public class DbToolBase extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected String |
baseDir |
protected Connection |
connection |
protected org.xipki.datasource.DataSourceWrapper |
datasource |
protected AtomicBoolean |
stopMe |
| Constructor and Description |
|---|
DbToolBase(org.xipki.datasource.DataSourceWrapper datasource,
String baseDir,
AtomicBoolean stopMe) |
| Modifier and Type | Method and Description |
|---|---|
static String |
buildFilename(String prefix,
String suffix,
long minIdOfCurrentFile,
long maxIdOfCurrentFile,
long maxId) |
void |
close() |
protected void |
commit(String task) |
int |
count(String table) |
protected Statement |
createStatement() |
boolean |
deleteFromTableWithLargerId(String table,
String idColumn,
long id,
org.slf4j.Logger log) |
static void |
deleteTmpFiles(String dirName,
String prefix) |
protected void |
disableAutoCommit() |
static Properties |
getDbConfProperties(InputStream is) |
static ZipOutputStream |
getZipOutputStream(File zipFile) |
long |
max(String table,
String column) |
long |
max(String table,
String column,
String condition) |
long |
min(String table,
String column) |
long |
min(String table,
String column,
String condition) |
protected PreparedStatement |
prepareStatement(String sql) |
protected void |
recoverAutoCommit() |
void |
releaseResources(Statement ps,
ResultSet rs) |
protected void |
rollback() |
protected static void |
setBoolean(PreparedStatement ps,
int index,
boolean value) |
protected static void |
setInt(PreparedStatement ps,
int index,
Integer value) |
protected static void |
setLong(PreparedStatement ps,
int index,
Long value) |
protected Savepoint |
setSavepoint() |
boolean |
tableExists(String table) |
boolean |
tableHasColumn(String table,
String column) |
protected org.xipki.datasource.DataAccessException |
translate(String sql,
SQLException ex) |
protected static void |
writeLine(OutputStream os,
String text) |
protected final AtomicBoolean stopMe
protected final org.xipki.datasource.DataSourceWrapper datasource
protected final String baseDir
protected Connection connection
public DbToolBase(org.xipki.datasource.DataSourceWrapper datasource,
String baseDir,
AtomicBoolean stopMe)
throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionprotected Statement createStatement() throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionprotected PreparedStatement prepareStatement(String sql) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionpublic boolean deleteFromTableWithLargerId(String table, String idColumn, long id, org.slf4j.Logger log)
public void close()
close in interface Closeableclose in interface AutoCloseablepublic long min(String table, String column) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionpublic long min(String table, String column, String condition) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionpublic long max(String table, String column) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionpublic long max(String table, String column, String condition) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionpublic int count(String table) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionpublic boolean tableHasColumn(String table, String column) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionpublic boolean tableExists(String table) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionprotected Savepoint setSavepoint() throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionprotected void rollback()
throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionprotected org.xipki.datasource.DataAccessException translate(String sql, SQLException ex)
protected void disableAutoCommit()
throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionprotected void recoverAutoCommit()
protected void commit(String task) throws org.xipki.datasource.DataAccessException
org.xipki.datasource.DataAccessExceptionprotected static void setLong(PreparedStatement ps, int index, Long value) throws SQLException
SQLExceptionprotected static void setInt(PreparedStatement ps, int index, Integer value) throws SQLException
SQLExceptionprotected static void setBoolean(PreparedStatement ps, int index, boolean value) throws SQLException
SQLExceptionpublic static Properties getDbConfProperties(InputStream is) throws IOException
IOExceptionprotected static void writeLine(OutputStream os, String text) throws IOException
IOExceptionpublic static String buildFilename(String prefix, String suffix, long minIdOfCurrentFile, long maxIdOfCurrentFile, long maxId)
public static ZipOutputStream getZipOutputStream(File zipFile) throws IOException
IOExceptionCopyright © 2019. All rights reserved.