首页 新闻 搜索 专区 学院

Mybatis 错误,no value specified for parameter 1.....

0
悬赏园豆:10 [已解决问题] 解决于 2015-05-21 20:35

Exception in thread "Thread-1" org.springframework.jdbc.BadSqlGrammarException: ### Error updating database. Cause: java.sql.SQLException: No value specified for parameter 1 ### The error may involve com.oliver.mapper.inter.INewsItemMapper.insertNewsItem-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO news_item (title, link, type, url_code) VALUES (创业板回升翻红站上2300, http://finance.sina.cn/stock/dpps/2015-03-27/detail-iawzuney1223890.d.html?vt=4, 21, 3) ### Cause: java.sql.SQLException: No value specified for parameter 1 ; bad SQL grammar []; nested exception is java.sql.SQLException: No value specified for parameter 1 at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365) at com.sun.proxy.$Proxy10.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:237) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy21.insertNewsItem(Unknown Source) at com.oliver.dao.impl.NewsItemDao.insertNewsItem(NewsItemDao.java:22) at com.oliver.service.impl.NewsItemService.addNewsItemList(NewsItemService.java:32) at com.oliver.spiders.utils.SpiderUtils.saveNewsItemList(SpiderUtils.java:34) at com.oliver.spiders.utils.SpiderUtils.saveNewsTitle(SpiderUtils.java:144) at com.oliver.spiders.StockNewsSpider.refreshStockNews(StockNewsSpider.java:52) at com.oliver.spiders.task.StockNewsTask.run(StockNewsTask.java:24) at java.lang.Thread.run(Thread.java:722) Caused by: java.sql.SQLException: No value specified for parameter 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920) at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2613) at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2588) at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2512) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1316) at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44) at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105) at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152) at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355) ... 12 more

 

参数明明足够了,为什么还报这个错误啊,求大神解答!

湖心北斗的主页 湖心北斗 | 初学一级 | 园豆:186
提问于:2015-04-18 20:14
< >
分享
最佳答案
0

感觉是你的sql语句的参数用法错了。你注意看异常里面的sql语句。#param# ,这样才是参数化哦。

收获园豆:10
幻天芒 | 高人七级 |园豆:36662 | 2015-04-18 23:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册