在无状态bean中,我试图插入到具有OID字段的表中。请在下面找到以下代码段:
DataSource dataSource = (DataSource) context.lookup(JNDI_NAME);
Connection connection = dataSource.getConnection();
PreparedStatement statement = connection.prepareStatement(sql.toString());
byte[] streamOutput = responseData.getBytes();
LargeObjectManager largeObjectManager = ((org.postgresql.PGConnection)connection).getLargeObjectAPI();
long oid = largeObjectManager.createLO(LargeObjectManager.READ | LargeObjectManager.WRITE);
LargeObject largeObject = largeObjectManager.open(oid, LargeObjectManager.WRITE);
largeObject.write(streamOutput);
largeObject.close();
我在LargeObjectManager largeObjectManager = ((org.postgresql.PGConnection)connection).getLargeObjectAPI();
org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6无法强制转换为org.postgresql.PGConnection:java.lang.ClassCastException:org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6不能强制转换为org.postgresql.PGConnection
Stateless bean的TransactionManagementType设置为Container。
我正在使用Postgresql 9.1和JBoss AS7.1
有人可以帮助我吗?
答案 0 :(得分:1)
通常这意味着您的类路径上有两个不同的库。确保您的部署中没有包含PostgreSQL库。