-
Notifications
You must be signed in to change notification settings - Fork 38.5k
NPE in Spring-JDBC with Oracle and SimpleJdbcInsert [SPR-16495] #21038
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
Comments
Juergen Hoeller commented This turns out to be rather odd: The only reference that can be |
Juergen Hoeller commented This seems to be a side effect of the #19234 refactoring: Instead of catching |
John Ahlroos commented Here is the difference in the implementations of lookupDefaultSchema(). In 4.3.6 we consume the NPE in an empty catch clause: private void lookupDefaultSchema(DatabaseMetaData databaseMetaData) {
try {
CallableStatement cstmt = null;
try {
cstmt = databaseMetaData.getConnection().prepareCall("{? = call sys_context('USERENV', 'CURRENT_SCHEMA')}");
cstmt.registerOutParameter(1, Types.VARCHAR);
cstmt.execute();
this.defaultSchema = cstmt.getString(1);
}
finally {
if (cstmt != null) {
cstmt.close();
}
}
}
catch (Exception ignore) {
}
} While in 4.3.7 we only catch the SQLExceptions and let the NPE pass: private void lookupDefaultSchema(DatabaseMetaData databaseMetaData) {
try {
CallableStatement cstmt = null;
try {
cstmt = databaseMetaData.getConnection().prepareCall(
"{? = call sys_context('USERENV', 'CURRENT_SCHEMA')}");
cstmt.registerOutParameter(1, Types.VARCHAR);
cstmt.execute();
this.defaultSchema = cstmt.getString(1);
}
finally {
if (cstmt != null) {
cstmt.close();
}
}
}
catch (SQLException ex) {
logger.debug("Encountered exception during default schema lookup", ex);
}
} That is most likely why it stopped working. Why the connection is null from |
Juergen Hoeller commented We posted at almost the same time there, coming to the same conclusion :-) Since we're generally trying to avoid accidental over-catching, I've added a not-null check for the |
John Ahlroos opened SPR-16495 and commented
When running the following code:
This code will work with Spring JDBC 4.3.6.RELEASE but if I change it to 4.3.7.RELEASE or above it will fail in:
Affects: 4.3.14
Issue Links:
Referenced from: commits f2dc075, 766e602
Backported to: 4.3.15
The text was updated successfully, but these errors were encountered: