aspose file tools
The moose likes JDBC and the fly likes SQL invalid column index Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "SQL invalid column index" Watch "SQL invalid column index" New topic
Author

SQL invalid column index

Aabha Varma
Greenhorn

Joined: Jan 12, 2005
Posts: 22
I have written a procedure that returns me Ref cursor.
the object that i am returning is a table of records that have two columns. Both the record and the table is created permanently in db.

I am calling the procedure from java.
The procedure when run separately, gives me two rows with value.

Now when i take a result set of the cursor, and if i give rs.getInt(column name) it gives me an invalid column index.

But the resultset meta data gives me the information that there are two columns.
So now i am stuck as where to debug.

Can anybody help me out

Thanks in advance
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Aabha ,
Check Whether the sql Query returning the ResultSet has the column name mentioned in "rs.getInt(column name)". Also check if you are using alises like "e.EmpName" in that case you can rewrite the query like
Select e.EmpName EmpName from Emp e

Note : I guess it's not the right place to post this question. If you have posted it at right place you 'll get more responses from the ranchers.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Aabha Varma
Greenhorn

Joined: Jan 12, 2005
Posts: 22
But I am calling a procedure which returns me a REF cursor.

Thanks for telling me the place to put the query.
I have posted the same in jdbc forum
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Even while returning a Ref Cursor. You need to have some SQL that creates the Ref cursor in the stored procedure. Check that out.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

Don't know why this is in the Swing forum; it clearly belongs in JDBC. I'll move it there for you.


[Jess in Action][AskingGoodQuestions]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56200
    
  13

"Aabha MMT",

Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place, and wastes the bartender's time having to close and move posts around.

Additionally, please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Aabha Varma
Greenhorn

Joined: Jan 12, 2005
Posts: 22
Regarding naming convention..
Its my real name and MMT is my initial.

Posting the same querry twice. It was a mistake. but somebody pointed it out that there is a better place to put up such query. And thats the reason why its there in second place.

Rgds,
Aabha
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26192
    
  66

Aabha,
No problem. In the future, you can just ask a bartender/sherriff to move the post for you without having to create a copy.

I don't think Bear was questioning whether Aabha was your real first name. It was probably the lack of vowels in the last name "MMT". We prefer you use a last name, not just initials.


[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
Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61
hi,

during retrieval, you can retrive the data in the same order as you have selected.

for example, if your query reads "select a,b,c from xyz" retrieve the values in the same order as a, then b, and finally c.

this has worked for me.

all the best...


cheers,<br />Anandh
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: SQL invalid column index
 
Similar Threads
java swings
Runtime Creating Tables
Stored Procedure in DB2
Invalid column index
How to map returned cursor to a POJO / Bean in Hibernate?