aspose file tools
The moose likes Java in General and the fly likes Call a stored procedure via JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Call a stored procedure via JDBC" Watch "Call a stored procedure via JDBC" New topic

Call a stored procedure via JDBC

Bechir Bejaoui

Joined: Feb 06, 2013
Posts: 7
Hi folks

I need to call a stored procedure from within the java code, I encountred the following error
ORA-00900: invalid SQL statement

I created a procedure that works perfectly I tested it in TOAD

This above procedure executes perfecty under toad

IT gives me res = 50 under toad

Now here is the code in java

This code gives me error exactly at this line

So how to fix that

Thank you

amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 535
It seems you are not registering the out parameter.
Please check the javadocs and modify the code accordingly and it should work then.

Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 224

String s="{call getTestData(?, ?)}"; //you have not used "call" to call procedure..

and OUT should be registered as amit said.
refer to this link Callable Statement

It is sorta covered in the JavaRanch Style Guide.
subject: Call a stored procedure via JDBC