智慧景区网站建设,省厅建设信息网网站,备份管理wordpress,网站栅格布局今天在调试的过程中发现一个bug#xff0c;把传入的参数写到查询分析器中执行没有问题#xff0c;但是在程序中执行就报错#xff1a;org.springframework.jdbc.UncategorizedSQLException : Error setting null parameter. Most JDBC drivers require that the JdbcType m…今天在调试的过程中发现一个bug把传入的参数写到查询分析器中执行没有问题但是在程序中执行就报错org.springframework.jdbc.UncategorizedSQLException : Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters. Cause: java.sql.SQLException无效的列类型 网上找了很久才找到了错误原因myBatis的参数不能传入null但是在查询分析器中参数为null是允许的如果传入了nullSQL在类型匹配时找不到匹配的类型就会报上面的错。 解决办法
1、在参数后面添加jdbcTypeVARCHAR
2、使用if标签
if testid ! null and id ! and id #{id}
/if
3、将null替换成“”字符串 例如把 insert into user(id,name) values(#{id},#{name}) 修改成insert into user(id,name) values(#{id,jdbcTypeVARCHAR},#{name,jdbcTypeVARCHAR}) 就可以解决这个问题了。