mybatis invalid column type: 1111

    nested exception is org.springframework.jdbc.UncategorizedSQLException: Error setting null for parameter #2 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111

; uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; Invalid column type: 1111; nested exception is java.sql.SQLException: Invalid column type: 1111] with root cause

java.sql.SQLException: Invalid column type: 1111

 

Reason: The field of the incoming parameter is a null object, and the corresponding jdbcType type cannot be obtained, and an error is reported.

 

Solution:

1. Specify the insert value jdbcType, and change the sql to  insert into user(id,name) values(#{id,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR}) 

 

2. Configure it in the mybatis-config.xml file and add the settings configuration, as follows: (recommended)

<configuration>

<settings>

    <setting name="jdbcTypeForNull" value="NULL" />

</settings>

</configuration>

 

normal operation.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326537776&siteId=291194637