Package jslx.dbutilities.dbutil
Class Database
- java.lang.Object
-
- jslx.dbutilities.dbutil.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jslx.dbutilities.dbutil.DatabaseIfc
DatabaseIfc.LineOption
-
-
Field Summary
-
Fields inherited from interface jslx.dbutilities.dbutil.DatabaseIfc
COMMENT_PATTERN, DEFAULT_DELIMITER, LOGGER, NEW_DELIMITER_PATTERN
-
-
Constructor Summary
Constructors Constructor Description Database(java.lang.String dbLabel, javax.sql.DataSource dataSource)
Create a Database.Database(java.lang.String dbLabel, javax.sql.DataSource dataSource, org.jooq.SQLDialect dialect)
Database(java.lang.String dbLabel, javax.sql.DataSource dataSource, org.jooq.SQLDialect dialect, org.jooq.conf.Settings settings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.sql.DataSource
getDataSource()
java.lang.String
getDefaultSchemaName()
org.jooq.DSLContext
getDSLContext()
java.lang.String
getLabel()
org.jooq.SQLDialect
getSQLDialect()
void
setDefaultSchemaName(java.lang.String defaultSchemaName)
Sets the name of the default schema-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jslx.dbutilities.dbutil.DatabaseIfc
areAllTablesEmpty, containsSchema, containsSchema, containsTable, containsTable, containsTable, create, createResultQuery, dropSchema, executeCommand, executeCommand, executeCommands, executeScript, fetchJDBCResultSet, fetchResults, getAllTableNames, getConnection, getDatabaseMetaData, getDefaultSchema, getInsertQueries, getInsertQueries, getSchema, getTable, getTable, getTable, getTableNames, getTables, hasData, hasTables, isJooQDefaultExecutionLoggingOn, isTableEmpty, isTableEmpty, printAllTablesAsInsertQueries, printAllTablesAsText, printInsertQueries, printTableAsCSV, printTableAsText, selectAll, selectAll, setJooQDefaultExecutionLoggingOption, writeAllTablesAsCSV, writeAllTablesAsInsertQueries, writeAllTablesAsText, writeDbToExcelWorkbook, writeDbToExcelWorkbook, writeDbToExcelWorkbook, writeDbToExcelWorkbook, writeDbToExcelWorkbook, writeInsertQueries, writeInsertQueries, writeTableAsCSV, writeTableAsText
-
-
-
-
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 nulldialect
- 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 nulldialect
- the SLQ dialect for this type of database. It obviously must be consistent with the database referenced by the connectionsettings
- the JOOQ settings for the database context, may be null
-
-
Method Detail
-
getDataSource
public final javax.sql.DataSource getDataSource()
- Specified by:
getDataSource
in interfaceDatabaseIfc
- Returns:
- the DataSource backing the database
-
getLabel
public final java.lang.String getLabel()
- Specified by:
getLabel
in interfaceDatabaseIfc
- 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 interfaceDatabaseIfc
- Returns:
- the jooq SQL dialect for the database
-
getDSLContext
public org.jooq.DSLContext getDSLContext()
- Specified by:
getDSLContext
in interfaceDatabaseIfc
- Returns:
- the jooq DSLContext for manipulating this database
-
getDefaultSchemaName
public java.lang.String getDefaultSchemaName()
- Specified by:
getDefaultSchemaName
in interfaceDatabaseIfc
- 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 interfaceDatabaseIfc
- Parameters:
defaultSchemaName
- the name for the default schema, may be null
-
-