0

Orale WebLogic で実行される既存の SpringMVC J2EE アプリケーションがあり、これを Apache Tomcat に移行しようとしています。JDBC を介して配列値をデータベースにバインドする際に問題が発生していることを除いて、すべてが機能しているようです。以下は、WebLogic で成功した方法です。

SqlParameterSource in = new MapSqlParameterSource()
                .addValue("i_username", user.getUsername())
                .addValue("i_statuses",
                        new SqlArrayValue<String>(statuses,
                                "VARCHAR_TABLE_T"));

Map<String, Object> out = myDatabaseProc.execute(in);

statuses 変数は String 配列で、VARCHAR_TABLE_T は同じ Oracle DB タイプです。SqlArrayValue は、JDBC での Oracle 配列処理専用の Spring クラスです。

コードが実行されると、次のエラーが発生します (これも Tomcat でのみ壊れています)。

java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp2.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.jdbc.OracleConnection
        at oracle.sql.TypeDescriptor.setPhysicalConnectionOf(TypeDescriptor.java:803) ~[ojdbc8.jar:12.2.0.1.0]
        at oracle.sql.TypeDescriptor.<init>(TypeDescriptor.java:585) ~[ojdbc8.jar:12.2.0.1.0]
        at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:258) ~[ojdbc8.jar:12.2.0.1.0]
        at org.springframework.data.jdbc.support.oracle.SqlArrayValue.createTypeValue(SqlArrayValue.java:90) ~[spring-data-oracle-1.2.1.RELEASE.jar:?]
        at org.springframework.jdbc.core.support.AbstractSqlTypeValue.setTypeValue(AbstractSqlTypeValue.java:60) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:293) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:232) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:147) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:209) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1090) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1147) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:412) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:372) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
        at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:198) ~[spring-jdbc-5.2.3.RELEASE.jar:5.2.3.RELEASE]

ベンダー固有のアクションを実行できるように接続をアンラップすることについてオンラインでたくさん見つけましたが、Spring が私のためにそれを行うべきだと思われますか? 接続リソースがセットアップされているTomcatのserver.xml(オンラインで見つけたもの)でaccessToUnderlyingConnectionAllowedをtrueに設定しようとしましたが、動作には影響しませんでした。

これは server.xml のリソースです。

<Resource name="jdbc/datasource" auth="Container"
          type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
          url="jdbc:oracle:thin:@//db.domain.com:port/sid"
          username="user" password="password"
          maxTotal="15" maxIdle="3" maxWaitMillis="-1"
          accessToUnderlyingConnectionAllowed="true" />
4

1 に答える 1