[jira] Closed: (DBUTILS-31) fillStatement setNull bug with the Derby JDBC driver

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (DBUTILS-31) fillStatement setNull bug with the Derby JDBC driver

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/DBUTILS-31?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed DBUTILS-31.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2

svn ci -m "Merging in Dab Fabulich's work on https://svn.apache.org/repos/asf/commons/sandbox/dbutils/bugfixing from -r741987:747723. Resolving DBUTILS-34 - DBUTILS-37 - DBUTILS-29 - DBUTILS-14 - DBUTILS-31 - DBUTILS-39 - DBUTILS-41 - DBUTILS-44 - DBUTILS-33 - DBUTILS-42 - DBUTILS-40"  

Sending        pom.xml
Sending        src/java/org/apache/commons/dbutils/BasicRowProcessor.java
Sending        src/java/org/apache/commons/dbutils/BeanProcessor.java
Sending        src/java/org/apache/commons/dbutils/QueryRunner.java
Adding         src/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java
Sending        src/java/org/apache/commons/dbutils/handlers/ArrayListHandler.java
Sending        src/java/org/apache/commons/dbutils/handlers/BeanListHandler.java
Sending        src/java/org/apache/commons/dbutils/handlers/ColumnListHandler.java
Deleting       src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java
Sending        src/java/org/apache/commons/dbutils/handlers/MapListHandler.java
Sending        src/test/org/apache/commons/dbutils/BaseTestCase.java
Adding         src/test/org/apache/commons/dbutils/QueryRunnerTest.java
Transmitting file data .........
Committed revision 747724.

> fillStatement setNull bug with the Derby JDBC driver
> ----------------------------------------------------
>
>                 Key: DBUTILS-31
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-31
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.0
>         Environment: Derby 10.1.2.1
>            Reporter: Francis Townsend
>             Fix For: 1.2
>
>
> 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.
> {code}
>     protected void fillStatement(PreparedStatement stmt, Object[] params)
>         throws SQLException {
>         if (params == null) {
>             return;
>         }
>         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));
>             }
>         }
>     }
> {code}
> 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 overhead.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.