Interface RDBMSDriver
- All Known Implementing Classes:
HSQLDBDriver, MySQLDriver, PostgreSQLDriver, SQLiteDriver
public interface RDBMSDriver
RDBMSDrivers represents a way to connect and physically execute queries over
a database. This is a wrapper over java.sql which also give access to some
useful and driver-specific SQL queries.
A driver may keep a connection open in order to execute queries faster
A driver may keep a connection open in order to execute queries faster
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidDrops all indexes in the database except for primary keys.default voidClears all tables in the database by truncating them.default StringReturns the base INSERT query template.Returns the base safe INSERT query template.Returns the safe INSERT-SELECT query template.default StringReturns the base SELECT-with-filter query template.default StringReturns the base SELECT query template.default StringReturns the base alias used for tables.A driver may keep a connection open in order to execute queries faster or create a new one each time Returns a JDBC connection to the target database.getCSVCopyQuery(String tableName, String csvFilePath, char delimiter, int headerSize) Returns the SQL query used to bulk-copy CSV data.Returns the data source handled by this driver.Returns the JDBC connection string.Returns the SQL numeric-column type name used by this driver.Returns the SQL text-column type name used by this driver.default booleanChecks whether a table exists in the target database.
-
Method Details
-
getDatasource
DataSource getDatasource()Returns the data source handled by this driver.- Returns:
- the
DataSourcerepresented by this driver
-
getConnection
Connection getConnection()A driver may keep a connection open in order to execute queries faster or create a new one each time Returns a JDBC connection to the target database.- Returns:
- a
Connectionfor the database represented by this driver
-
getJDBCString
-
hasTable
Checks whether a table exists in the target database.- Parameters:
table_name- the name of the table- Returns:
- true iff the database represented by this driver have a table with the given name
- Throws:
SQLException- iff something bad happen
-
getBaseSelectQuery
Returns the base SELECT query template.- Returns:
- the base SELECT query corresponding to this driver
-
getBaseSelectFilteredQuery
Returns the base SELECT-with-filter query template.- Returns:
- the base SELECT query with a WHERE clause corresponding to this driver
-
getBaseTableAlias
Returns the base alias used for tables.- Returns:
- the base alias used to name tables for this driver
-
getBaseInsertQuery
Returns the base INSERT query template.- Returns:
- the base INSERT query corresponding to this driver
-
getBaseSafeInsertQuery
String getBaseSafeInsertQuery()Returns the base safe INSERT query template.- Returns:
- the base INSERT query which does not create exceptions in case of duplicates corresponding to this driver
-
getBaseSafeInsertSelectQuery
String getBaseSafeInsertSelectQuery()Returns the safe INSERT-SELECT query template.- Returns:
- the base INSERT query using a SELECT clause which does not create exceptions in case of duplicates corresponding to this driver
-
getTextFieldName
String getTextFieldName()Returns the SQL text-column type name used by this driver.- Returns:
- the name of the Text field corresponding to this driver
-
getNumberFieldName
String getNumberFieldName()Returns the SQL numeric-column type name used by this driver.- Returns:
- the name of the Number field corresponding to this driver
-
getCSVCopyQuery
Returns the SQL query used to bulk-copy CSV data.- Parameters:
tableName- table name to store datacsvFilePath- path to the csv filedelimiter- delimiter of the csv fileheaderSize- size of the csv header- Returns:
- the query used to copy a CSV file into the database system
-
dropAllTables
Clears all tables in the database by truncating them.- Throws:
SQLException- If an error occurs during database access.
-
dropAllIndexes
default void dropAllIndexes()Drops all indexes in the database except for primary keys.
-