最近忙,很久沒來寫博文了,慚愧。今天遇到如題的問題,就是在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>
問題解決,繼續碼碼,但願常來寫博文,共同窗習~~~