commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carl Hall (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DBUTILS-55) Oracle: Can't insert null into BFILE parameter
Date Fri, 17 Apr 2015 01:45:58 GMT

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

Carl Hall commented on DBUTILS-55:
----------------------------------

[~britter], I think this is directly related to DBUTILS-90 rather than DBUTILS-117.

> 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.1, 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:
> {code}
> OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource();
> ds.setURL("jdbc:oracle:thin:system/welcome@mydbhost:1521:XE");
> QueryRunner runner = new QueryRunner(ds);
> runner.update("INSERT INTO dbutilstest(col1) values (?)", new Object[] {null});
> {code}
> Expected: Code should run without error
> Actual:
> {code}
> 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)
> {code}
> 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 was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message