Class DatabaseSetup

java.lang.Object
net.solarnetwork.node.dao.jdbc.DatabaseSetup

public class DatabaseSetup extends Object
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 Details

    • DEFAULT_INIT_SQL_RESOURCE

      public static final String DEFAULT_INIT_SQL_RESOURCE
      The default classpath resource for the initSqlResource property.
      See Also:
    • DEFAULT_SQL_GET_TABLES_VERSION

      public static final String DEFAULT_SQL_GET_TABLES_VERSION
      The default value for the sqlGetTablesVersion property.
      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

      public DataSource getDataSource()
      Returns:
      the dataSource
    • setDataSource

      public void setDataSource(DataSource dataSource)
      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