Java JDBC HSQL Connection createHSQLDBConnection(String hsqldbName)

Here you can find the source of createHSQLDBConnection(String hsqldbName)

Description

Establish a database connection to a HSQL database (file system)

License

LGPL

Parameter

Parameter Description
hsqldbName the file path to the HSQL database (file system). See HSQL documentation at http://hsqldb.org/doc/2.0/guide/running-chapt.html

Return

a database connection

Declaration

public static Connection createHSQLDBConnection(String hsqldbName) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.sql.*;

public class Main {
    /**//from w ww  . j  av a  2 s  .  com
     * Establish a database connection to a HSQL database (file system)
     * @param hsqldbName the file path to the HSQL database (file system). See HSQL documentation at http://hsqldb.org/doc/2.0/guide/running-chapt.html
     * @return a database connection
     */
    public static Connection createHSQLDBConnection(String hsqldbName) {
        try {
            Class.forName("org.hsqldb.jdbcDriver");
            Connection conn = DriverManager.getConnection(
                    "jdbc:hsqldb:file:" + hsqldbName, // filenames
                    "sa", // username
                    ""); // pwd
            return conn;
        } catch (Exception e) {
            System.err
                    .println("ERROR SEVERE - Cannot establish database connection to JATR internal database. Please check your "
                            + "claspath to HSQL library, and database path: "
                            + hsqldbName);
            e.printStackTrace();
            System.exit(1);
        }
        return null;
    }
}

Related

  1. createConnection()
  2. createSchemasForHSQLDB(String dbName, String[] schemaNames)
  3. getConnection()
  4. getDbConnection()
  5. createTweetTable()