File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes procedure call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "procedure call " Watch "procedure call " New topic
Author

procedure call

Tmmet Johnson
Ranch Hand

Joined: Nov 03, 2004
Posts: 56
Hi,
Can anyone help me out?
I am getting error - Invalid cursor state. SQLSTATE=24000 when i run the below code.
It is faling when the shile loop is called.
Any ideas/suggesstions to resolve the issue would be very helpful for me.

final String procedure = "CALL db2test.testdata(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
stmt = conn.prepareCall(procedure);
stmt.setShort(1, 1);
stmt.setString(2, "1234567890");
stmt.setString(3, "12345"));
stmt.registerOutParameter(4, Types.CHAR);
stmt.registerOutParameter(5, Types.INTEGER);
stmt.registerOutParameter(6, Types.CHAR);
stmt.registerOutParameter(7, Types.CHAR);
stmt.registerOutParameter(8, Types.CHAR);
stmt.registerOutParameter(9, Types.CHAR);
stmt.registerOutParameter(10,Types.CHAR);
stmt.registerOutParameter(11, Types.CHAR);
stmt.registerOutParameter(12, Types.CHAR);
stmt.registerOutParameter(13, Types.CHAR);
stmt.registerOutParameter(14, Types.CHAR);
stmt.registerOutParameter(15, Types.CHAR);
stmt.registerOutParameter(16, Types.CHAR);
stmt.registerOutParameter(17, Types.CHAR);

ResultSet rs = stmt.executeQuery();
output.setData(stmt.getString(4));
output.setData1(new Integer(stmt.getInt(5)).toString());
output.setData2(stmt.getString(6));
output.setDaat3(stmt.getString(7));
output.setData4(stmt.getString(8));
output.setData5(stmt.getString(9));
output.setData5(stmt.getString(10));
output.setData6(stmt.getString(11));
output.setData7(stmt.getString(12));
output.setDaat8(stmt.getString(13));
output.setData9(stmt.getString(14));
output.setData10(stmt.getString(15));
output.setData11(stmt.getString(16));
output.setData12(stmt.getString(17));
while(rs.next())
{
short code = rs.getShort(1);
String id = rs.getString(2);
System.out.println("ID is : "+ i);l
}
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Moving to our JDBC forum.


[Jess in Action][AskingGoodQuestions]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

output.setData(stmt.getString(4));

What does this code do?

Also what does the stored procedure do? Does it return a single result set?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Consider Paul's rocket mass heater.
 
subject: procedure call