loading HSQL in-memory from different JVM processes

From: Albretch (lbrtchx_at_hotmail.com)
Date: 02/08/05

  • Next message: David Harper: "Re: linked server referred by insert trigger"
    Date: Tue, 8 Feb 2005 07:36:45 -0500 (EST)
    
    

     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?


  • Next message: David Harper: "Re: linked server referred by insert trigger"

    Relevant Pages

    • Bugs in the Databasemetadata for in-memory HSQLDB?
      ... TABLE_NAME String => table name ... should give you the TABLE_NAME for a given database. ... System.out.println(" aSQL=" + aSQL); ... I have tested this code with different DBMS and it works fine except for in-memory hsqldb ...
      (comp.lang.java.programmer)
    • loading HSQL in-memory from different JVM processes
      ... TABLE_NAME String => table name ... should give you the TABLE_NAME for a given database. ... System.out.println(" aSQL=" + aSQL); ... I have tested this code with different DBMS and it works fine except for in-memory hsqldb ...
      (comp.lang.java.programmer)
    • Re: A little Rolodex [revised]
      ... including alpha sort and searching for any embedded string, ... In this application, a database is a directory, ... you may optionally provide any alternate UCASE program, ... NN -> first store NN as key length ...
      (comp.sys.hp48)
    • Re: return multiple rows from sql statement
      ... strings from input values is almost certainly a safe path to SQL ... Also, being a MySQL function, it knows what MySQL needs or uses. ... All characters that are entered in the fields make their way into the database unaltered. ... The insert of what surprisinlgly was NOT a syntax error, but a string called "mysql_insert_id" into an integer field resulted in the value zero being put in. ...
      (comp.lang.php)
    • Re: Code to delete/unlink Linked tables
      ... Public intLinkODBCTables As Variant, intLinkDB2Tables As Variant ... Public strLinkBackendDB As String, strLinkDSNname As String, strLinkLibName ... ' MsgBox "This database is in MDE format...I will delete/recreate ODBC ... Public Sub fncLinkDB2Table() ...
      (microsoft.public.access.modulesdaovba)