最近忙,很久没来写博文了,惭愧。今天遇到如题的问题,就是在mybatis 插入oracle数据库空值的报的异常: 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: Invalid column type ; uncategorized SQLException for SQL []; SQL state [null]; error code [17004]; Invalid column type; nested exception is java.sql.SQLException: Invalid column typejava
开始sql是这样写的insert into user(id,name) values(#{id},#{name}) spring
解决方法:sql
1、指定插入值得jdbcType,将sql改为 insert into user(id,name) values(#{id,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR}) 数据库
2、在mybatis-config.xml文件中配置一下,添加settings配置,以下:(推荐)mybatis
<configuration>oracle
......学习
<settings>ui
<setting name="jdbcTypeForNull" value="NULL" />
spa
</settings>code
......
</configuration>
问题解决,继续码码,但愿常来写博文,共同窗习~~~