public class DBInterfaceHSQLDB extends Database implements IDBInterface
Database.ExecuteQueryThread, Database.Modifications, Database.QueryCacheExecutor
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
_rcsid |
protected java.lang.String |
cacheKey |
static java.lang.String |
databaseInstanceProperty |
static java.lang.String |
databasePathProperty |
static java.lang.String |
databasePortProperty |
static java.lang.String |
databaseProtocolProperty |
static java.lang.String |
databaseServerProperty |
protected int |
depthCount |
protected int |
desiredTransactionType |
protected boolean |
inTransaction |
protected boolean |
isRemote |
protected java.lang.String |
schemaNameForQueries |
protected int |
serializableDepth |
_TRANSACTION_, cacheManager, commitDone, connection, context, databaseName, debug, delayedTransactionDepth, doRollback, jdbcDriverClass, jdbcUrl, maxDBConnections, maxQueryTime, modificationsSet, password, random, th, userName
TRANSACTION_ENCLOSING, TRANSACTION_READCOMMITTED, TRANSACTION_REPEATABLEREAD, TRANSACTION_SERIALIZED
Constructor and Description |
---|
DBInterfaceHSQLDB(IThreadContext tc,
java.lang.String databaseName,
java.lang.String userName,
java.lang.String password) |
Modifier and Type | Method and Description |
---|---|
protected void |
addIndex(java.util.Map rval,
java.lang.String indexName,
boolean isUnique,
java.util.List<java.lang.String> indexColumns) |
void |
addTableIndex(java.lang.String tableName,
boolean unique,
java.util.List<java.lang.String> columnList)
Add an index to a table.
|
void |
analyzeTable(java.lang.String tableName)
Analyze a table.
|
protected static void |
appendDescription(java.lang.StringBuilder queryBuffer,
java.lang.String columnName,
ColumnDescription cd,
boolean forceNull) |
void |
beginTransaction()
Begin a database transaction.
|
void |
beginTransaction(int transactionType)
Begin a database transaction.
|
java.lang.String |
buildConjunctionClause(java.util.List outputParameters,
ClauseDescription[] clauseDescriptions) |
void |
closeDatabase()
Uninitialize.
|
protected void |
commitCurrentTransaction()
Abstract method to commit a transaction
|
java.lang.String |
constructCountClause(java.lang.String column)
Construct a count clause.
|
java.lang.String |
constructDistinctOnClause(java.util.List outputParameters,
java.lang.String baseQuery,
java.util.List baseParameters,
java.lang.String[] distinctFields,
java.lang.String[] orderFields,
boolean[] orderFieldsAscending,
java.util.Map<java.lang.String,java.lang.String> otherFields)
Construct a 'distinct on (x)' filter.
|
java.lang.String |
constructDoubleCastClause(java.lang.String value)
Construct a cast to a double value.
|
java.lang.String |
constructIndexOrderByClause(java.lang.String[] fieldNames,
boolean direction)
Construct ORDER-BY clause meant for reading from an index.
|
java.lang.String |
constructOffsetLimitClause(int offset,
int limit,
boolean afterOrderBy)
Construct an offset/limit clause.
|
java.lang.String |
constructRegexpClause(java.lang.String column,
java.lang.String regularExpression,
boolean caseInsensitive)
Construct a regular-expression match clause.
|
java.lang.String |
constructSubstringClause(java.lang.String column,
java.lang.String regularExpression,
boolean caseInsensitive)
Construct a regular-expression substring clause.
|
void |
createUserAndDatabase(java.lang.String adminUserName,
java.lang.String adminPassword,
StringSet invalidateKeys)
Create user and database.
|
void |
dropUserAndDatabase(java.lang.String adminUserName,
java.lang.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).
|
protected void |
explainQuery(java.lang.String query,
java.util.List params)
Abstract method for explaining a query
|
int |
findConjunctionClauseMax(ClauseDescription[] otherClauseDescriptions) |
StringSet |
getAllTables(StringSet cacheKeys,
java.lang.String queryClass)
Get a database's tables.
|
java.lang.String |
getDatabaseCacheKey()
Get the database general cache key.
|
protected static java.lang.String |
getDatabaseString(IThreadContext tc,
java.lang.String databaseName) |
protected static java.lang.String |
getFullDatabasePath(java.lang.String databaseName) |
protected static java.lang.String |
getJDBCString(IThreadContext tc,
java.lang.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.
|
java.util.Map<java.lang.String,IndexDescription> |
getTableIndexes(java.lang.String tableName,
StringSet cacheKeys,
java.lang.String queryClass)
Get a table's indexes.
|
java.util.Map<java.lang.String,ColumnDescription> |
getTableSchema(java.lang.String tableName,
StringSet cacheKeys,
java.lang.String queryClass)
Get a table's schema.
|
int |
getWindowedReportMaxRows()
For windowed report queries, e.g.
|
protected void |
initializeConnection(java.sql.Connection connection)
Initialize the connection (for HSQLDB).
|
protected java.lang.String |
mapLabelName(java.lang.String rawLabelName)
Abstract method for mapping a column name from resultset
|
protected static java.lang.String |
mapType(java.lang.String inputType)
Map a standard type into a postgresql type.
|
void |
openDatabase()
Initialize.
|
void |
performAddIndex(java.lang.String indexName,
java.lang.String tableName,
IndexDescription description)
Add an index to a table.
|
void |
performAlter(java.lang.String tableName,
java.util.Map<java.lang.String,ColumnDescription> columnMap,
java.util.Map<java.lang.String,ColumnDescription> columnModifyMap,
java.util.List<java.lang.String> columnDeleteList,
StringSet invalidateKeys)
Perform a table alter operation.
|
void |
performCreate(java.lang.String tableName,
java.util.Map<java.lang.String,ColumnDescription> columnMap,
StringSet invalidateKeys)
Perform a table creation operation.
|
void |
performDelete(java.lang.String tableName,
java.lang.String whereClause,
java.util.List whereParameters,
StringSet invalidateKeys)
Perform a delete operation.
|
void |
performDrop(java.lang.String tableName,
StringSet invalidateKeys)
Perform a table drop operation.
|
void |
performInsert(java.lang.String tableName,
java.util.Map<java.lang.String,java.lang.Object> parameterMap,
StringSet invalidateKeys)
Perform an insert operation.
|
void |
performModification(java.lang.String query,
java.util.List params,
StringSet invalidateKeys)
Perform a general database modification query.
|
IResultSet |
performQuery(java.lang.String query,
java.util.List params,
StringSet cacheKeys,
java.lang.String queryClass)
Perform a general "data fetch" query.
|
IResultSet |
performQuery(java.lang.String query,
java.util.List params,
StringSet cacheKeys,
java.lang.String queryClass,
int maxResults,
ILimitChecker returnLimit)
Perform a general "data fetch" query.
|
IResultSet |
performQuery(java.lang.String query,
java.util.List params,
StringSet cacheKeys,
java.lang.String queryClass,
int maxResults,
ResultSpecification resultSpec,
ILimitChecker returnLimit)
Perform a general "data fetch" query.
|
void |
performRemoveIndex(java.lang.String indexName,
java.lang.String tableName)
Remove an index.
|
void |
performUpdate(java.lang.String tableName,
java.util.Map<java.lang.String,java.lang.Object> parameterMap,
java.lang.String whereClause,
java.util.List whereParameters,
StringSet invalidateKeys)
Perform an update operation.
|
protected static void |
recursiveDelete(java.io.File f) |
void |
reindexTable(java.lang.String tableName)
Reindex a table.
|
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(java.io.File f) |
protected void |
startATransaction()
Abstract method to start a transaction
|
cleanupParameters, constructIndexHintClause, constructOffsetLimitClause, execute, executeQuery, executeUncachedQuery, executeViaThread, findColumn, getBLOB, getCurrentTransactionType, getData, getDatabaseName, getObject, getSleepAmt, getTransactionID, internalTransactionBegin, interruptCleanup, isBinary, isBLOB, loadPS, mapLookupName, noteModifications, noteModificationsNoTransactions, performCommit, prepareForDatabaseCreate, sleepFor, synchronizeTransactions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
constructIndexHintClause, constructOffsetLimitClause, getDatabaseName, getSleepAmt, getTransactionID, noteModifications, performCommit, sleepFor
public static final java.lang.String _rcsid
public static final java.lang.String databasePathProperty
public static final java.lang.String databaseProtocolProperty
public static final java.lang.String databaseServerProperty
public static final java.lang.String databasePortProperty
public static final java.lang.String databaseInstanceProperty
protected java.lang.String cacheKey
protected int serializableDepth
protected boolean isRemote
protected java.lang.String schemaNameForQueries
protected int depthCount
protected boolean inTransaction
protected int desiredTransactionType
public DBInterfaceHSQLDB(IThreadContext tc, java.lang.String databaseName, java.lang.String userName, java.lang.String password) throws ManifoldCFException
ManifoldCFException
protected static java.lang.String getJDBCString(IThreadContext tc, java.lang.String databaseName) throws ManifoldCFException
ManifoldCFException
protected static java.lang.String getDatabaseString(IThreadContext tc, java.lang.String databaseName) throws ManifoldCFException
ManifoldCFException
protected static java.lang.String getFullDatabasePath(java.lang.String databaseName) throws ManifoldCFException
ManifoldCFException
protected void initializeConnection(java.sql.Connection connection) throws ManifoldCFException
initializeConnection
in class Database
connection
- is the JDBC connection.ManifoldCFException
public void openDatabase() throws ManifoldCFException
openDatabase
in interface IDBInterface
ManifoldCFException
public void closeDatabase() throws ManifoldCFException
closeDatabase
in interface IDBInterface
ManifoldCFException
public java.lang.String getDatabaseCacheKey()
getDatabaseCacheKey
in interface IDBInterface
public void performInsert(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> parameterMap, StringSet invalidateKeys) throws ManifoldCFException
performInsert
in interface IDBInterface
tableName
- 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.ManifoldCFException
public void performUpdate(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> parameterMap, java.lang.String whereClause, java.util.List whereParameters, StringSet invalidateKeys) throws ManifoldCFException
performUpdate
in interface IDBInterface
tableName
- 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.ManifoldCFException
public void performDelete(java.lang.String tableName, java.lang.String whereClause, java.util.List whereParameters, StringSet invalidateKeys) throws ManifoldCFException
performDelete
in interface IDBInterface
tableName
- 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.ManifoldCFException
public void performCreate(java.lang.String tableName, java.util.Map<java.lang.String,ColumnDescription> columnMap, StringSet invalidateKeys) throws ManifoldCFException
performCreate
in interface IDBInterface
tableName
- 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.ManifoldCFException
protected static void appendDescription(java.lang.StringBuilder queryBuffer, java.lang.String columnName, ColumnDescription cd, boolean forceNull)
public void performAlter(java.lang.String tableName, java.util.Map<java.lang.String,ColumnDescription> columnMap, java.util.Map<java.lang.String,ColumnDescription> columnModifyMap, java.util.List<java.lang.String> columnDeleteList, StringSet invalidateKeys) throws ManifoldCFException
performAlter
in interface IDBInterface
tableName
- 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.ManifoldCFException
protected static java.lang.String mapType(java.lang.String inputType)
inputType
- is the input type.public void addTableIndex(java.lang.String tableName, boolean unique, java.util.List<java.lang.String> columnList) throws ManifoldCFException
addTableIndex
in interface IDBInterface
tableName
- 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.ManifoldCFException
public void performAddIndex(java.lang.String indexName, java.lang.String tableName, IndexDescription description) throws ManifoldCFException
performAddIndex
in interface IDBInterface
tableName
- 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.ManifoldCFException
public void performRemoveIndex(java.lang.String indexName, java.lang.String tableName) throws ManifoldCFException
performRemoveIndex
in interface IDBInterface
indexName
- is the name of the index to remove.tableName
- is the table the index belongs to.ManifoldCFException
public void analyzeTable(java.lang.String tableName) throws ManifoldCFException
analyzeTable
in interface IDBInterface
tableName
- is the name of the table to analyze/calculate statistics for.ManifoldCFException
public void reindexTable(java.lang.String tableName) throws ManifoldCFException
reindexTable
in interface IDBInterface
tableName
- is the name of the table to rebuild indexes for.ManifoldCFException
public void performDrop(java.lang.String tableName, StringSet invalidateKeys) throws ManifoldCFException
performDrop
in interface IDBInterface
tableName
- is the name of the table to drop.invalidateKeys
- are the cache keys that should be invalidated, if any.ManifoldCFException
public void createUserAndDatabase(java.lang.String adminUserName, java.lang.String adminPassword, StringSet invalidateKeys) throws ManifoldCFException
createUserAndDatabase
in interface IDBInterface
adminUserName
- is the admin user name.adminPassword
- is the admin password.invalidateKeys
- are the cache keys that should be invalidated, if any.ManifoldCFException
public void dropUserAndDatabase(java.lang.String adminUserName, java.lang.String adminPassword, StringSet invalidateKeys) throws ManifoldCFException
dropUserAndDatabase
in interface IDBInterface
adminUserName
- is the admin user name.adminPassword
- is the admin password.invalidateKeys
- are the cache keys that should be invalidated, if any.ManifoldCFException
protected static void recursiveDelete(java.io.File f)
protected static void singleDelete(java.io.File f)
protected ManifoldCFException reinterpretException(ManifoldCFException theException)
theException
- is the exception to reinterpretpublic void performModification(java.lang.String query, java.util.List params, StringSet invalidateKeys) throws ManifoldCFException
performModification
in interface IDBInterface
query
- is the query string.params
- are the parameterized values, if needed.invalidateKeys
- are the cache keys to invalidate.ManifoldCFException
public java.util.Map<java.lang.String,ColumnDescription> getTableSchema(java.lang.String tableName, StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
getTableSchema
in interface IDBInterface
tableName
- 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.ManifoldCFException
public java.util.Map<java.lang.String,IndexDescription> getTableIndexes(java.lang.String tableName, StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
getTableIndexes
in interface IDBInterface
tableName
- 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.ManifoldCFException
protected void addIndex(java.util.Map rval, java.lang.String indexName, boolean isUnique, java.util.List<java.lang.String> indexColumns)
public StringSet getAllTables(StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
getAllTables
in interface IDBInterface
cacheKeys
- are the cache keys for the query, or null.queryClass
- is the name of the query class, or null.ManifoldCFException
public IResultSet performQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
performQuery
in interface IDBInterface
query
- 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.ManifoldCFException
public IResultSet performQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass, int maxResults, ILimitChecker returnLimit) throws ManifoldCFException
performQuery
in interface IDBInterface
query
- 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.ManifoldCFException
public IResultSet performQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass, int maxResults, ResultSpecification resultSpec, ILimitChecker returnLimit) throws ManifoldCFException
performQuery
in interface IDBInterface
query
- 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.ManifoldCFException
public java.lang.String constructIndexOrderByClause(java.lang.String[] fieldNames, boolean direction)
constructIndexOrderByClause
in interface IDBInterface
constructIndexOrderByClause
in class Database
fieldNames
- are the names of the fields in the index that is to be used.direction
- is a boolean describing the sorting order of the first term.public java.lang.String constructDoubleCastClause(java.lang.String value)
constructDoubleCastClause
in interface IDBInterface
value
- is the value to be cast.public java.lang.String constructCountClause(java.lang.String column)
constructCountClause
in interface IDBInterface
column
- is the column string to be counted.public java.lang.String constructRegexpClause(java.lang.String column, java.lang.String regularExpression, boolean caseInsensitive)
constructRegexpClause
in interface IDBInterface
column
- 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 java.lang.String constructSubstringClause(java.lang.String column, java.lang.String regularExpression, boolean caseInsensitive)
constructSubstringClause
in interface IDBInterface
column
- 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 java.lang.String constructOffsetLimitClause(int offset, int limit, boolean afterOrderBy)
constructOffsetLimitClause
in interface IDBInterface
constructOffsetLimitClause
in class Database
offset
- 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 java.lang.String constructDistinctOnClause(java.util.List outputParameters, java.lang.String baseQuery, java.util.List baseParameters, java.lang.String[] distinctFields, java.lang.String[] orderFields, boolean[] orderFieldsAscending, java.util.Map<java.lang.String,java.lang.String> otherFields)
constructDistinctOnClause
in interface IDBInterface
outputParameters
- 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 findConjunctionClauseMax(ClauseDescription[] otherClauseDescriptions)
findConjunctionClauseMax
in interface IDBInterface
findConjunctionClauseMax
in class Database
public java.lang.String buildConjunctionClause(java.util.List outputParameters, ClauseDescription[] clauseDescriptions)
buildConjunctionClause
in interface IDBInterface
buildConjunctionClause
in class Database
public int getMaxInClause()
getMaxInClause
in interface IDBInterface
getMaxInClause
in class Database
public int getMaxOrClause()
getMaxOrClause
in interface IDBInterface
public int getWindowedReportMaxRows()
getWindowedReportMaxRows
in interface IDBInterface
public void beginTransaction() throws ManifoldCFException
beginTransaction
in interface IDBInterface
ManifoldCFException
public void beginTransaction(int transactionType) throws ManifoldCFException
beginTransaction
in interface IDBInterface
beginTransaction
in class Database
transactionType
- is the kind of transaction desired.ManifoldCFException
public void signalRollback()
signalRollback
in interface IDBInterface
signalRollback
in class Database
public void endTransaction() throws ManifoldCFException
endTransaction
in interface IDBInterface
endTransaction
in class Database
ManifoldCFException
protected void startATransaction() throws ManifoldCFException
startATransaction
in class Database
ManifoldCFException
protected void commitCurrentTransaction() throws ManifoldCFException
commitCurrentTransaction
in class Database
ManifoldCFException
protected void rollbackCurrentTransaction() throws ManifoldCFException
rollbackCurrentTransaction
in class Database
ManifoldCFException
protected void explainQuery(java.lang.String query, java.util.List params) throws ManifoldCFException
explainQuery
in class Database
ManifoldCFException
protected java.lang.String mapLabelName(java.lang.String rawLabelName)
mapLabelName
in class Database