*
The moose likes JDBC and the fly likes SQLException Invalid Descriptor Index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException Invalid Descriptor Index " Watch "SQLException Invalid Descriptor Index " New topic
Author

SQLException Invalid Descriptor Index

salman moin
Greenhorn

Joined: Jan 19, 2001
Posts: 8
highR = reccheck.getFloat("HIGHEST");
Above is my coding accessing a field value, I got an error message "Invalid Descriptor Index".
Can any one help me resolve this error
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Can you provide more of the code body? A description of the table to which the SQL statement is going against and the actual SQL statement would be helpful.
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
After you get the resultset, did you check if it has next?
while(result.next()){
//do you getXXX() here
}
salman moin
Greenhorn

Joined: Jan 19, 2001
Posts: 8
Ok below is the coding:
ResultSet reccheck("SELECT * FROM STK_DETAIL WHERE STK_ID = '" + f2 + "'");
int highR = reccheck.getFloat("HIGHEST");
please also tell me how to resolve the invalid cursor state problem thanx...
salman moin
Greenhorn

Joined: Jan 19, 2001
Posts: 8
Originally posted by Peter Tran:
Can you provide more of the code body? A description of the table to which the SQL statement is going against and the actual SQL statement would be helpful.

Resultset reccheck = statement.executeQuery("SELECT * FROM STK_DETAIL WHERE STK_ID = '" + f2 + "'");
int highR = reccheck.getFloat("HIGHEST");
at the above line i got the problem...
do you have any idea about it?
Anand Joshi
Greenhorn

Joined: Dec 06, 2000
Posts: 12
Please make sure
1. Field 'HIGHEST' exists in table STK_DETAIL
2. There are some records in the in the table STK_DETAIL which matches the selection criteria
Here I found interesting thing in the selection criteria
(STK_ID = '" + f2 + "'")
what is f2 doing?
I think you need to create PreparedStatement and you need to use
setString method to provide values of f2.
I hope it will help.
3. Make sure there are records in the resultset.
Regards


<A HREF="mailto:anandjoshi@india.com" rel="nofollow">anandjoshi@india.com</A>
salman moin
Greenhorn

Joined: Jan 19, 2001
Posts: 8
Hi Anand
f2 is a string type variable which i have checked that contain the right value.
HIGHEST exist in table STK_DETAIL
There are few records in the table and one thing I forgot to tell that my application is running well with MS Access 2000.
This error only occurs when I connect to SQL Server.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
You need to do a reccheck.next() after the executeQuery(). Until you do a next(), you are not pointing to any rows in the table.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
titojermaine
Greenhorn

Joined: May 21, 2001
Posts: 2
I'm having a very similar problem as this. I am attaching to SQL-Server 7.0 and getting a similar error when I attempt to retreive columns of a numerical data type (tinyint, smallint, int, etc.). I am able to retreive columns of the varchar data type without a problem, even in the same recordset, on the same record. I'm also using string concatentation within the SQL queries (this is a temporary fix until I have a chance to write stored procedures, which may contribute to solving or intensifying the current issue...) throughout the application without any problems elsewhere, so I do not believe that is the issue. If I find a solution to the issue I'm having, I will post it. For now, the only other suggestion I could offer is to use System.out.println to dump out your query to the screen after the string concatenation has occurred. Copy and paste it into MS-SQL Query Analyzer, and be sure the query itself is not the cause of the issue (it's likely not to be at this point, but it's worth a try).
titojermaine
Greenhorn

Joined: May 21, 2001
Posts: 2
After a little more research on the web, I was able to solve my issue, but the solution may apply to this issue as well. It seems that we're gonna have to thank the good people of Microshaft for this one. Basically, suppose you have a query like the one listed here:
SELECT col1, col2, col3
FROM table
The exception occurs when you try to access the columns out of the order that they were queried in. That means that if you use one of the get...() functions to retrieve each column, you have to be careful the order you retrieve them in. If you get col2 first, you cannot get col1 any longer, but if you get col1 before you get col2, it will be fine. Basically, just check the order that you are getting the columns in, and make sure that order matches the order in the query.
However, in the example given in this thread, it is selecting * (which might make the ordering confusing, but it's the ordering of the columns in the table at this point), and only one column has been obtained at the time of the exception, so perhaps the solution I suggested here may not be a straightforward solution, but hopefully it'll give you some new ideas.
Charlie Boss
Ranch Hand

Joined: May 22, 2001
Posts: 44
its 11:57pm here.. i'm still at work yes.. i've been working on this same problem since 8 this morning.. i can't tell u how much i'm grateful.. thank you.. thank you.. whew..


Java Rawks
Jaha Cush
Greenhorn

Joined: Jun 12, 2001
Posts: 1
Thank you for the help. I have been working on this for 5 hours and I could not figure it out. You are the greatest.
Regards,
Jaha
Originally posted by titojermaine:
After a little more research on the web, I was able to solve my issue, but the solution may apply to this issue as well. It seems that we're gonna have to thank the good people of Microshaft for this one. Basically, suppose you have a query like the one listed here:
SELECT col1, col2, col3
FROM table
The exception occurs when you try to access the columns out of the order that they were queried in. That means that if you use one of the get...() functions to retrieve each column, you have to be careful the order you retrieve them in. If you get col2 first, you cannot get col1 any longer, but if you get col1 before you get col2, it will be fine. Basically, just check the order that you are getting the columns in, and make sure that order matches the order in the query.
However, in the example given in this thread, it is selecting * (which might make the ordering confusing, but it's the ordering of the columns in the table at this point), and only one column has been obtained at the time of the exception, so perhaps the solution I suggested here may not be a straightforward solution, but hopefully it'll give you some new ideas.

David Grant
Greenhorn

Joined: Aug 15, 2001
Posts: 2
Tito, thanks a lot. I had only been working on this problem for about 3 minutes but your information was enough to fix it. Thanks again-
david
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException Invalid Descriptor Index
 
Similar Threads
Help Needed For JSP code
[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
SQLException: Invalid Descriptor Index?
SQL Exception :Invalid descriptor index,Help
Invalid Descriptor Index