commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francis Townsend (JIRA)" <>
Subject [jira] Created: (DBUTILS-31) fillStatement setNull bug with the Derby JDBC driver
Date Tue, 13 Jun 2006 00:46:29 GMT
fillStatement setNull bug with the Derby JDBC driver

         Key: DBUTILS-31
     Project: Commons DbUtils
        Type: Improvement

    Versions: 1.0 Final    
 Environment: Derby
    Reporter: Francis Townsend

This has been documented many times before, but I was not happy with the existing code fixes.
 The following small code snippet should fix it for all conforming JDBC drivers.

    protected void fillStatement(PreparedStatement stmt, Object[] params)
        throws SQLException {

        if (params == null) {
        ParameterMetaData pmd = stmt.getParameterMetaData();
        for (int i = 0; i < params.length; i++) {
            if (params[i] != null) {
                stmt.setObject(i + 1, params[i]);
            } else {
                stmt.setNull(i + 1, pmd.getParameterType(i + 1));

The only difference is that you get the parameter meta data and pass that type information
to the setNull method.  This should neatly fix this problem, with a very slight additional

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message