spring - Retrieving Native Connection from JBOSS wrapped Connection -
i need pass array object oracle 11 db. using annotations based spring 3.1 , using simplejdbccall phone call procedure on jboss server. here relevant jdbccall.
simplejdbccall phone call = new simplejdbccall(datasource) .withoutprocedurecolumnmetadataaccess() .withprocedurename(ibegindatabaseconstants.procedure_create_new_admin.val) .declareparameters(new sqlparameter("inuserempid", oracletypes.integer)) .declareparameters(new sqlparameter("incountryids", oracletypes.array, "ibo_number_array" )) .declareparameters(new sqlparameter("insysroleid", oracletypes.integer)) .declareparameters(new sqlparameter("inloggedin", oracletypes.integer)) .declareparameters(new sqloutparameter("outstatus", oracletypes.char)) .declareparameters(new sqloutparameter("outmsg", oracletypes.varchar)); as can see incountryidsis array need send.
with help google, able multiple ways through can send array db. here first one.
sqltypevalue value = new abstractsqltypevalue() { protected object createtypevalue(connection conn, int sqltype, string typename) throws sqlexception { arraydescriptor arraydescriptor = new arraydescriptor(typename, conn); array idarray = new array(arraydescriptor, conn, ids); homecoming idarray; } and added parameter source using
sourcemap.addvalue("inuserempid", newadmin.getempid()); sourcemap.addvalue("incountryids", value); sourcemap.addvalue("insysroleid", newadmin.getroleid()); sourcemap.addvalue("inloggedin", newadmin.getloggedinid()); and exception got org.jboss.jca.adapters.jdbc.jdk6.wrappedconnectionjdk6 cannot cast oracle.jdbc.oracleconnection
i understood reason, sqltypevalue implemention requires oracleconnection whereas spring passes wrappedconnection.
so, tried disclose connection using wrappedconnection class code.
wrappedconnection wrappedconnection = conn.unwrap(wrappedconnection.class); but here exception was
not wrapper for: org.jboss.jca.adapters.jdbc.wrappedconnection in try, tried cast existing connection wrappedconnection using explicit cast this.
wrappedconnection wrappedconn = (wrappedconnection)conn; and still no luck. exception.
org.jboss.jca.adapters.jdbc.jdk6.wrappedconnectionjdk6 cannot cast org.jboss.jca.adapters.jdbc.wrappedconnection well, had retrieve underlying connection, tried cast wrappedconnectionjdk6 able phone call relevent method there.
wrappedconnectionjdk6 wrappedconnection = (wrappedconnectionjdk6)conn; leads org.jboss.jca.adapters.jdbc.jdk6.wrappedconnectionjdk6 cannot cast org.jboss.jca.adapters.jdbc.jdk6.wrappedconnectionjdk6
and sec approach
map in = collections.singletonmap("incountryids", new sqlarrayvalue(idsarray)); the problem approach collections.singletonmap returns immutable map. so, can't utilize add together more parameters.
is there way through can retrieve underlying connection in jboss wrapped connection ? or there other mechanism through can pass array paramter without having interact connection ?
spring jboss7.x jdbctemplate
No comments:
Post a Comment