Class H2ConnectionFactory
- All Implemented Interfaces:
ConnectionFactory
ConnectionFactory for creating connections to an H2 database.-
Constructor Summary
ConstructorsConstructorDescriptionH2ConnectionFactory(H2ConnectionConfiguration configuration) Creates a new connection factory. -
Method Summary
Modifier and TypeMethodDescriptioncreate()static CloseableConnectionFactoryCreate a newIn-Memory database connection factoryfor database atname.static CloseableConnectionFactoryinMemory(String name, String username, CharSequence password) Create a newIn-Memory database connection factoryfor database atnamegivenusernameandpassword.static CloseableConnectionFactoryinMemory(String name, String username, CharSequence password, Map<H2ConnectionOption, String> properties) Create a newIn-Memory database connection factoryfor database atnamegivenusernameandpassword.toString()
-
Constructor Details
-
H2ConnectionFactory
Creates a new connection factory.- Parameters:
configuration- the configuration to use to create connections- Throws:
NullPointerException- ifconfigurationisnull
-
-
Method Details
-
inMemory
Create a newIn-Memory database connection factoryfor database atname.The closeable
ConnectionFactorykeeps the database open unless the connection factory isclosed.The database gets created if it does not exist yet.
Connecting to an existing database closes the database for all participating components if the resulting
ConnectionFactoryisclosed.- Parameters:
name- database name- Returns:
- connection factory for database at
name
-
inMemory
public static CloseableConnectionFactory inMemory(String name, String username, CharSequence password) Create a newIn-Memory database connection factoryfor database atnamegivenusernameandpassword.The closeable
ConnectionFactorykeeps the database open unless the connection factory isclosed.The database gets created if it does not exist yet.
Connecting to an existing database closes the database for all participating components if the resulting
ConnectionFactoryisclosed.- Parameters:
name- database nameusername- the usernamepassword- the password to use- Returns:
- connection factory for database at
name.
-
inMemory
public static CloseableConnectionFactory inMemory(String name, String username, CharSequence password, Map<H2ConnectionOption, String> properties) Create a newIn-Memory database connection factoryfor database atnamegivenusernameandpassword.The closeable
ConnectionFactorykeeps the database open unless the connection factory isclosed.Connecting to an existing database closes the database for all participating components if the resulting
ConnectionFactoryisclosed.- Parameters:
name- database nameusername- the usernamepassword- the password to useproperties- properties to set- Returns:
- connection factory for database at
name. - See Also:
-
create
- Specified by:
createin interfaceConnectionFactory
-
getMetadata
- Specified by:
getMetadatain interfaceConnectionFactory
-
toString
-