oracle - How to obtain OracleConnection with JNDI look-up -


in spring boot application, implemented class call stored procedure. 1 of input parameters of stored proc array. in order pass in array, oracleconnection needed. here code that:

@component @transactional public class fmtrfutil {     static int returnval;      @persistencecontext     private entitymanager em;     public int insertfmtrfs(list<string> trfs, string source) {             session session = em.unwrap( session.class );         final string[] trfarray = trfs.toarray(new string[trfs.size()]);         final string src = source;         session.dowork( new work(){             public void execute(connection conn) throws sqlexception {                 callablestatement stmt = null;                                oracleconnection oracon = conn.unwrap(oracleconnection.class);                 array array = oracon.createarray("varchar2_tab_t", trfarray);                 stmt = conn.preparecall("{? = call fm_trf_util.process_fm_trf(?,?)}");                 stmt.registeroutparameter(1, types.integer);                 stmt.setarray(2, array);                 stmt.setstring(3, src);                 stmt.execute();                 returnval = stmt.getint(1);             }         });         return returnval;     } } 

it works fine when testing in ide jdbc connection explicitly specified in spring profile (application.properties). when deployed war on our dev server jndi lookup datasource, got error java.sql.sqlexception: object not wrap requested interface @ line oracleconnection oracon = conn.unwrap(oracleconnection.class);. may indicate connection instance not valid. other rest calls not need connection still work though means jndi working.

the datasource set in context.xml of tomcat 7 follows:

<?xml version="1.0" encoding="utf-8"?> <context crosscontext="true">     <watchedresource>web-inf/web.xml</watchedresource>     <resource auth="container" driverclassname="oracle.jdbc.oracledriver" maxactive="10" maxidle="10" maxwait="-1"               name="jdbc/ristoredb" password="ristoreowner987" type="javax.sql.datasource" username="ristore_owner"               url="jdbc:oracle:thin:@ldap://mdaoid.xxx.org:389/risdev3,cn=oraclecontext,dc=ac,,dc=org"             /> </context> 

i have jndi name configured in application.properties:

spring.datasource.jndi-name=jdbc/ristoredb 

it seems obtaining jdbc connection not work jndi. correct way retrieve oracleconnection? if not work, there alternative pass array oracle stored procedure?


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -