Invalid descriptors index


Web tier: servlets, JSP, Web frameworks: Invalid descriptors index

  1. Invalid descriptors index (3 messages)

    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 ({
      product_code = rs.getString("product_code");
      weight = rs.getFloat("weight");
    jsp run error show:
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]invalid descriptors index
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(
    at sun.jdbc.odbc.JdbcOdbc.standardError(
    at sun.jdbc.odbc.JdbcOdbc.SQLGetDataFloat(
    at sun.jdbc.odbc.JdbcOdbcResultSet.getDataFloat(
    at sun.jdbc.odbc.JdbcOdbcResultSet.getFloat(
    ... ...
    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!


    Threaded Messages (3)

  2. Invalid descriptors index[ Go to top ]

    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");


  3. Invalid descriptors index[ Go to top ]

    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.
    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.
  4. Thanks[ Go to top ]

    Thank you for the solution. It really solved my problem that i have tried for two days. thanks again.