Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Unanswered: JDBC with Oracle: error with getInt(String) and metadata

    Hello,

    I have a problem with the methods ResultSet.getXXX(String). I always get an "Invalid column name" exception. Here is an example :

    DataSource ds = (DataSource) new InitialContext().lookup("jdbc/SilexDS");

    conn = ds.getConnection();
    PreparedStatement ps =
    conn.prepareStatement("select IVDR from VDRS_INCIDENTS");

    ResultSet rs = ps.executeQuery();
    ResultSetMetaData rsmd = rs.getMetaData();

    if (rs.next()) {
    // print metadata
    for (int i = 1; i <= rsmd.getColumnCount(); i++) {
    System.err.println("#DEBUG: i = " + i + " column = " + rsmd.getColumnName(i) + " label = " + rsmd.getColumnLabel(i) + " type = " + rsmd.getColumnTypeName(i));
    }

    // print data
    System.err.println("#DEBUG: rs.getInt(int) --> " + rs.getInt(1));
    System.err.println("#DEBUG: rs.getInt(String) --> " + rs.getInt("IVDR")); // here is the exception
    } else {
    System.err.println("#DEBUG: NO DATA FOUND");
    }


    and here is what I get:

    #DEBUG: i = 1 column = label = type = NUMBER
    #DEBUG: rs.getInt(int) --> 37178
    java.sql.SQLException: Invalid column name
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:269)
    at oracle.jdbc.driver.OracleStatement.get_column_inde x(OracleStatement.java:6221)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn( OracleResultSetImpl.java:1557)
    at oracle.jdbc.driver.OracleResultSet.getInt(OracleRe sultSet.java:1528)
    at com.ibm.ejs.cm.proxy.ResultSetProxy.getInt(ResultS etProxy.java:744)
    at com.airfrance.silex.servlet.MainTest.doGet(MainTes t.java:64)


    Obviously, the metadata has not been filled, and the name of the column is right but it doesn't work.

    This code executed on another computer similar to mine works fine. I dont have any clue of what could be the problem with my computer.

    Does someone have an idea or have exprienced something similar ?

    Thanks.
    Last edited by ChrisThal; 08-10-04 at 04:03.

  2. #2
    Join Date
    Apr 2002
    Posts
    56
    I guess this belongs in the SQL Server forum.

  3. #3
    Join Date
    Apr 2002
    Posts
    56
    Sorry, I spoke too soon. I reacted on getINT, which I do not recognize as an Oracle function.

  4. #4
    Join Date
    Aug 2004
    Posts
    2
    I found my problem. It was an old version of Oracle drivers (classes12.zip) hidden in my Websphere classpath.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •