views:

56

answers:

2

I have a table with a column of type XML. When I insert a record into this table from a servlet running in WebSphere on Windows, the insert succeeds. However, when I run exactly the 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'm running WebSphere 6.1 against a DB2 version 9, z/OS database.

Because of the platform difference, this feels alot like an encoding problem. But who knows. Any advice?

A: 

Just a guess, since I don't work with DB2, but a BLOB column probably requires that the input be a byte array, not a String.

Jim Garrison
I would totally by this - if it didn't work perfectly in my windows-based development environment, and then fail miserably in my AIX-based test environment.
Jared
Thw Windows JDBC driver may be more lenient converting String to BLOB
Jim Garrison
A: 

This turned out to be a "problem" with the JDBC driver configuration.

Another application running in the same JVM was configured to use the v8 JDBC driver. Mine was configured to use the v9 JDBC driver. But because of the way classloading works, the first one on the classpath was loading for both (which just so happened to be the v8 driver, which didn't work for my application.)

The fix was to switch both applications to use the v9 driver (which was fine, because it's supposedly completely backward compatible.)

Jared