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

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

Comments

@spring-projects-issues
Copy link
Collaborator

@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);
}

New


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(IfxErrMsg.java:373)
at com.informix.jdbc.IfxValue.a(IfxValue.java:405)
at com.informix.jdbc.IfxValue.a(IfxValue.java:642)
at com.informix.jdbc.IfxValue.c(IfxValue.java:617)
at com.informix.jdbc.IfxValue.a(IfxValue.java:593)
at com.informix.jdbc.IfxValue.a(IfxValue.java:394)
at com.informix.jdbc.IfxPreparedStatement.setNull(IfxPreparedStatement.java:636)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:96)
at org.springframework.jdbc.core.JdbcTemplate$ArgPreparedStatementSetter.setValues(JdbcTemplate.java:1181)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:696)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:476)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:692)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:754)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:762)


Affects: 1.2.7, 2.0 RC3

@spring-projects-issues
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.

Juergen

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

Successfully merging a pull request may close this issue.

None yet
2 participants