Bugs in the Databasemetadata for in-memory HSQLDB? - JDBC JAVA

This is a discussion on Bugs in the Databasemetadata for in-memory HSQLDB? - JDBC JAVA ; as specified in the JDBC MEtadata getTables and getColumns /doc/src/org/hsqldb/jdbc/jdbcDatabaseMetaData.html ... 3. TABLE_NAME String => table name ... should give you the TABLE_NAME for a given database. However the code snipped does not: // - - - - - - ...

+ Reply to Thread
Results 1 to 2 of 2

Bugs in the Databasemetadata for in-memory HSQLDB?

  1. Default Bugs in the Databasemetadata for in-memory HSQLDB?



    as specified in the JDBC MEtadata getTables and getColumns

    /doc/src/org/hsqldb/jdbc/jdbcDatabaseMetaData.html

    ...
    3. TABLE_NAME String => table name
    ...

    should give you the TABLE_NAME for a given database.

    However the code snipped does not:

    // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    import java.io.*;
    import java.util.*;
    import java.sql.*;

    // __
    public class testCols02{
    public static void main(String[] aArgs){
    String aDrvr = "org.hsqldb.jdbcDriver";
    String aDBURL = "jdbc:hsqldb:mem:";
    String aTblsDB = ".";
    String aUser = "sa";
    String aPW = "";
    // __
    try{ Class.forName(aDrvr).newInstance(); }
    catch(ClassNotFoundException KNFX){ KNFX.printStackTrace(); }
    catch(InstantiationException InstX){ InstX.printStackTrace(); }
    catch(IllegalAccessException IlgAxX){ IlgAxX.printStackTrace(); }
    // __
    Connection _DBCx = null;
    Statement St = null;
    DatabaseMetaData DBMD = null;
    String aSQL = null;
    String[] aTyps = new String[]{"TABLE"};
    String aRSTblNm = null;
    ResultSet RSTbls = null;
    ResultSet RSCols = null;
    int iTbls;
    int iCols;
    // __ Creating the in-memory DB
    try{
    _DBCx = DriverManager.getConnection(aDBURL + aTblsDB, aUser, aPW);
    St = _DBCx.createStatement();

    System.out.println("// __ _DBCx: |" + _DBCx + "|");
    System.out.println("// __ St: |" + St + "|");

    aSQL = "CREATE TABLE tbl00AA467E (fld00 CHAR(16), fld02 VARCHAR(255), fld04 INT NOT NULL, fld06 REAL);";
    System.out.println(" aSQL=" + aSQL);
    St.executeUpdate(aSQL);
    // __
    St.close(); St = null;
    // __
    DBMD = _DBCx.getMetaData();
    RSTbls = DBMD.getTables(aTblsDB, null, "%", aTyps);
    // __
    System.out.println("// __ _DBCx: |" + _DBCx + "|");
    System.out.println("// __ DBMD: |" + DBMD + "|");
    System.out.println("// __ RSTbls: |" + RSTbls + "|");
    // __
    iTbls = 0;
    while(RSTbls.next()){
    aRSTblNm = RSTbls.getString(3);
    System.out.println(iTbls + " |" + aRSTblNm + "|");
    ++iTbls;
    }
    RSTbls.close(); RSTbls = null;
    System.out.println(" iTbls: |" + iTbls + "|");
    // __
    }catch(SQLException SQLX){ SQLX.printStackTrace(); }
    // __
    finally{
    if(St != null){ try{ St.close(); }catch(SQLException SQLX){ ; } St = null; }
    if(_DBCx != null){ try{ _DBCx.close(); }catch(SQLException SQLX){ ; } _DBCx = null; }
    }// finally
    }
    }
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    I have tested this code with different DBMS and it works fine except for in-memory hsqldb

    Any examples of how to get the tables and their column names of an in-memory hsqldb?





  2. Default Re: Bugs in the Databasemetadata for in-memory HSQLDB?

    You need to call getTables with a null first argument:

    RSTbls = DBMD.getTables(null, null, "%", aTyps);

    Fred

    "Albretch" <lbrtchx@hotmail.com> wrote in message
    news:14831146.1107866256992.JavaMail.X@x-0yc08mu0lvpns...
    >
    >
    > as specified in the JDBC MEtadata getTables and getColumns
    >
    > /doc/src/org/hsqldb/jdbc/jdbcDatabaseMetaData.html
    >
    > ..
    > 3. TABLE_NAME String => table name
    > ..
    >
    > should give you the TABLE_NAME for a given database.
    >
    > However the code snipped does not:
    >
    > // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    > import java.io.*;
    > import java.util.*;
    > import java.sql.*;
    >
    > // __
    > public class testCols02{
    > public static void main(String[] aArgs){
    > String aDrvr = "org.hsqldb.jdbcDriver";
    > String aDBURL = "jdbc:hsqldb:mem:";
    > String aTblsDB = ".";
    > String aUser = "sa";
    > String aPW = "";
    > // __
    > try{ Class.forName(aDrvr).newInstance(); }
    > catch(ClassNotFoundException KNFX){ KNFX.printStackTrace(); }
    > catch(InstantiationException InstX){ InstX.printStackTrace(); }
    > catch(IllegalAccessException IlgAxX){ IlgAxX.printStackTrace(); }
    > // __
    > Connection _DBCx = null;
    > Statement St = null;
    > DatabaseMetaData DBMD = null;
    > String aSQL = null;
    > String[] aTyps = new String[]{"TABLE"};
    > String aRSTblNm = null;
    > ResultSet RSTbls = null;
    > ResultSet RSCols = null;
    > int iTbls;
    > int iCols;
    > // __ Creating the in-memory DB
    > try{
    > _DBCx = DriverManager.getConnection(aDBURL + aTblsDB, aUser, aPW);
    > St = _DBCx.createStatement();
    >
    > System.out.println("// __ _DBCx: |" + _DBCx + "|");
    > System.out.println("// __ St: |" + St + "|");
    >
    > aSQL = "CREATE TABLE tbl00AA467E (fld00 CHAR(16), fld02 VARCHAR(255),
    > fld04 INT NOT NULL, fld06 REAL);";
    > System.out.println(" aSQL=" + aSQL);
    > St.executeUpdate(aSQL);
    > // __
    > St.close(); St = null;
    > // __
    > DBMD = _DBCx.getMetaData();
    > RSTbls = DBMD.getTables(aTblsDB, null, "%", aTyps);
    > // __
    > System.out.println("// __ _DBCx: |" + _DBCx + "|");
    > System.out.println("// __ DBMD: |" + DBMD + "|");
    > System.out.println("// __ RSTbls: |" + RSTbls + "|");
    > // __
    > iTbls = 0;
    > while(RSTbls.next()){
    > aRSTblNm = RSTbls.getString(3);
    > System.out.println(iTbls + " |" + aRSTblNm + "|");
    > ++iTbls;
    > }
    > RSTbls.close(); RSTbls = null;
    > System.out.println(" iTbls: |" + iTbls + "|");
    > // __
    > }catch(SQLException SQLX){ SQLX.printStackTrace(); }
    > // __
    > finally{
    > if(St != null){ try{ St.close(); }catch(SQLException SQLX){ ; } St =
    > null; }
    > if(_DBCx != null){ try{ _DBCx.close(); }catch(SQLException SQLX){ ; }
    > _DBCx = null; }
    > }// finally
    > }
    > }
    > // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    >
    > I have tested this code with different DBMS and it works fine except for
    > in-memory hsqldb
    >
    > Any examples of how to get the tables and their column names of an
    > in-memory hsqldb?
    >
    >
    >
    >




+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 08-27-2007, 06:38 PM
  2. HSQLDB Memory Limit Running with CACHED Tables
    By Application Development in forum JDBC JAVA
    Replies: 0
    Last Post: 03-20-2007, 05:34 PM
  3. SQl exception for using getPrimaryKeys() of DatabaseMetaData
    By Application Development in forum JDBC JAVA
    Replies: 1
    Last Post: 04-06-2006, 03:50 AM
  4. Any examples of using DatabaseMetaData?
    By Application Development in forum JDBC JAVA
    Replies: 1
    Last Post: 12-19-2005, 05:58 AM
  5. finding CHECK constraint with DatabaseMetaData
    By Application Development in forum JDBC JAVA
    Replies: 1
    Last Post: 09-26-2005, 03:22 PM