• 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

java and jdbc

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to execute a stored procedure in a database using the prepareCall method. This is how I use it to call a procedure passing two paramters.
connect.prepareCall("call procedure[(?,?)]}");
How do I change this if my procedure does not pass in any parameters but returns two parameters. I want to also go through a loop and assign what is returned to variables. THe first thing returned is a string, and the second argument returned is a float. Thank you.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd probably get better response in the JDBC forum. I'm moving this there.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no change. The only change is to declare the out parameters of the stored procedure ( different than return vals, but since you can only return one value, I assume you meant out parameters )
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you
 
Chanpreet Julka
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the error I am getting
java.sql.SQLException: JZ0SA: Prepared Statement: Input parameter not set, ind
ex: 2.
And here is the code..
CallableStatement cstmt = con.prepareCall("{ ? = call RET_ANT_NAME_UP_BY_MAX_VERSION[(?,?)]}");
cstmt.registerOutParameter ( 1, java.sql.Types.VARCHAR );
cstmt.registerOutParameter ( 2, java.sql.Types.FLOAT );
cstmt.execute();
String outParam1 = cstmt.getString( 1 );
float outParam2 = cstmt.getFloat( 2 );
I want to return two arguments from the stored procedure, and do not want to pass any inputs in to the procedure as parameters. Help please? Thanks
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your error is that you have 3 ?'s in your prepareCall method, but you only define( register ) 2 of them. you probably want this:

this should work ( only 2 parameters ).
Jamie
 
reply
    Bookmark Topic Watch Topic
  • New Topic