public class DBInterfaceDerby extends Database implements IDBInterface
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DBInterfaceDerby.TableStatistics
Table accumulation records.
|
Database.ExecuteQueryThread, Database.Modifications, Database.QueryCacheExecutor| Modifier and Type | Field and Description |
|---|---|
protected static String |
_driver |
static String |
_rcsid |
protected static String |
_url |
protected static Map<String,Integer> |
analyzeThresholds
Table analyze thresholds, as read from configuration information.
|
protected String |
cacheKey |
protected static int |
commitThreshold
The number of inserts, deletes, etc.
|
protected static Map<String,DBInterfaceDerby.TableStatistics> |
currentAnalyzeStatistics
Accumulated analyze statistics.
|
protected static Map<String,DBInterfaceDerby.TableStatistics> |
currentReindexStatistics
Accumulated reindex statistics.
|
static String |
databasePathProperty |
protected ILockManager |
lockManager
A lock manager handle.
|
protected String |
password |
protected static Map<String,Integer> |
reindexThresholds
Table reindex thresholds, as read from configuration information.
|
protected int |
serializableDepth |
protected static String |
statsAnalyzePrefix |
protected static String |
statslockAnalyzePrefix |
protected static String |
statslockReindexPrefix |
protected static String |
statsReindexPrefix |
protected List<String> |
tablesToAnalyze |
protected List<String> |
tablesToReindex |
protected String |
userName |
_TRANSACTION_, cacheManager, commitDone, connection, context, databaseName, debug, delayedTransactionDepth, doRollback, jdbcDriverClass, jdbcUrl, maxDBConnections, maxQueryTime, modificationsSet, random, thTRANSACTION_ENCLOSING, TRANSACTION_READCOMMITTED, TRANSACTION_REPEATABLEREAD, TRANSACTION_SERIALIZED| Constructor and Description |
|---|
DBInterfaceDerby(IThreadContext tc,
String databaseName) |
DBInterfaceDerby(IThreadContext tc,
String databaseName,
String userName,
String password) |
| Modifier and Type | Method and Description |
|---|---|
void |
addTableIndex(String tableName,
boolean unique,
List<String> columnList)
Add an index to a table.
|
void |
analyzeTable(String tableName)
Analyze a table.
|
protected void |
analyzeTableInternal(String tableName) |
protected void |
appendDescription(StringBuilder queryBuffer,
String columnName,
ColumnDescription cd,
boolean forceNull) |
void |
beginTransaction()
Begin a database transaction.
|
void |
beginTransaction(int transactionType)
Begin a database transaction.
|
static String |
caseInsensitiveRegularExpressionCompare(String value,
String regularExpression)
Method to compare a value using a case-insensitive regular expression.
|
static String |
caseInsensitiveSubstring(String value,
String regularExpression)
Method to get a substring out of a case-insensitive regular expression group.
|
static String |
caseSensitiveRegularExpressionCompare(String value,
String regularExpression)
Method to compare a value using a case-sensitive regular expression.
|
static String |
caseSensitiveSubstring(String value,
String regularExpression)
Method to get a substring out of a case-sensitive regular expression group.
|
void |
closeDatabase()
Uninitialize.
|
protected void |
commitCurrentTransaction()
Abstract method to commit a transaction
|
String |
constructCountClause(String column)
Construct a count clause.
|
String |
constructDistinctOnClause(List outputParameters,
String baseQuery,
List baseParameters,
String[] distinctFields,
String[] orderFields,
boolean[] orderFieldsAscending,
Map<String,String> otherFields)
Construct a 'distinct on (x)' filter.
|
String |
constructDoubleCastClause(String value)
Construct a cast to a double value.
|
String |
constructOffsetLimitClause(int offset,
int limit,
boolean afterOrderBy)
Construct an offset/limit clause.
|
String |
constructRegexpClause(String column,
String regularExpression,
boolean caseInsensitive)
Construct a regular-expression match clause.
|
String |
constructSubstringClause(String column,
String regularExpression,
boolean caseInsensitive)
Construct a regular-expression substring clause.
|
void |
createUserAndDatabase(String adminUserName,
String adminPassword,
StringSet invalidateKeys)
Create user and database.
|
void |
dropUserAndDatabase(String adminUserName,
String adminPassword,
StringSet invalidateKeys)
Drop user and database.
|
void |
endTransaction()
End a database transaction, either performing a commit or a rollback (depending on whether
signalRollback() was called within the transaction).
|
StringSet |
getAllTables(StringSet cacheKeys,
String queryClass)
Get a database's tables.
|
String |
getDatabaseCacheKey()
Get the database general cache key.
|
protected static String |
getFullDatabasePath(String databaseName) |
int |
getMaxInClause()
Obtain the maximum number of individual items that should be
present in an IN clause.
|
int |
getMaxOrClause()
Obtain the maximum number of individual clauses that should be
present in a sequence of OR clauses.
|
Map<String,IndexDescription> |
getTableIndexes(String tableName,
StringSet cacheKeys,
String queryClass)
Get a table's indexes.
|
Map<String,ColumnDescription> |
getTableSchema(String tableName,
StringSet cacheKeys,
String queryClass)
Get a table's schema.
|
int |
getWindowedReportMaxRows()
For windowed report queries, e.g.
|
protected String |
mapLabelName(String rawLabelName)
Abstract method for mapping a column name from resultset
|
protected static String |
mapType(String inputType)
Map a standard type into a derby type.
|
protected void |
noteModificationsNoTransactions(String tableName,
int insertCount,
int modifyCount,
int deleteCount)
Note a number of inserts, modifications, or deletions to a specific table.
|
void |
openDatabase()
Initialize.
|
void |
performAddIndex(String indexName,
String tableName,
IndexDescription description)
Add an index to a table.
|
void |
performAlter(String tableName,
Map<String,ColumnDescription> columnMap,
Map<String,ColumnDescription> columnModifyMap,
List<String> columnDeleteList,
StringSet invalidateKeys)
Perform a table alter operation.
|
void |
performCreate(String tableName,
Map<String,ColumnDescription> columnMap,
StringSet invalidateKeys)
Perform a table creation operation.
|
void |
performDelete(String tableName,
String whereClause,
List whereParameters,
StringSet invalidateKeys)
Perform a delete operation.
|
void |
performDrop(String tableName,
StringSet invalidateKeys)
Perform a table drop operation.
|
void |
performInsert(String tableName,
Map<String,Object> parameterMap,
StringSet invalidateKeys)
Perform an insert operation.
|
void |
performModification(String query,
List params,
StringSet invalidateKeys)
Perform a general database modification query.
|
IResultSet |
performQuery(String query,
List params,
StringSet cacheKeys,
String queryClass)
Perform a general "data fetch" query.
|
IResultSet |
performQuery(String query,
List params,
StringSet cacheKeys,
String queryClass,
int maxResults,
ILimitChecker returnLimit)
Perform a general "data fetch" query.
|
IResultSet |
performQuery(String query,
List params,
StringSet cacheKeys,
String queryClass,
int maxResults,
ResultSpecification resultSpec,
ILimitChecker returnLimit)
Perform a general "data fetch" query.
|
void |
performRemoveIndex(String indexName,
String tableName)
Remove an index.
|
void |
performUpdate(String tableName,
Map<String,Object> parameterMap,
String whereClause,
List whereParameters,
StringSet invalidateKeys)
Perform an update operation.
|
protected int |
readDatum(String datumName)
Read a datum, presuming zero if the datum does not exist.
|
protected static void |
recursiveDelete(File f) |
void |
reindexTable(String tableName)
Reindex a table.
|
protected void |
reindexTableInternal(String tableName) |
protected ManifoldCFException |
reinterpretException(ManifoldCFException theException)
Reinterpret an exception tossed by the database layer.
|
protected void |
rollbackCurrentTransaction()
Abstract method to roll back a transaction
|
void |
signalRollback()
Signal that a rollback should occur on the next endTransaction().
|
protected static void |
singleDelete(File f) |
protected void |
startATransaction()
Abstract method to start a transaction
|
protected void |
writeDatum(String datumName,
int value)
Write a datum, presuming zero if the datum does not exist.
|
buildConjunctionClause, cleanupParameters, constructIndexHintClause, constructIndexOrderByClause, constructOffsetLimitClause, execute, executeQuery, executeUncachedQuery, executeViaThread, explainQuery, findColumn, findConjunctionClauseMax, getBLOB, getCurrentTransactionType, getData, getDatabaseName, getObject, getSleepAmt, getTransactionID, initializeConnection, internalTransactionBegin, interruptCleanup, isBinary, isBLOB, loadPS, mapLookupName, noteModifications, performCommit, prepareForDatabaseCreate, sleepFor, synchronizeTransactionsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildConjunctionClause, constructIndexHintClause, constructIndexOrderByClause, constructOffsetLimitClause, findConjunctionClauseMax, getDatabaseName, getSleepAmt, getTransactionID, noteModifications, performCommit, sleepForpublic static final String _rcsid
protected static final String _url
protected static final String _driver
public static final String databasePathProperty
protected ILockManager lockManager
protected String userName
protected String password
protected String cacheKey
protected int serializableDepth
protected static Map<String,DBInterfaceDerby.TableStatistics> currentReindexStatistics
protected static Map<String,Integer> reindexThresholds
protected static Map<String,DBInterfaceDerby.TableStatistics> currentAnalyzeStatistics
protected static Map<String,Integer> analyzeThresholds
protected static final int commitThreshold
protected static final String statslockReindexPrefix
protected static final String statsReindexPrefix
protected static final String statslockAnalyzePrefix
protected static final String statsAnalyzePrefix
public DBInterfaceDerby(IThreadContext tc, String databaseName, String userName, String password) throws ManifoldCFException
ManifoldCFExceptionpublic DBInterfaceDerby(IThreadContext tc, String databaseName) throws ManifoldCFException
ManifoldCFExceptionprotected static String getFullDatabasePath(String databaseName) throws ManifoldCFException
ManifoldCFExceptionpublic void openDatabase()
throws ManifoldCFException
openDatabase in interface IDBInterfaceManifoldCFExceptionpublic void closeDatabase()
throws ManifoldCFException
closeDatabase in interface IDBInterfaceManifoldCFExceptionpublic String getDatabaseCacheKey()
getDatabaseCacheKey in interface IDBInterfacepublic void performInsert(String tableName, Map<String,Object> parameterMap, StringSet invalidateKeys) throws ManifoldCFException
performInsert in interface IDBInterfacetableName - is the name of the table.invalidateKeys - are the cache keys that should be
invalidated.parameterMap - is the map of column name/values to write.ManifoldCFExceptionpublic void performUpdate(String tableName, Map<String,Object> parameterMap, String whereClause, List whereParameters, StringSet invalidateKeys) throws ManifoldCFException
performUpdate in interface IDBInterfacetableName - is the name of the table.invalidateKeys - are the cache keys that should be invalidated.parameterMap - is the map of column name/values to write.whereClause - is the where clause describing the match (including the WHERE), or null if none.whereParameters - are the parameters that come with the where clause, if any.ManifoldCFExceptionpublic void performDelete(String tableName, String whereClause, List whereParameters, StringSet invalidateKeys) throws ManifoldCFException
performDelete in interface IDBInterfacetableName - is the name of the table to delete from.invalidateKeys - are the cache keys that should be invalidated.whereClause - is the where clause describing the match (including the WHERE), or null if none.whereParameters - are the parameters that come with the where clause, if any.ManifoldCFExceptionpublic void performCreate(String tableName, Map<String,ColumnDescription> columnMap, StringSet invalidateKeys) throws ManifoldCFException
performCreate in interface IDBInterfacetableName - is the name of the table to create.columnMap - is the map describing the columns and types. NOTE that these are abstract
types, which will be mapped to the proper types for the actual database inside this
layer.invalidateKeys - are the cache keys that should be invalidated, if any.ManifoldCFExceptionprotected void appendDescription(StringBuilder queryBuffer, String columnName, ColumnDescription cd, boolean forceNull) throws ManifoldCFException
ManifoldCFExceptionpublic void performAlter(String tableName, Map<String,ColumnDescription> columnMap, Map<String,ColumnDescription> columnModifyMap, List<String> columnDeleteList, StringSet invalidateKeys) throws ManifoldCFException
performAlter in interface IDBInterfacetableName - is the name of the table to alter.columnMap - is the map describing the columns and types to add. These
are in the same form as for performCreate.columnModifyMap - is the map describing the columns to be changed. The key is the
existing column name, and the value is the new type of the column. Data will be copied from
the old column to the new.columnDeleteList - is the list of column names to delete.invalidateKeys - are the cache keys that should be invalidated, if any.ManifoldCFExceptionprotected static String mapType(String inputType)
inputType - is the input type.public void addTableIndex(String tableName, boolean unique, List<String> columnList) throws ManifoldCFException
addTableIndex in interface IDBInterfacetableName - is the name of the table to add the index for.unique - is a boolean that if true describes a unique index.columnList - is the list of columns that need to be included
in the index, in order.ManifoldCFExceptionpublic void performAddIndex(String indexName, String tableName, IndexDescription description) throws ManifoldCFException
performAddIndex in interface IDBInterfacetableName - is the name of the table to add the index for.indexName - is the optional name of the table index. If null, a name will be chosen automatically.description - is the index description.ManifoldCFExceptionpublic void performRemoveIndex(String indexName, String tableName) throws ManifoldCFException
performRemoveIndex in interface IDBInterfaceindexName - is the name of the index to remove.tableName - is the table the index belongs to.ManifoldCFExceptionprotected int readDatum(String datumName) throws ManifoldCFException
ManifoldCFExceptionprotected void writeDatum(String datumName, int value) throws ManifoldCFException
ManifoldCFExceptionpublic void analyzeTable(String tableName) throws ManifoldCFException
analyzeTable in interface IDBInterfacetableName - is the name of the table to analyze/calculate statistics for.ManifoldCFExceptionpublic void reindexTable(String tableName) throws ManifoldCFException
reindexTable in interface IDBInterfacetableName - is the name of the table to rebuild indexes for.ManifoldCFExceptionprotected void analyzeTableInternal(String tableName) throws ManifoldCFException
ManifoldCFExceptionprotected void reindexTableInternal(String tableName) throws ManifoldCFException
ManifoldCFExceptionpublic void performDrop(String tableName, StringSet invalidateKeys) throws ManifoldCFException
performDrop in interface IDBInterfacetableName - is the name of the table to drop.invalidateKeys - are the cache keys that should be invalidated, if any.ManifoldCFExceptionpublic void createUserAndDatabase(String adminUserName, String adminPassword, StringSet invalidateKeys) throws ManifoldCFException
createUserAndDatabase in interface IDBInterfaceadminUserName - is the admin user name.adminPassword - is the admin password.invalidateKeys - are the cache keys that should be invalidated, if any.ManifoldCFExceptionpublic void dropUserAndDatabase(String adminUserName, String adminPassword, StringSet invalidateKeys) throws ManifoldCFException
dropUserAndDatabase in interface IDBInterfaceadminUserName - is the admin user name.adminPassword - is the admin password.invalidateKeys - are the cache keys that should be invalidated, if any.ManifoldCFExceptionprotected static void recursiveDelete(File f)
protected static void singleDelete(File f)
protected ManifoldCFException reinterpretException(ManifoldCFException theException)
theException - is the exception to reinterpretpublic void performModification(String query, List params, StringSet invalidateKeys) throws ManifoldCFException
performModification in interface IDBInterfacequery - is the query string.params - are the parameterized values, if needed.invalidateKeys - are the cache keys to invalidate.ManifoldCFExceptionpublic Map<String,ColumnDescription> getTableSchema(String tableName, StringSet cacheKeys, String queryClass) throws ManifoldCFException
getTableSchema in interface IDBInterfacetableName - is the name of the table.cacheKeys - are the keys against which to cache the query, or null.queryClass - is the name of the query class, or null.ManifoldCFExceptionpublic Map<String,IndexDescription> getTableIndexes(String tableName, StringSet cacheKeys, String queryClass) throws ManifoldCFException
getTableIndexes in interface IDBInterfacetableName - is the name of the table.cacheKeys - are the keys against which to cache the query, or null.queryClass - is the name of the query class, or null.ManifoldCFExceptionpublic StringSet getAllTables(StringSet cacheKeys, String queryClass) throws ManifoldCFException
getAllTables in interface IDBInterfacecacheKeys - are the cache keys for the query, or null.queryClass - is the name of the query class, or null.ManifoldCFExceptionpublic IResultSet performQuery(String query, List params, StringSet cacheKeys, String queryClass) throws ManifoldCFException
performQuery in interface IDBInterfacequery - is the query string.params - are the parameterized values, if needed.cacheKeys - are the cache keys, if needed (null if no cache desired).queryClass - is the LRU class name against which this query would be cached,
or null if no LRU behavior desired.ManifoldCFExceptionpublic IResultSet performQuery(String query, List params, StringSet cacheKeys, String queryClass, int maxResults, ILimitChecker returnLimit) throws ManifoldCFException
performQuery in interface IDBInterfacequery - is the query string.params - are the parameterized values, if needed.cacheKeys - are the cache keys, if needed (null if no cache desired).queryClass - is the LRU class name against which this query would be cached,
or null if no LRU behavior desired.maxResults - is the maximum number of results returned (-1 for all).returnLimit - is a description of how to limit the return result, or null if no limit.ManifoldCFExceptionpublic IResultSet performQuery(String query, List params, StringSet cacheKeys, String queryClass, int maxResults, ResultSpecification resultSpec, ILimitChecker returnLimit) throws ManifoldCFException
performQuery in interface IDBInterfacequery - is the query string.params - are the parameterized values, if needed.cacheKeys - are the cache keys, if needed (null if no cache desired).queryClass - is the LRU class name against which this query would be cached,
or null if no LRU behavior desired.maxResults - is the maximum number of results returned (-1 for all).resultSpec - is a result specification, or null for the standard treatment.returnLimit - is a description of how to limit the return result, or null if no limit.ManifoldCFExceptionpublic String constructDoubleCastClause(String value)
constructDoubleCastClause in interface IDBInterfacevalue - is the value to be cast.public String constructCountClause(String column)
constructCountClause in interface IDBInterfacecolumn - is the column string to be counted.public String constructRegexpClause(String column, String regularExpression, boolean caseInsensitive)
constructRegexpClause in interface IDBInterfacecolumn - is the column specifier string.regularExpression - is the properly-quoted regular expression string, or "?" if a parameterized value is to be used.caseInsensitive - is true of the regular expression match is to be case insensitive.public String constructSubstringClause(String column, String regularExpression, boolean caseInsensitive)
constructSubstringClause in interface IDBInterfacecolumn - is the column specifier string.regularExpression - is the properly-quoted regular expression string, or "?" if a parameterized value is to be used.caseInsensitive - is true if the regular expression match is to be case insensitive.public String constructOffsetLimitClause(int offset, int limit, boolean afterOrderBy)
constructOffsetLimitClause in interface IDBInterfaceconstructOffsetLimitClause in class Databaseoffset - is the starting offset number.limit - is the limit of result rows to return.afterOrderBy - is true if this offset/limit comes after an ORDER BY.public String constructDistinctOnClause(List outputParameters, String baseQuery, List baseParameters, String[] distinctFields, String[] orderFields, boolean[] orderFieldsAscending, Map<String,String> otherFields)
constructDistinctOnClause in interface IDBInterfaceoutputParameters - is a blank list into which to put parameters. Null may be used if the baseParameters parameter is null.baseQuery - is the base query, which is another SELECT statement, without parens,
e.g. "SELECT ..."baseParameters - are the parameters corresponding to the baseQuery.distinctFields - are the fields to consider to be distinct. These should all be keys in otherFields below.orderFields - are the otherfield keys that determine the ordering.orderFieldsAscending - are true for orderFields that are ordered as ASC, false for DESC.otherFields - are the rest of the fields to return, keyed by the AS name, value being the base query column value, e.g. "value AS key"public int getMaxInClause()
getMaxInClause in interface IDBInterfacegetMaxInClause in class Databasepublic int getMaxOrClause()
getMaxOrClause in interface IDBInterfacepublic int getWindowedReportMaxRows()
getWindowedReportMaxRows in interface IDBInterfaceprotected void noteModificationsNoTransactions(String tableName, int insertCount, int modifyCount, int deleteCount) throws ManifoldCFException
noteModificationsNoTransactions in class DatabasetableName - is the name of the table being modified.insertCount - is the number of inserts.modifyCount - is the number of updates.deleteCount - is the number of deletions.ManifoldCFExceptionpublic void beginTransaction()
throws ManifoldCFException
beginTransaction in interface IDBInterfaceManifoldCFExceptionpublic void beginTransaction(int transactionType)
throws ManifoldCFException
beginTransaction in interface IDBInterfacebeginTransaction in class DatabasetransactionType - is the kind of transaction desired.ManifoldCFExceptionpublic void signalRollback()
signalRollback in interface IDBInterfacesignalRollback in class Databasepublic void endTransaction()
throws ManifoldCFException
endTransaction in interface IDBInterfaceendTransaction in class DatabaseManifoldCFExceptionprotected void startATransaction()
throws ManifoldCFException
startATransaction in class DatabaseManifoldCFExceptionprotected void commitCurrentTransaction()
throws ManifoldCFException
commitCurrentTransaction in class DatabaseManifoldCFExceptionprotected void rollbackCurrentTransaction()
throws ManifoldCFException
rollbackCurrentTransaction in class DatabaseManifoldCFExceptionprotected String mapLabelName(String rawLabelName)
mapLabelName in class Databasepublic static String caseInsensitiveRegularExpressionCompare(String value, String regularExpression) throws SQLException
SQLExceptionpublic static String caseSensitiveRegularExpressionCompare(String value, String regularExpression) throws SQLException
SQLExceptionpublic static String caseInsensitiveSubstring(String value, String regularExpression) throws SQLException
SQLExceptionpublic static String caseSensitiveSubstring(String value, String regularExpression) throws SQLException
SQLException