第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么測試這樣報錯

為什么測試這樣報錯

薛定諤de貓 2017-06-27 17:42:26
package?junit4; import?java.util.Date; import?hibernate.Students; import?org.hibernate.*; import?org.hibernate.cfg.Configuration; import?org.hibernate.service.ServiceRegistry; import?org.hibernate.service.ServiceRegistryBuilder; import?org.junit.After; import?org.junit.Before; import?org.junit.Test; public?class?StudentsTest?{ private?SessionFactory?sessionFactory; private?Session?session; private?Transaction?transaction; @Before public?void?init(){ //創(chuàng)建配置對象 Configuration?config?=?new?Configuration().configure(); //創(chuàng)建服務注冊對象 ServiceRegistry?serviceRegistry?=?new?ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry(); //創(chuàng)建會話工廠對象 sessionFactory?=config.buildSessionFactory(serviceRegistry); //打開會話 session?=?sessionFactory.openSession(); //打開事物 transaction?=?session.beginTransaction(); System.out.println(1); } @After public?void?destory(){ transaction.commit();//提交事務 session.close();//關閉會話 sessionFactory.close();//關閉會話工廠 } @Test public?void?testSaveStudents(){ //生成學生對象 Students?s?=new?Students(1,"張三豐","男",new?java.sql.Date(new?Date().getTime()),"武當山"); session.save(s);//保存對象進入數(shù)據(jù)庫 } } ERROR:?You?have?an?error?in?your?SQL?syntax;?check?the?manual?that?corresponds?to?your?MySQL?server?version?for?the?right?syntax?to?use?near?'-001.students?(name,?gender,?birthday,?adress,?sid)?values?('張三豐',?'男',?'?at?line?1
查看完整描述

1 回答

?
大咪

TA貢獻785條經驗 獲得超332個贊

你new student對應set值的那個Date類型不對吧,我怎么看著這么別扭,我覺得Date應該是util包而不是sql包吧?

查看完整回答
反對 回復 2017-06-27
  • 薛定諤de貓
    薛定諤de貓
    我一開始用的是new Date()發(fā)現(xiàn)一直是這個錯誤,以為是應該用成sql包,但是還是這個錯誤
  • 薛定諤de貓
    薛定諤de貓
    Students s =new Students(1,"張三豐","男",new Date(),"武當山");這樣也是報同樣的錯誤
  • qq_Soulmate_0
    qq_Soulmate_0
    如果是注解配置,請查看你的實體類的字段是否和數(shù)據(jù)表字段做了映射,如果是xml配置的映射,請檢查xml的映射文件。
  • 1 回答
  • 0 關注
  • 1301 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號