Package net.solarnetwork.node.dao.jdbc
Class DatabaseSetup
java.lang.Object
net.solarnetwork.node.dao.jdbc.DatabaseSetup
Class to initialize a database for first-time use by a Solar Node.
The init() method should be called once during
application startup, before any other JDBC-based DAOs attempt to initialize
or access the database.
The configurable properties of this class are:
- dataSource
- The DataSource to use for accessing the database with.
- initSqlResource
- A Resource to a SQL script that will initialize the database for the
first time, when it is not found to exist already. Defaults to a
classpath-relative resource named
DEFAULT_INIT_SQL_RESOURCE.
- Version:
- 2.0
- Author:
- matt
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.core.io.Resourcevoidinit()Check for the existence of the database, and if not found create and initialize it.voidsetDataSource(DataSource dataSource) voidsetInitSqlResource(org.springframework.core.io.Resource initSqlResource)
-
Field Details
-
DEFAULT_INIT_SQL_RESOURCE
The default classpath resource for theinitSqlResourceproperty.- See Also:
-
DEFAULT_SQL_GET_TABLES_VERSION
The default value for thesqlGetTablesVersionproperty.- See Also:
-
-
Constructor Details
-
DatabaseSetup
public DatabaseSetup()
-
-
Method Details
-
init
public void init()Check for the existence of the database, and if not found create and initialize it. -
getDataSource
- Returns:
- the dataSource
-
setDataSource
- Parameters:
dataSource- the dataSource to set
-
getInitSqlResource
public org.springframework.core.io.Resource getInitSqlResource()- Returns:
- the initSqlResource
-
setInitSqlResource
public void setInitSqlResource(org.springframework.core.io.Resource initSqlResource) - Parameters:
initSqlResource- the initSqlResource to set
-