• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

procedure call

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
}
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our JDBC forum.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


What does this code do?

Also what does the stored procedure do? Does it return a single result set?
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic