Description:
I'm trying to insert an object in a mysql db, but an error apeared when obtaining the generated key for the object.
After investigating, I found the obvious error in the jdbc driver:
com.mysql.jdbc.jdbc2.optional.ConnectionWrapper contains this methods:
/**
* @see Connection#prepareStatement(String, int)
*/
public java.sql.PreparedStatement prepareStatement(String arg0, int arg1)
throws SQLException {
checkClosed();
try {
PreparedStatementWrapper.getInstance(this, this.mpc, this.mc
.prepareStatement(arg0, arg1));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#prepareStatement(String, int[])
*/
public java.sql.PreparedStatement prepareStatement(String arg0, int[] arg1)
throws SQLException {
checkClosed();
try {
PreparedStatementWrapper.getInstance(this, this.mpc, this.mc
.prepareStatement(arg0, arg1));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#prepareStatement(String, String[])
*/
public java.sql.PreparedStatement prepareStatement(String arg0,
String[] arg1) throws SQLException {
checkClosed();
try {
PreparedStatementWrapper.getInstance(this, this.mpc, this.mc
.prepareStatement(arg0, arg1));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
return null; // we don't reach this code, compiler can't tell
}
Notice that a return call is missing and they always return null.
Version 5.0.8 is fine.
How to repeat:
I don't think instructions are needed here, the bug is obvious.
Suggested fix:
Modify the methods to return the prepared statements.