java.lang.Object
is.codion.dbms.h2.H2DatabaseFactory
- All Implemented Interfaces:
DatabaseFactory
Provides h2 database implementations
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Database
createDatabase
(String url, String... initScripts) Creates a H2 Database instanceboolean
driverCompatible
(String driverClassName) static void
Runs the given script using the RunScript tool, with the default sysadmin username (sa) and default charsetstatic void
runScript
(Database database, String scriptPath, String username, String password, Charset scriptCharset) Runs the given script using the RunScript tool
-
Constructor Details
-
H2DatabaseFactory
public H2DatabaseFactory()
-
-
Method Details
-
driverCompatible
- Specified by:
driverCompatible
in interfaceDatabaseFactory
- Parameters:
driverClassName
- the driver class name- Returns:
- true if this database factory is compatible with the given driver
-
create
- Specified by:
create
in interfaceDatabaseFactory
- Parameters:
url
- the jdbc url- Returns:
- a new
Database
implementation based on the given jdbc url.
-
createDatabase
Creates a H2 Database instance- Parameters:
url
- the jdbc urlinitScripts
- initialization scripts to run on database creation- Returns:
- a H2 Database instance
-
runScript
Runs the given script using the RunScript tool, with the default sysadmin username (sa) and default charset- Parameters:
database
- the databasescriptPath
- the path to the script- Throws:
SQLException
- in case of an exception
-
runScript
public static void runScript(Database database, String scriptPath, String username, String password, Charset scriptCharset) throws SQLException Runs the given script using the RunScript tool- Parameters:
database
- the databasescriptPath
- the path to the scriptusername
- the username to run the script underpassword
- the passwordscriptCharset
- the script character set- Throws:
SQLException
- in case of an exception
-