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] Updated: (DBUTILS-55) Oracle: Can't insert null into BFILE parameter
Date Mon, 13 Apr 2009 06:05:14 GMT

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

Dan Fabulich updated DBUTILS-55:
--------------------------------

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

  was:
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/welcome@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.


> 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:
> {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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message