Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

got error: Invalid column index

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I tried to call a procedure which returns a cursor (the 5th param, refcursor type in oracle9i), I got an error(java.sql.SQLException: Invalid column index) when the execution went to line 'rs = (ResultSet)st.getObject(1);'. When I tested and execute the same procedure in SQLplus, I could get a result back (returns one record with 3 columns)Any suggestion and help will be greatly appreciated!

--------------------------------------------------
CallableStatement st = null;
ResultSet rs = null;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection db_conn = java.sql.DriverManager.getConnection ("");
st = db_conn.prepareCall("BEGIN packName.GETVENDORLIST(?,?,?,?,?); END; ");

st.setString(1,"1603DR");
st.setString(2,"06");
st.setString(3,"4160");
st.setString(4,"LA");
st.registerOutParameter(5,OracleTypes.CURSOR);

st.execute();
System.out.println("success execute");

rs = (ResultSet)st.getObject(1);

while (rs.next()){
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}
[ August 03, 2006: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have registered 5 as the out parameter but, are getting parameter 1 after the call.

Change that to rs = (ResultSet)st.getObject(5);
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic