Druid's oracle problem

Druid's Pit

When the Clob of the query database is converted to the Oracle Clob type.

java.lang.ClassCastException: com.alibaba.druid.proxy.jdbc.ClobProxyImpl cannot be cast to oracle.sql.CLOB

problem causes

ClobProxyImpl cannot be converted to Oracle's Clob field, which is also drunk.

The reason is that Druid adds a proxy class for the Clob field: com.alibaba.druid.proxy.jdbc.ClobProxyImpl, and then the code is forced to convert to Oracle's Clob, and this problem occurs.

solution

The current solution is to convert it to Druid's proxy class ClobProxy object first, and then get the native Oracle Clob field content.

public class ClobUtil { public static CLOB parseOracleClob(Clob clob) { SerializableClob sclob = (SerializableClob) clob; Clob wrappedClob = sclob.getWrappedClob(); // 解决Druid的坑 if (wrappedClob instanceof ClobProxy) { ClobProxy clobProxy = (ClobProxy) wrappedClob; wrappedClob = clobProxy.getRawClob(); } return (CLOB) wrappedClob; }}

Please add the code and all resources to the java group 274435854 to download, let's learn and communicate together.

The road to architecture, featured headlines, a dry article every day, if you like it, just collect + follow it!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325647478&siteId=291194637