commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Fabulich (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DBUTILS-31) fillStatement setNull bug with the Derby JDBC driver
Date Sun, 08 Feb 2009 22:08:59 GMT

    [ https://issues.apache.org/jira/browse/DBUTILS-31?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12671689#action_12671689
] 

Dan Fabulich commented on DBUTILS-31:
-------------------------------------

Unfortunately, Oracle 10.2 JDBC drivers still don't support getParameterMetaData, even as
recently as Oct 2008.  http://forums.oracle.com/forums/thread.jspa?threadID=585880

You have to register to read that link (it's free but it's a hassle).  But the most recent
post is confirming that it's still broken in Oct 2008.  If you call getParameterType, you
get error ORA-17023 "Unsupported feature."  Lame!

> 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
>
> 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.


Mime
View raw message