It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes SQL invalid column index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL invalid column index" Watch "SQL invalid column index" New topic

SQL invalid column index

Aabha Varma

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

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

Joined: Jul 08, 2003
Posts: 24199

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

Joined: Jan 10, 2002
Posts: 63852

"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.

Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
Aabha Varma

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.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33106

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61

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:
subject: SQL invalid column index
It's not a secret anymore!