java - DBUnit and Oracle JDBC (ClassCastException) -
i want dump test db raw xml file using dbunit , i'm getting classcastexception. below code:
new flatxmlwriter(new fileoutputstream("expected_ds.xml")). write(getdbunitconnection().createdataset(new string[]{"tab1","tab2"}));
and result :
java.lang.classcastexception: org.apache.commons.dbcp.delegatingresultset cannot cast oracle.jdbc.oracleresultset
i'm using ojdbc14-10.2.0.3.0.jar, commons-dbcp-1.2.2.jar , dbunit-2.4.7.jar.
is bug in oracle jdbc ? in ojdbc driver have found sth that:
/** * * todo unittests missing * @author phil barr * @author last changed by: $author: jbhurst $ * @version $revision: 1072 $ $date: 2009-10-12 19:46:45 +0200 (lun, 12 ott 2009) $ * @since 2.4.0 */ public class oraclexmltypedatatype extends blobdatatype { public object getsqlvalue(int column, resultset resultset) throws sqlexception, typecastexception { byte[] data = new byte[0]; oracleresultset oracleresultset = (oracleresultset) resultset; ... other stuf ... } ... }
it looks oracle issue , javadoc seems not tested @ all. has had similar problem?
the oracle jdbc driver not @ fault here.
it looks dbunit assumes can cast resultset
oracle-specific type. that's bad idea in first place (but can't avoided in cases).
since you're using connection pool, dbunit doesn't access oracle-specific object, wrapper provided pool instead.
either stop using pool tests or underlying connection pooled connection , pass dbunit (this risks dbunit closes physical connection, pool tries avoid providing wrapper).
Comments
Post a Comment