Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Error :java.sql.SQLException: Invalid column index

 
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have written a procedure in oracle which goes a below




Now I am calling this procedure in java class file



While I execute the proc in sql console i get all the multiple records. Where as i while i try to display it in front end i get the error
Error :java.sql.SQLException: Invalid column index

Please let me know how to retrieve multiple records from proc in java. Am i doing wrong in the above code..please let me know
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eshwar,
What do you want your stored procedure to return? Right now, it looks like it just prints out a bunch of stuff and returns nothing.
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
extremely sorry. i want password to return from proc, so that same can be displayed in front end
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
stored procedure do not return value, however function does that.

So do function needs to be used here instead of proc.

Can anybody please explain how the below problem could be solved.
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting how to return multiple values from procedure. From the below program, when i print (String)cs.getObject(2); i am getting just the first record from the procedure.

Please let me know how to get the multiple results. Also, let me know how to return values from procedure.

Thanks in advance
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one suggest some idea on this
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.oradev.com/ref_cursor.jsp check this link .
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your case your procedure should return 1 row.

so you should replace this:


with this:
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All.

Krishna, the link you provided was really very helpful.

However, small clarification, in the article, the ref cursor package is declared as below.



Where EMP is a table name and declared with attribute ROWTYPE.

I have a requirement where the I need to pull the records from five different tables using joins. In that case should i give any one of the table name in place of EMP in above package

As I am not using all the column values of every individual table, do I need to give attribute ROWTYPE.

Please let me know.



 
krishna bala
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic