Menu

#9 DatabaseMetaData.getColumns() not JDBC Spec compliant

open
None
5
2007-01-08
2006-12-31
TomK
No

When retrieving the definition of a table using DatabaseMetaData.getColumns() the ResultSet returned from that call should contain a column "ORDINAL_POSITION".

http://java.sun.com/j2se/1.5.0/docs/api/java/sql/DatabaseMetaData.html#getColumns\(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)

When calling ResultSet.getInt("ORDINAL_POSITION") on the ResultSet returned by the tinySQL JDBC driver, an Exception is thrown:

java.sql.SQLException: Invalid column name: ORDINAL_POSITION
at com.sqlmagic.tinysql.tinySQLResultSet.findColumn(tinySQLResultSet.java:1069)
at com.sqlmagic.tinysql.tinySQLResultSet.getInt(tinySQLResultSet.java:836)

When using index 17 (according to the specs) it throws an exception as well.

Discussion

  • Davis Swan

    Davis Swan - 2007-01-08
    • assigned_to: nobody --> davswa
     
  • Davis Swan

    Davis Swan - 2007-01-08

    Logged In: YES
    user_id=625089
    Originator: NO

    I'm actually surprised that getColumns works at all. I looked at that code over the holidays and concluded it would just throw an exception.

    This is definitely on the list of things to fix, however I don't know when I will get to it. The work around is to do a SELECT * on TABLENAME and use the ResultSetMetaData.

     

Log in to post a comment.