Oracle JDBC driver does not support Datatypes defined in java.sql?
Joined: Mar 18, 2004
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.
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)...