Megatron
Megatron

Reputation: 17089

Java connection to HSQLDB without server being started

I'm connecting to the HSQLDB server using the following:

private static Connection connectionToServer () throws SQLException {
    try {
        Class.forName("org.hsqldb.jdbcDriver");
    } catch (Exception e) {
        System.out.println("ERROR: failed to load HSQLDB JDBC driver.");
        e.printStackTrace();
    }
    return DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
}

Why does this return a connection that I can use to create tables even if the hsqldb server has not been started at the specified DB_URL with those credentials?

Upvotes: 1

Views: 244

Answers (1)

fredt
fredt

Reputation: 24352

The URL "jdbc:hsqldb:mem:dbtestingname" creates an in-process database in your application's JVM process. This is not a server.

If you want a separate server, you have to start it separately. You then connect to the server with something like: "jdbc:hsqldb:hsql:dbtestserver"

Upvotes: 1

Related Questions