Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatementCreatorUtils handling of null values incompatible with Informix [SPR-2407] #7096

spring-projects-issues opened this issue Aug 11, 2006 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Aug 11, 2006

Scott Schenkein opened SPR-2407 and commented

Under 1.2.7, attempts to insert NULL's in JdbcTemplate.update using a prepared statement fail on Informix. They succeed under the 1.1 tree. The difference is

Old (StatementCreatorUtils, 94)

if (sqlType == SqlTypeValue.TYPE_UNKNOWN) {
        // possible alternative: ps.setNull(paramIndex, Types.NULL);
        ps.setObject(paramIndex, null);


if (sqlType == SqlTypeValue.TYPE_UNKNOWN) {
        ps.setNull(paramIndex, Types.NULL);

When the updated null handler runs on Informix, the update/insert fails, and you get this stack trace:

java.sql.SQLException: Unknown object type
at com.informix.util.IfxErrMsg.getSQLException(
at com.informix.jdbc.IfxValue.a(
at com.informix.jdbc.IfxValue.a(
at com.informix.jdbc.IfxValue.c(
at com.informix.jdbc.IfxValue.a(
at com.informix.jdbc.IfxValue.a(
at com.informix.jdbc.IfxPreparedStatement.setNull(
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(
at org.springframework.jdbc.core.JdbcTemplate$ArgPreparedStatementSetter.setValues(
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(
at org.springframework.jdbc.core.JdbcTemplate.execute(
at org.springframework.jdbc.core.JdbcTemplate.update(
at org.springframework.jdbc.core.JdbcTemplate.update(
at org.springframework.jdbc.core.JdbcTemplate.update(

Affects: 1.2.7, 2.0 RC3

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 20, 2006

Juergen Hoeller commented

Thanks for pointing this out! It's a bit of a pain that databases differ in such subtle details. As you noticed, we also changed our strategy in Spring 1.2 there, since it was found to be the most compatible strategy for all databases that we tested against.

To be able to properly adapt to Informix, our StatementCreatorUtils uses "PreparedStatement.setObject(index, null)" for null values with unknown SQL type on Informix now. We simply have a special check that detects Informix via the metadata's database product name, choosing the appropriate null strategy accordingly.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants