Java – how to resolve the “illegal conversion” exception when inserting an XML column?

I have a table that contains columns of XML type When I insert records into this table in a servlet running in WebSphere on windows, the insertion succeeds However, when I run the exact same code in WebSphere on AIX, I get the following exception:

com.ibm.db2.jcc.c.sqlException: Illegal Conversion: Can not convert from "java.lang.String" to "java.sql.Blob"
        at com.ibm.db2.jcc.c.r.a(r.java:695)
        at com.ibm.db2.jcc.c.uf.b(uf.java:927)
        at com.ibm.db2.jcc.c.uf.setString(uf.java:910)
        at com.ibm.ws.rsadapter.spi.InternalGenericDataStoreHelper.psSetString(InternalGenericDataStoreHelper.java:554)
        at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.setString(WSJdbcPreparedStatement.java:1662)
        at org.hibernate.type.StringType.set(StringType.java:49)
        at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
        at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:131)
        at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2015)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2261)
        ... 33 more

I am running WebSphere 6.1.0 for DB2 version 9, Z / OS databases

Due to platform differences, this feels like a coding problem But who knows Any suggestions?

Solution

It turns out that this is a "problem" with jdbc driver configuration

Another application running in the same JVM is configured to use the V8 jdbc driver My configuration is to use V9 jdbc driver However, due to the way class loading works, the first one in the classpath loads two (this happens to be the V8 driver, which doesn't work for my application.)

The solution is to switch the two applications to use the V9 driver (which is good because it should be fully backward compatible.)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>