This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

got error: Invalid column index

emma Yao
Posts: 1
  • Mark post as helpful
  • send pies
  • 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; ");


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

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

while ({
[ August 03, 2006: Message edited by: Bear Bibeault ]
Carl Trusiak
Posts: 3341
  • Mark post as helpful
  • send pies
  • 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);
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!