wood burning stoves 2.0*
The moose likes JDBC and the fly likes Error :java.sql.SQLException: Invalid column index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error :java.sql.SQLException: Invalid column index " Watch "Error :java.sql.SQLException: Invalid column index " New topic
Author

Error :java.sql.SQLException: Invalid column index

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202

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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
extremely sorry. i want password to return from proc, so that same can be displayed in front end
Prakash Kumar M
Greenhorn

Joined: Jun 29, 2009
Posts: 18
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.
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
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
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
Can any one suggest some idea on this
krishna bala
Ranch Hand

Joined: Jul 20, 2009
Posts: 59
http://www.oradev.com/ref_cursor.jsp check this link .
Charbel Keyrouz
Ranch Hand

Joined: Jun 10, 2005
Posts: 46
In your case your procedure should return 1 row.

so you should replace this:


with this:
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
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

Joined: Jul 20, 2009
Posts: 59

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error :java.sql.SQLException: Invalid column index
 
Similar Threads
java.sql.SQLException: invalid name pattern
Passing Array as a parameter to Stored procedures
trouble passing array to stored procedure in spring HELP
Calling Oracle Stored Procedure
CallableStatement Error