problem JSP code following:
<%
... ...
Statement stmt = connection.createStatement();
ResultSet rs =
stmt.executeQuery("select prod_id, weight from product");
String prod_id = "";
float weight = 0;
while (rs.next()){
product_code = rs.getString("product_code");
weight = rs.getFloat("weight");
}
stmt.close();
%>
jsp run error show:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]invalid descriptors index
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataFloat(JdbcOdbc.java:3097)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataFloat(JdbcOdbcResultSet.java:5285)
at sun.jdbc.odbc.JdbcOdbcResultSet.getFloat(JdbcOdbcResultSet.java:648)
... ...
But when i copied the problem code to a Java program, it run ok.
I don't know why and hope to get your comments!
Thanks
Luke
-
Invalid descriptors index (3 messages)
- Posted by: Luke Cai
- Posted on: June 04 2001 03:41 EDT
Threaded Messages (3)
- Invalid descriptors index by Luke Cai on June 04 2001 07:08 EDT
- Invalid descriptors index by Padmanabh Kulkarni on June 04 2001 09:39 EDT
- Thanks by Girish Wakure on March 21 2009 12:00 EDT
- Invalid descriptors index by Padmanabh Kulkarni on June 04 2001 09:39 EDT
-
Invalid descriptors index[ Go to top ]
- Posted by: Luke Cai
- Posted on: June 04 2001 07:08 EDT
- in response to Luke Cai
Accidentally i found the reason.
The order of getParameter must consistent with the select sentence.For example:
strSql = "select prod_id, name from product";
... ...
// OK
String prod_id = rs.getParameter("prod_id");
String name = rs.getParameter("name");
// Wrong
// error "invalid descriptor index" occur when running
String name = rs.getParameter("name");
String prod_id = rs.getParameter("prod_id");
strange!!!
-
Invalid descriptors index[ Go to top ]
- Posted by: Padmanabh Kulkarni
- Posted on: June 04 2001 09:39 EDT
- in response to Luke Cai
This happens when u r trying to access the columns in a different sequence ie. if the column name n the value u r getting is not matching.
Ex:
column names
1:name 2:password 3:type
While retrieving it strictly retrive in the same sequence.
If u r using MS-Access it works but DBs like MS-SQL wont work.
Hope this helps. -
Thanks[ Go to top ]
- Posted by: Girish Wakure
- Posted on: March 21 2009 12:00 EDT
- in response to Padmanabh Kulkarni
Thank you for the solution. It really solved my problem that i have tried for two days. thanks again.