File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Stored Procedure Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Stored Procedure Error" Watch "Stored Procedure Error" New topic

Stored Procedure Error

Pavan Kumar

Joined: Jan 13, 2002
Posts: 8
Hi Have written follwoing code to call stored procedure. But I am getting error general SQL error.
here is the code.
public void connectGeneva(){

String url = "jdbc dbc:GENSYS";

Connection con;

try {
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
con = DriverManager.getConnection(url,"geneva_admin", "geneva");
System.out.println ("Connected Geneva .............");
Statement stmt = con.createStatement();

CallableStatement cs = con.prepareCall("{call GNVCUST.GETBILLINGDETAILS(?, ?, ?, ?, ?, ?) }");

cs.registerOutParameter(3, java.sql.Types.INTEGER);
String CUSTOMERNAME = cs.getString(2);
int BILLPERIOD = cs.getInt(3);
System.out.println ("CUSTOMERNAME ............." + CUSTOMERNAME);
System.out.println ("BILLPERIOD ............." + BILLPERIOD);
}catch(SQLException ex) {
System.err.print("SQLException: ");


pavan kuamr
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
In your "prepareCall" you have a procedure call with six parameters. You then set one value (#1) and register another as an output parameter (#3). What about the other four parameters? If they are input parameters, you need to call a "setXXX()" method for them. If they are output parmeters you need to call "registerOutParmeter()" for them.
I notice that after the procedure call you are doing "cs.getString(2)", which indicates that parameter #2 is an output parameter, so you must call "registerOutParameter()" before doing the "cs.execute()". If parameters 4-6 are output parameters you need to call "registerOutParameter()" on them even if you don't plan on using the results. If they are input parameters, you need to set appropriate values first.
If doing this doesn't solve your problem, please post the exact error message with a traceback.
[ October 23, 2003: Message edited by: Wayne L Johnson ]
I agree. Here's the link:
subject: Stored Procedure Error
jQuery in Action, 3rd edition