Hi,
When i debug the code, it doesnt get to the point where i am initialising
the OracleCallableStatement object. It failed just after the initialisation
of the ArrayDescriptor object.
I have tried to change it to use CallableStatement and im now getting
another error. Here is how i've changed it to.
CallableStatement cst =
conn.prepareCall(stp.SUBMIT_CONSIGNMENT_STORED_PROC);
ArrayDescriptor rectabDescriptor =
ArrayDescriptor.createDescriptor("CCS21_CONSIGNMENTLIST_TYPE",conn);
ARRAY awbNoHwbs = new
ARRAY(rectabDescriptor,conn,childLessAwbs);
ARRAY hwbs = new ARRAY(rectabDescriptor,conn,hwbList);
context.xml
<Resource name="jdbc/ccs21db" auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@xxx.xxx.xxx:1525:dbsid"
username="xxx" password="xxx" maxActive="20" maxIdle="10"
maxWait="-1"/>
web.xml
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/ccs21db</res-ref-name>
<res-type>oracle.jdbc.pool.OracleDataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
And here is the stack trace
java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:149)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:115)
at
com.abbt.ccs21.data.accessors.ConsignmentDAO.submitDeclaration(ConsignmentDAO.java:301)
at
com.bt.abccs21.presentation.events.consignments.select.SubmitDeclaration.midAction(SubmitDeclaration.java:68)
at
com.bt.abccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:36)
at
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
On Fri, Sep 26, 2008 at 5:57 PM, Christopher Schultz <
[EMAIL PROTECTED]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dini,
>
> Dini Omar wrote:
> > I am trying to send an array to a pl/sql module but for some reason i am
> > unable to get the connection object.
> >
> > Here is the line of code that fails
> >
> > [code]
> > Connection conn = null;
> > ArrayDescriptor rectabDescriptor =
> > ArrayDescriptor.createDescriptor("CCS21_CONSIGNMENTLIST_TYPE",conn);
>
> It's odd that your exception says DelegatingCallableStatement (which is
> the actual type of the object being casted) when the line indicated
> neither performs a cast, nor does anything with a statement.
>
> Are you sure this is the right line number?
>
> > <<FAILS HERE<<
> > ARRAY awbNoHwbs = new ARRAY(rectabDescriptor,conn,childLessAwbs);
> > ARRAY hwbs = new ARRAY(rectabDescriptor,conn,hwbList);
> >
> > OracleCallableStatement cst =
> >
> (OracleCallableStatement)conn.prepareCall(stp.SUBMIT_CONSIGNMENT_STORED_PROC);
>
> I'm guessing that the above line is the one where the problem is really
> occurring. conn.prepareCall returns a DelegatingCallableStatement
> instead of the Oracle-specific one you are expecting.
>
> Do you /need/ to use OracleCallableStatement, here? If not, you should
> simply use java.sql.CallableStatement and you should be good to go.
>
> If you need to access the underlying OracleCallableStatement, then
> you'll need to go through some hoops to get that actual object. Perhaps
> something like this:
>
> DelegatingCallableStatement dcs =
> conn.prepareCall(stp.SUBMIT_CONSIGNMENT_STORED_PROC);
>
> OracleCallableStatement =
> (OracleCallableStatement)dcs.getInnermostDelegate();
>
> This is a big dangerous, though, because Tomcat doesn't make too many
> guarantees about the structure of the objects in the dbcp.dbcp package.
> Also, the "innermost delegate" might not actually be your Oracle statement.
>
> My advise would be to try to stick to using only objects and interfaces
> in the JDBC API unless you absolutely need to (for instance, to create
> Oracle-specific arrays from templates or whatever this stuff is).
>
> The Oracle driver ought to allow you to interact a bit more naturally
> with the JDBC API and not require you to use OracleCallableStatement
> objects and stuff like that.
>
> Hope that helps,
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkjdFH4ACgkQ9CaO5/Lv0PARMgCgphBlDrwQWBWW73/a2cAG82Ju
> RaUAmwSmGtca3RVQc91kORrMuXiy2DXs
> =kZ3E
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: [email protected]
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>