wood burning stoves 2.0*
The moose likes JDBC and the fly likes Call Stored Procedure Returning Cursor as Output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Call Stored Procedure Returning Cursor as Output" Watch "Call Stored Procedure Returning Cursor as Output" New topic

Call Stored Procedure Returning Cursor as Output

carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Hi i am trying to call a stored procedure that returns ref cursor as out parameter but i am getting null pointer Exception suggest me where am i doing wrong

Stored Procedure

My Servlet code Snippet that calls stored procedure is

Error i am getting is

at oracle.jdbc.ttc7.TTCAdapter.newTTCType(TTCAdapter.java:300)
at oracle.jdbc.ttc7.TTCAdapter.createNonPlsqlTTCColumnArray(TTCAdapter.java:270)
at oracle.jdbc.ttc7.TTCAdapter.createNonPlsqlTTCDataSet(TTCAdapter.java:231)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1927)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1119)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2191)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2064)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2989)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:658)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:736)
at postDatedCheque.CallStoredProc.doGet(CallStoredProc.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
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:174)
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:874)
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(Unknown Source)

showing error at stmt.execute().
Victor Lindberg

Joined: Feb 13, 2012
Posts: 5
Look this framework (https://code.google.com/p/lindbergframework/). Easy handling of stored procedures and functions, including treatment of cursors automatically.

Lukas Eder
Ranch Hand

Joined: Jul 22, 2013
Posts: 41

Victor Lindberg wrote:Look this framework [...]

Can you show an example how to solve the OP's problem with your framework?

When Java and SQL work together, great software can evolve. That's why I have created jOOQ. Follow me on blog.jooq.org
Victor Lindberg

Joined: Feb 13, 2012
Posts: 5
Lukas Eder wrote:
Victor Lindberg wrote:Look this framework [...]

Can you show an example how to solve the OP's problem with your framework?

Of course!

First you need to configure. To configure, follow the guide shown here


Classes for example:

Table for example:

Procedures Definition for example:

Procedures Definition in linp-sqlMapping.xml file for example:

DAO for example:

You must configure and initialize the context of the framework. See the user guide for how to do this for web application and which are not.

Any questions, please reports it.

Lukas Eder
Ranch Hand

Joined: Jul 22, 2013
Posts: 41

Victor Lindberg wrote:[...]

But this list of examples only advertises your product. How does it explain the OP's NullPointerException? You mean that the OP wouldn't get that NPE with your framework?
I suspect that the correct answer in this post would indicate a bug in ojdbc, or a subtle misuse of the JDBC API with ojdbc...
jQuery in Action, 2nd edition
subject: Call Stored Procedure Returning Cursor as Output
Similar Threads
Inserting Blob throws Exception
Error while callling stored procedure : Non supported SQL92 token
java.sql.SQLException: ORA-03115: unsupported network datatype or representation
Determine the Callable Statements Parameters at runtime
java.sql.SQLException: ORA-01733: virtual column not allowed here