OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], but on …

Situation

Try to insert CLOB data to Oracle 11, but an error occurs.

spring-jdbc-3.1.0.jar

jdbcTemplate.update(INSERT_SQL, 
 new Object[] {new SqlLobValue(o.getLongString(), new OracleLobHandler()), ...},
 new int[] {Type.CLOB, ...});

Error occurs:

OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], not on [weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_T4CConnection_1036_WLStub]: specify a corresponding NativeJdbcExtractor; nested exception is java.lang.ClassCastException: weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_T4CConnection_1036_WLStub cannot be cast to oracle.jdbc.OracleConnection
org.springframework.dao.InvalidDataAccessApiUsageException: OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], not on [weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_T4CConnection_1036_WLStub]: specify a corresponding NativeJdbcExtractor; nested exception is java.lang.ClassCastException: weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_T4CConnection_1036_WLStub cannot be cast to oracle.jdbc.OracleConnection
 at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.createLob(OracleLobHandler.java:505) ~[spring-jdbc-3.1.0.RELEASE.jar:3.1.0.RELEASE]
 at org.springframework.jdbc.support.lob.OracleLobHandler$OracleLobCreator.setClobAsString(OracleLobHandler.java:413) ~[spring-jdbc-3.1.0.RELEASE.jar:3.1.0.RELEASE]
 at org.springframework.jdbc.core.support.SqlLobValue.setTypeValue(SqlLobValue.java:190) ~[spring-jdbc-3.1.0.RELEASE.jar:3.1.0.RELEASE]

 

Continue reading OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], but on …

Oracle 11gR2 SQL Reference Tips

使用Collection

http://docs.oracle.com/cd/B10501_01/appdev.920/a96624/05_colls.htm

Example:

DECLARE
  TYPE [USER_DEFINED_TYPE_NAME] IS TABLE OF [TABLE].[COLUMN]%TYPE;
  [VARIABLE_NAME] [USER_DEFINED_TYPE_NAME];

BEGIN
  SELECT [COLUMN] BULK COLLECT INTO [VARIABLE_NAME] FROM [TABLE] WHERE [CONDITIONS];
  FOR i IN 1..[VAIRABLE_NAME].COUNT LOOP
    BEGIN
      DBMS_OUTPUT.PUT_LINE(' DATA: '||[VARIABLE_NAME](i));
      ...
    END;
  END LOOP;
END;

Continue reading Oracle 11gR2 SQL Reference Tips