Oracle: Can't insert null into BFILE parameter
----------------------------------------------

                 Key: DBUTILS-55
                 URL: https://issues.apache.org/jira/browse/DBUTILS-55
             Project: Commons DbUtils
          Issue Type: Bug
    Affects Versions: 1.2
            Reporter: Dan Fabulich
            Priority: Trivial


Download and install Oracle Express Edition (XE) 10.2 (it's free) 
http://www.oracle.com/technology/products/database/xe/index.html

Run "sqlplus" and create a table like this: "create table dbutilstest(col1 
bfile);"

Then, using the JDBC jar from here 
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html
 

Run this:

OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource();
ds.setURL("jdbc:oracle:thin:system/welc...@mydbhost:1521:XE");
QueryRunner runner = new QueryRunner(ds);
runner.update("INSERT INTO dbutilstest(col1) values (?)", new Object[] {null});

Expected: Code should run without error
Actual: Exception in thread "main" java.sql.SQLException: ORA-00932: 
inconsistent datatypes: expected FILE got CHAR
 Query: INSERT INTO dbutilstest(col1) values (?) Parameters: [null]
        at org.apache.commons.dbutils.QueryRunner.rethrow(QueryRunner.java:540)
        at org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:597)
        at org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:653)

Why is this happening?  Because Oracle's JDBC driver doesn't support 
ParameterMetaData.getParameterType, we coded up a workaround to call 
PreparedStatement.setNull(index, java.sql.Types.VARCHAR) by default when we 
can't determine the parameter type (e.g. Oracle).  This works for most column 
types, but not BFILE.  For BFILE, you get the error above.

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

Reply via email to