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

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

為什么我的mybatis存儲html頁面的所有代碼到mysql數(shù)據(jù)庫的text類型中 直接存會報錯。

為什么我的mybatis存儲html頁面的所有代碼到mysql數(shù)據(jù)庫的text類型中 直接存會報錯。

寶慕林4294392 2019-03-01 10:31:59
這是代碼 public static void get(){ try { BufferedReader br=new BufferedReader(new FileReader(new File("tt.html"))); StringBuffer s=new StringBuffer(); String b; while ((b=br.readLine())!=null){ s.append(b+"\r\n"); } br.close(); InputStream inputStream= Resources.getResourceAsStream("mybatis_config.xml"); SqlSessionFactory sqlSessionFactory= new SqlSessionFactoryBuilder().build(inputStream); SqlSession sqlSession=sqlSessionFactory.openSession(); ArticleDao articleDao=sqlSession.getMapper(ArticleDao.class); TArticle article=new TArticle(); article.setContent(s.toString()); System.out.println(article.getContent()); article.setUuid(UUID.randomUUID().toString().replace("-","")); article.setDelsign("1"); article.setInserttime("1"); article.setIscollection("1"); article.setIsfabulous("1"); article.setIsopen("1"); article.setPointnumber("1"); article.setTitle("1"); article.setTypeid("1"); article.setUpdatetime("1"); article.setUrl("1"); article.setUserid("1"); articleDao.add(article); sqlSession.commit(); sqlSession.close(); } catch (IOException e) { e.printStackTrace(); } } 下面是異常 Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error committing transaction. Cause: org.apache.ibatis.executor.BatchExecutorException: cn.autually.dao.ArticleDao.add (batch index #1) failed. Cause: java.sql.BatchUpdateException: No value specified for parameter 1 ### Cause: org.apache.ibatis.executor.BatchExecutorException: cn.autually.dao.ArticleDao.add (batch index #1) failed. Cause: java.sql.BatchUpdateException: No value specified for parameter 1 at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:227) at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:218) at service.sss.get(sss.java:59) at service.sss.main(sss.java:25) Caused by: org.apache.ibatis.executor.BatchExecutorException: cn.autually.dao.ArticleDao.add (batch index #1) failed. Cause: java.sql.BatchUpdateException: No value specified for parameter 1 at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:146) at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:129) at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:122) at org.apache.ibatis.executor.BaseExecutor.commit(BaseExecutor.java:242) at org.apache.ibatis.executor.CachingExecutor.commit(CachingExecutor.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy11.commit(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:224) ... 3 more Caused by: java.sql.BatchUpdateException: No value specified for parameter 1 at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1666) at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1082) at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:122) ... 14 more 我試著輸出了讀出來的s,跟html的內(nèi)容一樣,但就是存不到數(shù)據(jù)庫里,不知道為什么,求大神指點
查看完整描述

3 回答

?
Qyouu

TA貢獻1786條經(jīng)驗 獲得超11個贊

找到問題了,是因為我用的自己寫的注解動態(tài)sql,如果儲存的字符串中有單引號''就會導致錄不進去,沒有單引號就沒問題,用mybatis逆向工程生成的mapper執(zhí)行一次儲存就沒問題.....這個是我暫時發(fā)現(xiàn)的直接原因,至于根本原因,還不清楚...

查看完整回答
反對 回復 2019-03-01
?
楊魅力

TA貢獻1811條經(jīng)驗 獲得超6個贊

failed. Cause: java.sql.BatchUpdateException: No value specified for parameter 1

這句話說你sql語句的一個參數(shù)沒有指定值給他
比如:

select * from employee where name =?

然后name沒有指定值給它,就會報這個錯誤。

查看完整回答
反對 回復 2019-03-01
?
慕碼人8056858

TA貢獻1803條經(jīng)驗 獲得超6個贊

前面實體類中 那么多 set 1的 這些數(shù)據(jù)類型都是字符串嗎??

查看完整回答
反對 回復 2019-03-01
  • 3 回答
  • 0 關(guān)注
  • 1556 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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