public final class H2Database extends Object implements DatabaseImpl
Modifier and Type | Field and Description |
---|---|
private Connection |
connection |
private org.h2.jdbcx.JdbcConnectionPool |
connectionPool |
Constructor and Description |
---|
H2Database(String dbName)
Create a new H2 database instance for a given database name.
|
H2Database(String dbName,
boolean deleteDb)
Create a new H2 database instance for a given database name.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the database connection.
|
Connection |
getConnection()
Get a connection to the database.
|
org.jooq.SQLDialect |
getDialect()
Obtain the database dialect e.g.
|
void |
open(String database)
Open the database for connection.
|
private Connection connection
private org.h2.jdbcx.JdbcConnectionPool connectionPool
public H2Database(String dbName)
dbName
- the name of the database to which we will connect.public H2Database(String dbName, boolean deleteDb)
dbName
- the name of the database to which we will connect.deleteDb
- delete the contents of the database once a connection is made.public void open(String database)
DatabaseImpl
open
in interface DatabaseImpl
database
- the name of the database to open/connect.public void close()
DatabaseImpl
close
in interface DatabaseImpl
close
in interface AutoCloseable
public Connection getConnection() throws SQLException
DatabaseImpl
getConnection
in interface DatabaseImpl
SQLException
- if the connection cannot be obtained.public org.jooq.SQLDialect getDialect()
DatabaseImpl
getDialect
in interface DatabaseImpl
Copyright © 2015 University of Glasgow. All rights reserved.