commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hernan Silberman <>
Subject [DBUtils] Oracle null/"Invalid Column Type"
Date Wed, 02 Jun 2004 23:54:44 GMT

I've run into a JDBC issue that I haven't found good help on elsewhere so I 
thought I'd bring it up.  I'm using Oracle driver v9.2.0.

QueryRunner's fillStatement deals with Java null parameters by doing a 

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

    if (params == null) {

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

Unfortunately, when the statement gets executed with a null parameter, an 
exception is thrown in Oracle's JDBC driver which complains with the exception 
message "Invalid column type".  I've written a few tests using JDBC and have 
discovered that using something other than Types.OTHER (like Types.STRING, 
Types.FLOAT, etc) in the setNull call fixes the problem and unconfuses Oracle's 
type mapper.

I'm not familiar enough with the JDBC spec to know whether 
setNull(idx,Types.OTHER) is guaranteed to work everywhere and whether or not I'm 
dealing with a bug Oracle's driver.  Seems like a popular RDBMS and I'm 
wondering if any of you have run into this before and have worked around it.

I've found the following reference, though it's not exactly the case I'm running 
into doesn't provide much help.  I see this issue regardless of column/java 

Here's a stack trace:

java.sql.SQLException: Invalid column type
at org.apache.commons.dbutils.QueryRunner.rethrow(
at org.apache.commons.dbutils.QueryRunner.update(
at org.apache.commons.dbutils.QueryRunner.update(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at sun.rmi.server.UnicastServerRef.dispatch(
at sun.rmi.transport.Transport$
at Method)
at sun.rmi.transport.Transport.serviceCall(
at sun.rmi.transport.tcp.TCPTransport.handleMessages(
at sun.rmi.transport.tcp.TCPTransport$

Any guidance is greatly appreciated.


Hernan Silberman

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

View raw message