public abstract class DataSourceWrapper extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
name |
protected com.zaxxer.hikari.HikariDataSource |
service
References the real data source implementation this class acts as pure
proxy for.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addForeignKeyConstraint(Connection conn,
String constraintName,
String baseTable,
String baseColumn,
String referencedTable,
String referencedColumn,
String onDeleteAction,
String onUpdateAction) |
void |
addPrimaryKey(Connection conn,
String primaryKeyName,
String table,
String... columns) |
void |
addUniqueConstrain(Connection conn,
String constraintName,
String table,
String... columns) |
protected String |
buildAndCacheNextSeqValueSql(String sequenceName) |
protected abstract String |
buildCreateSequenceSql(String sequenceName,
long startValue) |
protected abstract String |
buildDropSequenceSql(String sequenceName) |
protected abstract String |
buildNextSeqValueSql(String sequenceName) |
String |
buildSelectFirstSql(int rows,
String coreSql) |
abstract String |
buildSelectFirstSql(int rows,
String orderBy,
String coreSql) |
void |
close() |
boolean |
columnExists(Connection conn,
String table,
String column,
Object value) |
void |
createIndex(Connection conn,
String indexName,
String table,
String... columns) |
void |
createSequence(String sequenceName,
long startValue) |
Statement |
createStatement(Connection conn) |
boolean |
deleteFromTable(Connection conn,
String table,
String idColumn,
long id) |
void |
dropAndCreateSequence(String sequenceName,
long startValue) |
void |
dropForeignKeyConstraint(Connection conn,
String constraintName,
String baseTable) |
void |
dropIndex(Connection conn,
String table,
String indexName) |
void |
dropPrimaryKey(Connection conn,
String primaryKeyName,
String table) |
void |
dropSequence(String sequenceName) |
void |
dropUniqueConstrain(Connection conn,
String constraintName,
String table) |
Connection |
getConnection() |
int |
getCount(Connection conn,
String table) |
DatabaseType |
getDatabaseType() |
<T> T |
getFirstValue(Connection conn,
String table,
String column,
String criteria,
Class<T> type) |
PrintWriter |
getLogWriter() |
long |
getMax(Connection conn,
String table,
String column) |
long |
getMax(Connection conn,
String table,
String column,
String condition) |
int |
getMaximumPoolSize() |
long |
getMin(Connection conn,
String table,
String column) |
long |
getMin(Connection conn,
String table,
String column,
String condition) |
String |
getName() |
protected String |
getSqlToAddForeignKeyConstraint(String constraintName,
String baseTable,
String baseColumn,
String referencedTable,
String referencedColumn,
String onDeleteAction,
String onUpdateAction) |
protected String |
getSqlToAddPrimaryKey(String primaryKeyName,
String table,
String... columns) |
protected String |
getSqlToAddUniqueConstrain(String constraintName,
String table,
String... columns) |
protected String |
getSqlToCreateIndex(String indexName,
String table,
String... columns) |
protected String |
getSqlToDropForeignKeyConstraint(String constraintName,
String baseTable) |
protected String |
getSqlToDropIndex(String table,
String indexName) |
protected String |
getSqlToDropPrimaryKey(String primaryKeyName,
String table) |
protected String |
getSqlToDropUniqueConstraint(String constraintName,
String table) |
protected boolean |
isUseSqlStateAsCode() |
long |
nextSeqValue(Connection conn,
String sequenceName) |
PreparedStatement |
prepareStatement(Connection conn,
String sqlQuery) |
void |
releaseResources(Statement ps,
ResultSet rs) |
void |
releaseResources(Statement ps,
ResultSet rs,
boolean returnConnection) |
void |
returnConnection(Connection conn) |
void |
setLastUsedSeqValue(String sequenceName,
long sequenceValue) |
boolean |
tableExists(Connection conn,
String table) |
boolean |
tableHasColumn(Connection conn,
String table,
String column) |
DataAccessException |
translate(String sql,
SQLException ex) |
protected final com.zaxxer.hikari.HikariDataSource service
protected final String name
public final String getName()
public final DatabaseType getDatabaseType()
public final int getMaximumPoolSize()
public final Connection getConnection() throws DataAccessException
DataAccessExceptionpublic void returnConnection(Connection conn)
public void close()
public final PrintWriter getLogWriter() throws SQLException
SQLExceptionpublic Statement createStatement(Connection conn) throws DataAccessException
DataAccessExceptionpublic PreparedStatement prepareStatement(Connection conn, String sqlQuery) throws DataAccessException
DataAccessExceptionpublic abstract String buildSelectFirstSql(int rows, String orderBy, String coreSql)
public <T> T getFirstValue(Connection conn, String table, String column, String criteria, Class<T> type) throws DataAccessException
DataAccessExceptionpublic long getMin(Connection conn, String table, String column) throws DataAccessException
DataAccessExceptionpublic long getMin(Connection conn, String table, String column, String condition) throws DataAccessException
DataAccessExceptionpublic int getCount(Connection conn, String table) throws DataAccessException
DataAccessExceptionpublic long getMax(Connection conn, String table, String column) throws DataAccessException
DataAccessExceptionpublic long getMax(Connection conn, String table, String column, String condition) throws DataAccessException
DataAccessExceptionpublic boolean deleteFromTable(Connection conn, String table, String idColumn, long id)
public boolean columnExists(Connection conn, String table, String column, Object value) throws DataAccessException
DataAccessExceptionpublic boolean tableHasColumn(Connection conn, String table, String column) throws DataAccessException
DataAccessExceptionpublic boolean tableExists(Connection conn, String table) throws DataAccessException
DataAccessExceptionprotected abstract String buildCreateSequenceSql(String sequenceName, long startValue)
protected final String buildAndCacheNextSeqValueSql(String sequenceName)
protected boolean isUseSqlStateAsCode()
public void dropAndCreateSequence(String sequenceName, long startValue) throws DataAccessException
DataAccessExceptionpublic void createSequence(String sequenceName, long startValue) throws DataAccessException
DataAccessExceptionpublic void dropSequence(String sequenceName) throws DataAccessException
DataAccessExceptionpublic void setLastUsedSeqValue(String sequenceName, long sequenceValue)
public long nextSeqValue(Connection conn, String sequenceName) throws DataAccessException
DataAccessExceptionpublic void dropPrimaryKey(Connection conn, String primaryKeyName, String table) throws DataAccessException
DataAccessExceptionprotected String getSqlToAddPrimaryKey(String primaryKeyName, String table, String... columns)
public void addPrimaryKey(Connection conn, String primaryKeyName, String table, String... columns) throws DataAccessException
DataAccessExceptionprotected String getSqlToDropForeignKeyConstraint(String constraintName, String baseTable) throws DataAccessException
DataAccessExceptionpublic void dropForeignKeyConstraint(Connection conn, String constraintName, String baseTable) throws DataAccessException
DataAccessExceptionprotected String getSqlToAddForeignKeyConstraint(String constraintName, String baseTable, String baseColumn, String referencedTable, String referencedColumn, String onDeleteAction, String onUpdateAction)
public void addForeignKeyConstraint(Connection conn, String constraintName, String baseTable, String baseColumn, String referencedTable, String referencedColumn, String onDeleteAction, String onUpdateAction) throws DataAccessException
DataAccessExceptionpublic void dropIndex(Connection conn, String table, String indexName) throws DataAccessException
DataAccessExceptionprotected String getSqlToCreateIndex(String indexName, String table, String... columns)
public void createIndex(Connection conn, String indexName, String table, String... columns) throws DataAccessException
DataAccessExceptionprotected String getSqlToDropUniqueConstraint(String constraintName, String table)
public void dropUniqueConstrain(Connection conn, String constraintName, String table) throws DataAccessException
DataAccessExceptionprotected String getSqlToAddUniqueConstrain(String constraintName, String table, String... columns)
public void addUniqueConstrain(Connection conn, String constraintName, String table, String... columns) throws DataAccessException
DataAccessExceptionpublic DataAccessException translate(String sql, SQLException ex)
Copyright © 2018. All rights reserved.