aspose file tools*
The moose likes JDBC and the fly likes Oracle JDBC driver does not support Datatypes defined in java.sql? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle JDBC driver does not support Datatypes defined in java.sql? " Watch "Oracle JDBC driver does not support Datatypes defined in java.sql? " New topic
Author

Oracle JDBC driver does not support Datatypes defined in java.sql?

Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

Hi All,

I get a Class Cast Exception when I invoke the
setClob(int index, Clob aClob) of the PreparedStatement (extended by OraclePreparedStatement). on Oracle Database. ( this works fine with MySqL, setting a Clob on the preparedStatement ofcourse using the MySql jdbc driver).

Please note that the setCLOB method that takes an oracle CLOB Object of the ORaclePreparedStatement works fine,hence the deduction that there is something wrong.


Environment.
JDBC Driver : ojdbc14.jar
JDK : 1.4
Database : 10G.
[ November 29, 2004: Message edited by: RajaniKanth Bhargava ]
Bob Frapples
Ranch Hand

Joined: Mar 08, 2002
Posts: 32
you must be mismatching something

i've never heard of anyone having any problems mapping JDBC objects to database tables

that said, it could potentially be a driver issue, but I seriously doubt it

might help to post the code & stack trace
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

"Brackish Water",

Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

Hi Bob,

Thanks for the response...but let me tell you there is no ambiguity in my question or my understanding of the problem....

it is simple.. the setClob(paramindex nInt, java.sql.Clob aClob) simply throws a java.lang.ClassCastException, and there is no stack trace other than three lines of Exception info...the Exception is thrown in the setClob() method on the Ojdbc Driver.

And as you figured out I too think its a driver problem...and this is what I think is happenning.

oracle.sql.CLOB, implements the java.sql.Clob interface, so Obviously when we invoke setClob on the PreparedStatement (which is actually an instance of the type OraclePreparedStatement which implements the setClob method), the first thing this method does is cast the given Clob type to CLOB type...and hence the Exception and I think this is a bug because it does not guarantee the contract that is defined in the PreparedStatement, the standard JDBC Interface that should work on any driver.

No one has come up with this problem because, in general all developers use the Data type implementations that the Oracle Driver provides.

but just imagine, if you are trying to insert a Clob being read from one database (MySQL) and being set to another (Oracle) should work fine as long as I am handling the interfaces defined in the sql package. ( this is just a scenario)...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Oracle JDBC driver does not support Datatypes defined in java.sql?