Class Database

  • All Implemented Interfaces:
    DatabaseIfc

    public class Database
    extends java.lang.Object
    implements DatabaseIfc
    A concrete implementation of the DatabaseIfc interface.

    Many databases define the terms database, user, schema in a variety of ways. This abstraction defines this concept as the userSchema. It is the name of the organizational construct for which the user defined database objects are contained. These are not the system abstractions. The database label provided to the construct is for labeling and may or may not have any relationship to the actual file name or database name of the database. The supplied DataSource has all the information that it needs to access the database.

    • Constructor Detail

      • Database

        public Database​(java.lang.String dbLabel,
                        javax.sql.DataSource dataSource)
        Create a Database. The SQLDialect is guessed based on establishing a connection with the supplied DataSource. If the dialect cannot be guessed then an exception will occur. This can be checked prior to the call by using: Reference to JDBCUtils
        Parameters:
        dbLabel - a string representing a label for the database must not be null. This label may or may not have any relation to the actual name of the database. This is used for labeling purposes.
        dataSource - the DataSource backing the database, must not be null
      • Database

        public Database​(java.lang.String dbLabel,
                        javax.sql.DataSource dataSource,
                        org.jooq.SQLDialect dialect)
        Parameters:
        dbLabel - a string representing a label for the database must not be null. This label may or may not have any relation to the actual name of the database. This is used for labeling purposes.
        dataSource - the DataSource backing the database, must not be null
        dialect - the SLQ dialect for this type of database. It obviously must be consistent with the database referenced by the connection
      • Database

        public Database​(java.lang.String dbLabel,
                        javax.sql.DataSource dataSource,
                        org.jooq.SQLDialect dialect,
                        org.jooq.conf.Settings settings)
        Parameters:
        dbLabel - a string representing a label for the database must not be null. This label may or may not have any relation to the actual name of the database. This is used for labeling purposes.
        dataSource - the DataSource backing the database, must not be null
        dialect - the SLQ dialect for this type of database. It obviously must be consistent with the database referenced by the connection
        settings - the JOOQ settings for the database context, may be null
    • Method Detail

      • getDataSource

        public final javax.sql.DataSource getDataSource()
        Specified by:
        getDataSource in interface DatabaseIfc
        Returns:
        the DataSource backing the database
      • getLabel

        public final java.lang.String getLabel()
        Specified by:
        getLabel in interface DatabaseIfc
        Returns:
        an identifying string representing the database. This has no relation to the name of the database on disk or in the dbms. The sole purpose is for labeling of output
      • getSQLDialect

        public final org.jooq.SQLDialect getSQLDialect()
        Specified by:
        getSQLDialect in interface DatabaseIfc
        Returns:
        the jooq SQL dialect for the database
      • getDSLContext

        public org.jooq.DSLContext getDSLContext()
        Specified by:
        getDSLContext in interface DatabaseIfc
        Returns:
        the jooq DSLContext for manipulating this database
      • getDefaultSchemaName

        public java.lang.String getDefaultSchemaName()
        Specified by:
        getDefaultSchemaName in interface DatabaseIfc
        Returns:
        a String that represents the name of the default schema for the database. This is the schema that contains the database objects such as the tables. This may be null if no default schema is specified.
      • setDefaultSchemaName

        public void setDefaultSchemaName​(java.lang.String defaultSchemaName)
        Description copied from interface: DatabaseIfc
        Sets the name of the default schema
        Specified by:
        setDefaultSchemaName in interface DatabaseIfc
        Parameters:
        defaultSchemaName - the name for the default schema, may be null