1.

Why Do I Get Conversionexception When Using Rowsetdynaclass With Oracle?

Answer»

Oracle's JDBC driver is broken. When a query is run against a table containing a Timestamp column, the result set's metadata reports the column TYPE (correctly) as javax.sql.Timestamp. And therefore the DynaClass object created to represent the query has a field of type javax.sql.Timestamp to store the data for that column in. However calling resultset.getObject on that column returns an object of type javax.sql.Date(!), which then of course cannot be assigned to the corresponding field on a DynaBean object with that DynaClass.

This has been reported with Oracle10g, driver ojdbc14 version 10.1.0.4.

POSSIBLE solutions (untested) are:

  • subclass RowSetDynaClass and override the copy method to fudge the conversion.
  • subclass BasicDynaBean and override the set method to handle the PROBLEM, then subclass RowSetDynaClass and override createDynaBean to return instances of your custom BEAN that handles broken Oracle resultsets.

Oracle's JDBC driver is broken. When a query is run against a table containing a Timestamp column, the result set's metadata reports the column type (correctly) as javax.sql.Timestamp. And therefore the DynaClass object created to represent the query has a field of type javax.sql.Timestamp to store the data for that column in. However calling resultset.getObject on that column returns an object of type javax.sql.Date(!), which then of course cannot be assigned to the corresponding field on a DynaBean object with that DynaClass.

This has been reported with Oracle10g, driver ojdbc14 version 10.1.0.4.

Possible solutions (untested) are:



Discussion

No Comment Found