• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic