28 Feb 2013

org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter.

Problem: org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters.

Cause: The JdbcType property is not set in the XML mapper.

Solution: Specify jdbcType of the parameter in the mapper.

<select id="selectByYear" parameterType="map" resultMap="BaseResultMap"> SELECT * FROM tbl_calendar WHERE year=#{year,jdbcType=DECIMAL} </select>

No comments: