|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sibvisions.rad.persist.jdbc.DBAccess
public class DBAccess
The DBAccess
is the implementation for most used SQL databases.
Standard ANSI SQL Databases are anyways supported.
Its used to read/write data between the storage and the DataBook/DataPage
.
It has database type specific implementations.
Example:
DBAccess dba = new DBAccess();
// set connect properties
dba.setDriver("org.hsqldb.jdbcDriver");
dba.setUrl("jdbc:hsqldb:file:testdbs/test/testdb");
dba.setUsername("sa");
dba.setPassword("");
Properties pDBProperties = new Properties();
pDBProperties.put("shutdown", true);
dba.setDBProperties(pDBProperties);
// open
dba.open();
To get Database independent DBAccess, it is better to use:
DBAccess dba = DBAccess.getDBAccess("jdbc:hsqldb:file:testdbs/test/testdb");
// insert data into test table
PreparedStatement psPreparedStatement = dba.getPreparedStatement(
"insert into test (id, name) values(?,?)", false);
psPreparedStatement.setInt(1, 1);
psPreparedStatement.setString(2, "projectX");
dba.executeUpdate(psPreparedStatement);
// select data from test table
psPreparedStatement = dba.getPreparedStatement("select * from test", false);
ResultSet rs = dba.executeQuery(psPreparedStatement);
while (rs.next())
{
System.out.println(rs.getInt("id") + "," + rs.getString("name"));
}
IDBAccess
,
RemoteDataBook
Nested Class Summary | |
---|---|
static class |
DBAccess.BlobFileHandle
The DBAccess.BlobFileHandle is a simple IFileHandle implementation
that stores a Blob and allows to retrieve it again. |
static class |
DBAccess.ParameterizedStatement
The DBAccess.ParameterizedStatement is a simple, mutable container for
a statement and its values. |
Field Summary | |
---|---|
static int |
BFILE
A jdbc BFILE DB column data type constant. |
static int |
LONGNVARCHAR
A jdbc VARCHAR DB column data type constant. |
static int |
NCHAR
A jdbc VARCHAR DB column data type constant. |
static int |
NCLOB
A jdbc BLOB DB column data type constant. |
static int |
NVARCHAR
A jdbc VARCHAR DB column data type constant. |
static java.lang.String |
QUOTE
JVx generell DB quote character. will be translated in the DB specific. |
static int |
SQLXML
A jdbc XML DB column data type constant. |
static int |
TIMESTAMPWITHLOCALTIMEZONE
A jdbc timestamp DB column data type constant. |
static int |
TIMESTAMPWITHTIMEZONE
A jdbc timestamp DB column data type constant. |
Constructor Summary | |
---|---|
DBAccess()
Constructs a new DBAccess Object. |
Method Summary | |
---|---|
static void |
clearMetaData()
Clears the meta data cache. |
static void |
clearMetaData(java.lang.String pApplicationName)
Clears the meta data cache for the given application. |
void |
close()
Closes the database Connection and releases all memory. |
void |
commit()
Commits the DB transaction. |
protected void |
commitOrRollbackBeforeClose()
Calls commit or rollback before closing the connection. |
protected java.lang.Object |
convertDatabaseSpecificObjectToValue(ServerColumnMetaData pColumnMetaData,
java.lang.Object pObject)
Enables the database specific implementation to handle/convert special objects. |
protected java.lang.Object |
convertValueToDatabaseSpecificObject(java.lang.Object pValue)
Converts an object to a standard value for the specific database. |
static java.lang.String |
createIdentifier(java.lang.Object... pIdentifier)
Creates an identifier string from the given parameter. |
protected java.lang.String |
createReplace(java.lang.String pSource,
java.lang.String pOld,
java.lang.String pNew)
Create an DB specific replace command, which replacs in the pSource all pOld to pNew. |
protected ServerColumnMetaData |
createServerColumnMetaData(java.sql.ResultSetMetaData pResultSetMetaData,
int pResultSetColumnIndex,
java.lang.String pQueryColumn)
Creates the ServerColumnMetaData based on ResultSetMetaData . |
protected java.lang.String |
createWhereColumn(ServerMetaData pServerMetaData,
CompareCondition pCompare,
java.lang.String pColumnName)
Creates the where column. |
protected java.lang.String |
createWhereParam(ServerMetaData pServerMetaData,
CompareCondition pCompare)
Creates the where parameter. |
protected static void |
debug(java.lang.Object... pInfo)
Logs debug information. |
void |
delete(java.lang.String pWriteBackTable,
ServerMetaData pServerMetaData,
java.lang.Object[] pDelete)
Deletes the specified row. |
protected boolean |
detectModified()
Detects if a transaction is open directly in the database. |
protected static void |
error(java.lang.Object... pInfo)
Logs error information. |
EventHandler<IConfigureConnectionListener> |
eventConfigureConnection()
The event configure connection is always dispatched, when a new connection is used by this DBAccess. |
EventHandler<IUnconfigureConnectionListener> |
eventUnconfigureConnection()
The event configure connection is always dispatched, when a new connection is used by this DBAccess. |
java.lang.Object |
executeFunction(java.lang.String pFunctionName,
int pReturnType,
java.lang.Object... pParameters)
Executes a DB function with the specified parameters and return the result. |
java.lang.Object |
executeFunction(java.lang.String pFunctionName,
OutParam pReturnOutParam,
java.lang.Object... pParameters)
Executes a DB function with the specified parameters and return the result. |
void |
executeProcedure(java.lang.String pProcedureName,
java.lang.Object... pParameters)
Executes a DB procedure with the specified parameters. |
java.util.List<Bean> |
executeQuery(java.lang.String pStatement,
java.lang.Object... pParameters)
Executes a SQL query as prepared statement. |
java.util.List<java.lang.Object> |
executeSql(java.lang.String pStatement,
java.lang.Object... pParameters)
Executes a SQL command as prepared statement. |
protected java.util.List<java.lang.Object> |
executeSqlMulti(java.lang.String pStatement,
int pResultColumn,
java.lang.Object... pParameters)
Executes a SQL command as prepared statement. |
int |
executeStatement(java.lang.String pStatement,
java.lang.Object... pParameters)
Executes a DDL or DML Statement. |
java.util.List<java.lang.Object[]> |
fetch(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereCondition,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the List of fetched rows (as List of Object[]) for the specified query tables and parameters. |
java.util.List<java.lang.Object[]> |
fetch(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereCondition,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount,
boolean pAllowLazyFetch)
Returns the List of fetched rows (as List of Object[]) for the specified query tables and parameters. |
java.util.List<java.lang.Object[]> |
fetch(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereCondition,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
java.lang.String pOrderByClause,
int pFromRow,
int pMinimumRowCount)
Mostly same as fetch(ServerMetaData, String, String[], String, ICondition, String, String, SortDefinition, int, int) . |
java.util.List<java.lang.Object[]> |
fetch(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereCondition,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
java.lang.String pOrderByClause,
int pFromRow,
int pMinimumRowCount,
boolean pAllowLazyFetch)
Mostly same as fetch(ServerMetaData, String, String[], String, ICondition, String, String, SortDefinition, int, int) . |
protected ICondition |
findAndCreateReducedCondition(ICondition pCondition,
java.util.Set<java.lang.String> pNames,
java.util.Map<java.lang.String,CompareCondition> pNameToCondition)
Finds and removes the ICondition with the given column names from
the given ICondition . |
protected void |
findNamedParameters(java.lang.String pStatement,
java.util.List<java.lang.String> pNameList)
Finds all named parameters in the given statement and adds the names to the given List . |
protected void |
fireEventConfigureConnection()
Fires the event configureConnection. |
protected void |
fireEventUnconfigureConnection()
Fires the event unconfigureConnection. |
protected java.sql.SQLException |
formatSQLException(java.sql.SQLException pSqlException)
Adds the SQL Error Code into the message of the SQL Exception. |
protected java.sql.SQLException |
formatSQLException(java.sql.SQLException pSqlException,
java.lang.String pMessage,
java.lang.String pCode)
Adds the SQL Error Code into the message of the SQL Exception. |
java.util.Map<java.lang.String,java.lang.Object[]> |
getAllowedValues(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Gets the allowed values from a specific table. |
protected java.util.Map<java.lang.String,java.lang.Object[]> |
getAllowedValuesIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Gets the allowed values from a specific table. |
static TranslationMap |
getAutomaticLinkColumnNameTranslation()
Returns the TranslationMap for the automatic link column name custom Translation. its used in the getAutomaticLinkColName(ForeignKey pForeignKey) to change the column, thats determined. |
java.lang.String |
getCloseQuoteCharacter()
Gets the database specific quote character. |
ServerColumnMetaData[] |
getColumnMetaData(java.lang.String pFromClause,
java.lang.String[] pQueryColumns,
java.lang.String pBeforeQueryColumns,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause)
Returns the meta data information for the specified query, and configures all columns with defaults. |
IColumnMetaDataCreator |
getColumnMetaDataCreator()
Gets the column meta data creator for custom column meta data support. |
protected ServerColumnMetaData[] |
getColumnMetaDataIntern(java.lang.String pFromClause,
java.lang.String[] pQueryColumns,
java.lang.String pBeforeQueryColumns,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause)
Returns the meta data information for the specified query, and configures all columns with defaults. |
protected java.lang.String |
getColumnName(java.sql.ResultSetMetaData pMetaData,
int pColumn)
Gets the column name from the given resultset metadata. |
java.sql.Connection |
getConnection()
Returns the connection to the database. |
protected java.sql.Connection |
getConnectionIntern()
Returns the connection to the database. |
IConnectionPool |
getConnectionPool()
Returns the conncetion to the database. |
protected java.lang.String |
getDatabaseSpecificLockStatement(java.lang.String pWriteBackTable,
ServerMetaData pServerMetaData,
ICondition pPKFilter)
Returns the database specific statement to lock the specified row in the database. |
static DBAccess |
getDBAccess(java.sql.Connection pConnection)
Gets the suitable DBAccess for the given external connection. |
static DBAccess |
getDBAccess(DBCredentials pCredentials)
Gets the suitable DBAccess for the given DBCredentials . |
static DBAccess |
getDBAccess(IConnectionPool pConnectionPool)
Gets the suitable DBAccess for the given connection pool. |
static DBAccess |
getDBAccess(java.lang.String pJdbcUrl)
Gets the suitable DBAcces for the given JdbcUrl. |
static DBAccess |
getDBAccess(java.lang.String pJdbcUrl,
java.lang.String pOptionalUserName,
java.lang.String pOptionalPassword)
Gets the suitable DBAcces for the given JdbcUrl. |
java.util.Properties |
getDBProperties()
Returns the DB specific initial parameters for the Connection creation. |
java.lang.String |
getDBProperty(java.lang.String pName)
Gets the value for a specific database property. |
java.lang.Object[] |
getDefaultAllowedValues(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable,
ServerColumnMetaData pMetaData)
Gets the default allowed values for a given column from a given table. |
static long |
getDefaultCursorCacheTimeout()
Gets the default cursor cache timeout in ms. |
static long |
getDefaultLargeObjectLimit()
Gets the default value for the limit for what is considered a "large object". |
java.lang.String |
getDefaultSchema()
Gets the default schema name, if it was set manually. |
java.util.Map<java.lang.String,java.lang.Object> |
getDefaultValues(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Gets all default column values of a specific table. |
protected java.util.Map<java.lang.String,java.lang.Object> |
getDefaultValuesIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Gets all default column values of a specific table. |
protected int |
getDiscardRowCount(int pFromRow,
int pMinimumRowCount)
Gets how many rows should be discarded based on the given values. |
java.lang.String |
getDriver()
Gets the database driver name as String . |
java.util.List<ForeignKey> |
getForeignKeys(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Returns all Foreign Keys for the specified table. |
protected java.util.List<ForeignKey> |
getForeignKeysIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Returns all Foreign Keys for the specified table. |
protected java.lang.String |
getIdentifier()
Gets the identifier for this DBAccess. |
long |
getLargeObjectLimit()
Gets the value for the limit for what is considered a "large object". |
int |
getMaxColumnLength()
Returns the maximum allowed column length. |
int |
getMaxTime()
Returns the maximum time in miliseconds to use, to try to fetch all rows. reduce open cursors, and increase performance. |
MetaDataCacheOption |
getMetaDataCacheOption()
Gets the metadata cache option for this instance. |
protected java.lang.String |
getMetaDataWhereClause()
Gets the where clause for metadata detection. |
protected java.lang.Object |
getObjectFromResultSet(java.sql.ResultSet pResultSet,
int pIndex)
Gets the Object from the result set, and ensures that numbers are always returned as BigDecimal, and dates as Timestamp. |
protected java.lang.Object |
getObjectFromResultSet(java.sql.ResultSet pResultSet,
int pIndex,
ServerColumnMetaData pColumnMetaData)
Gets the Object from the result set, and ensures that numbers are always returned as BigDecimal, and dates as Timestamp. |
java.lang.String |
getOpenQuoteCharacter()
Gets the database specific open quote character. |
protected java.lang.Object[] |
getParameter(ICondition pCondition)
Returns the parameters used for this ICondition . |
protected java.lang.Object[] |
getParameter(ICondition pCondition,
int pFromRow,
int pMinimumRowCount)
Returns the parameters used for this ICondition . |
DBAccess.ParameterizedStatement |
getParameterizedSelectStatement(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
java.lang.String pOrderByClause,
int pFromRow,
int pMinimumRowCount)
Creates the DBAccess.ParameterizedStatement and returns it. |
java.lang.String |
getPassword()
Sets the password to use for the connection to the database. |
java.sql.PreparedStatement |
getPreparedStatement(java.lang.String pSqlStatement)
Return a PreparedStatement for the given SQL statement. |
protected java.sql.PreparedStatement |
getPreparedStatement(java.lang.String pSqlStatement,
boolean pReturnGeneratedKeys)
Return a PreparedStatement for the given SQL statement. |
Key |
getPrimaryKey(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
It's gets all Primary Key columns and return it as String[]. |
protected Key |
getPrimaryKeyIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
It's gets all Primary Key columns and return it as String[]. |
int |
getQueryTimeout()
Gets the query time out. |
protected java.lang.String |
getRealQueryColumnName(java.lang.String pQueryColumn)
Gets the real query column name without alias. |
java.lang.String |
getSelectStatement(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
java.lang.String pOrderByClause)
It initialize the select for a specified storage unit and return the SELECT statement. |
java.lang.String |
getSelectStatement(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
java.lang.String pOrderByClause,
int pFromRow,
int pMinimumRowCount)
It initialize the select for a specified storage unit and return the SELECT statement. |
protected java.lang.String |
getSQL(ServerMetaData pServerMetaData,
ICondition pCondition,
boolean pUseRealColumnName)
Returns the ANSI SQL String for this ICondition . |
java.lang.String |
getTableForSynonym(java.lang.String pSynomyn)
Returns the full qualified table name incl. schema/catalog/db link for the given synonym. |
protected java.lang.String |
getTableForSynonymIntern(java.lang.String pSynomyn)
Returns the full qualified table name incl. schema/catalog/db link for the given synonym. |
TableInfo |
getTableInfo(java.lang.String pWriteBackTable)
Returns the meta data information for the specified query, and configures all columns with defaults. |
protected TableInfo |
getTableInfoIntern(java.lang.String pWriteBackTable)
Returns the meta data information for the specified query, and configures all columns with defaults. |
int |
getTransactionTimeout()
Gets the transaction time out. |
java.util.List<Key> |
getUniqueKeys(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
It gets all columns for each Unique Key and return it. |
protected java.util.List<Key> |
getUniqueKeysIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
It gets all columns for each Unique Key and return it. |
java.lang.String |
getUrl()
Gets the jdbc url String for this database. |
java.lang.String |
getUsername()
Gets the user name to connect with. |
protected java.lang.String |
getWhereClause(ServerMetaData pServerMetaData,
ICondition pFilter,
java.lang.String pWhereClause,
boolean pUsePrefix)
Returns the WHERE clause for a UPDATE, DELETE or SELECT statement specified with a Filter . |
protected static void |
info(java.lang.Object... pInfo)
Logs information. |
void |
initializeColumnMetaData(java.sql.ResultSetMetaData pResultSetMetaData,
int pResultSetColumnIndex,
ColumnMetaData pColumnMetaData)
Initilizes the ColumnMetaData with the given ResultSetMetaData . |
protected void |
initializeDataType(java.sql.ResultSetMetaData pResultSetMetaData,
int pResultSetColumnIndex,
ColumnMetaData pColumnMetaData)
Initializes the datatype data of the ColumnMetaData with the given ResultSetMetaData . |
protected ServerColumnMetaData |
initializeServerColumnMetaData(java.sql.ResultSetMetaData pResultSetMetaData,
int pResultSetColumnIndex,
java.lang.String pQueryColumn,
ServerColumnMetaData pServerColumnMetaData)
Fills data into the ServerColumnMetaData based on ResultSetMetaData . |
java.lang.Object[] |
insert(java.lang.String pWriteBackTable,
ServerMetaData pServerMetaData,
java.lang.Object[] pNewDataRow)
Returns the newly inserted row from the write back table. |
protected java.lang.Object[] |
insertAnsiSQL(java.lang.String pWriteBackTable,
java.lang.String pInsertStatement,
ServerMetaData pServerMetaData,
java.lang.Object[] pNewDataRow,
java.lang.String pDummyColumn)
Returns the newly inserted row from a Ansi SQL Database. |
protected java.lang.Object[] |
insertDatabaseSpecific(java.lang.String pWriteBackTable,
java.lang.String pInsertStatement,
ServerMetaData pServerMetaData,
java.lang.Object[] pNewDataRow,
java.lang.String pDummyColumn)
Returns the newly inserted row from a Database specific insert statement. |
boolean |
isAutoCommit()
Gets whether auto-commit is en-/disabled. |
boolean |
isAutoQuote(java.lang.String pName)
It returns true if this name should be automated quoted. |
boolean |
isConnectionPoolEnabled()
Gets the method of connection pool usage. |
static boolean |
isJdbc(java.lang.String pUrl)
Gets whether the given URL is a JDBC resource. |
protected static boolean |
isLogEnabled(ILogger.LogLevel pLevel)
Gets whether the given log level is enabled. |
protected boolean |
isMetaDataCacheEnabled()
Gets whether the meta data cache should be used. |
boolean |
isModified()
Gets whether the database access is modified. |
boolean |
isOpen()
Returns true, if the database is still open. |
boolean |
isReleaseConnectionPending()
True, if there is a release connection task waiting. |
boolean |
isTypeEqual(ServerColumnMetaData pServerColumnMetaData,
CompareCondition pCompare)
Check if the Type of the column and the value to compare is equal. |
void |
lockRow(java.lang.String pWriteBackTable,
ServerMetaData pServerMetaData,
ICondition pPKFilter)
It locks the specified row in the storage. |
protected int |
lockRowInternal(java.lang.String pWriteBackTable,
ServerMetaData pServerMetaData,
ICondition pPKFilter)
It locks the current row and return how many rows are affected. |
void |
open()
It opens the database and stores the Connection object. |
protected void |
prepareConnection(java.sql.Connection pConnection)
Prepares the given Connection for being used by this
DBAccess . |
java.lang.String |
quote(java.lang.String pName)
Quotes a named DB object with our internal quote character, if it should be quoted in this database. |
java.lang.String |
quoteAllways(java.lang.String pName)
Quotes a named DB object with the JVx DB QUOTE character. |
static void |
registerDBAccessClass(java.lang.String pJdbcUrlPrefix,
java.lang.Class<? extends DBAccess> pClass)
Registers the Class for the jdbc url prefix. |
void |
releaseConnection()
Returns the connection to the connection pool. |
protected void |
releaseConnectionIntern()
Returns the connection to the connection pool. |
java.lang.String |
removeDBSpecificQuotes(java.lang.String pName)
Removes the DB specific quotes of a named DB object. |
static java.lang.String |
removeQuotes(java.lang.String pName)
Removes the JVx DB Quotes of a named DB object. |
void |
rollback()
Rollback the DB transaction. |
void |
setAutoCommit(boolean pEnable)
Sets auto-commit state. |
static void |
setAutomaticLinkColumnNameTranslation(TranslationMap pTranslationMap)
Sets the TranslationMap for the automatic link column name custom Translation. its used in the getAutomaticLinkColName(ForeignKey pForeignKey) to change the column, thats determined. |
void |
setColumnMetaDataCreator(IColumnMetaDataCreator pColumnMetaDataCreator)
Sets the column meta data creator for custom column meta data support. |
void |
setColumnMetaDataCreator(java.lang.Object pListener,
java.lang.String pMethodName)
Sets the column meta data creator for custom column meta data support. |
protected int |
setColumnsToStore(java.sql.PreparedStatement pInsert,
ServerColumnMetaData[] pServerColumnMetaData,
int[] iaWriteables,
java.lang.Object[] pNew,
java.lang.Object[] pOld)
Sets the values of all changed columns to store from the value Object[]s into the PreparedStatement and returns the last used parameter index. |
protected void |
setConnection(java.sql.Connection pConnection)
Sets the internal connection to the database. |
protected void |
setConnectionPool(IConnectionPool pConnectionPool)
Sets the internal connection pool to the database. |
void |
setConnectionPoolEnabled(boolean pConnectionPoolEnabled)
Sets the method of connection pool usage. |
void |
setDBProperties(java.util.Properties pProperties)
Sets DB specific initial parameters for the Connection creation. |
void |
setDBProperty(java.lang.String pName,
java.lang.String pValue)
Sets a specific database property. |
static void |
setDefaultCursorCacheTimeout(long pDefaultCursorCacheTimeout)
Sets the default cursor cache timeout in ms. |
static void |
setDefaultLargeObjectLimit(long pDefaultLargeObjectLimit)
Sets the default value for the limit for what is considered a "large object". |
void |
setDefaultSchema(java.lang.String pSchema)
Sets the user-defined default schema. |
void |
setDriver(java.lang.String pDriver)
Sets the database driver name as String . |
void |
setLargeObjectLimit(long pLargeObjectLimit)
Sets the value for the limit for what is considered a "large object". |
void |
setMaxTime(int pMaxTime)
Sets the maximum time in miliseconds to use, to try to fetch all rows. reduce open cursors, and increase performance. |
void |
setMetaDataCacheOption(MetaDataCacheOption pOption)
Sets the metadata cache option for this instance. |
protected void |
setModified(java.lang.Boolean pModified)
Sets modified state of the connection. |
void |
setPassword(java.lang.String pPassword)
Sets the password to use for the connection to the database. |
void |
setQueryTimeout(int pQueryTimeout)
Sets the query time out in seconds. |
protected void |
setQuoteCharacters(java.lang.String pOpen,
java.lang.String pClose)
Sets the database specific quote characters. |
void |
setTransactionTimeout(int pTransactionTimeout)
Sets the transaction time out. |
void |
setUrl(java.lang.String pUrl)
Sets the url String for this database. |
void |
setUsername(java.lang.String pUsername)
Sets the user name to connect with. |
protected java.lang.String[] |
splitSchemaTable(java.lang.String pFromClause)
Separates the schema and table from the given from clause. |
boolean |
supportsGetGeneratedKeys()
Returns if this Database specific supports generated keys. |
java.lang.String |
toString()
|
protected java.lang.Object |
translateDefaultValue(java.lang.String pColumnName,
int pDataType,
java.lang.String pDefaultValue)
Translates a default value from a column to the datatype object. |
java.lang.String |
translateQuotes(java.lang.String pStatement)
It replaces all JVx quotes with the database specific quote. |
protected java.lang.Object |
translateValue(int pDataType,
java.lang.String pValue)
Translates an object value to the datatype object. |
java.lang.Object[] |
update(java.lang.String pWriteBackTable,
ServerMetaData pServerMetaData,
java.lang.Object[] pOld,
java.lang.Object[] pNew)
Return the updated row. |
int |
updateAnsiSQL(java.lang.String pWriteBackTable,
java.lang.String sUpdateStatement,
ServerMetaData pServerMetaData,
java.lang.Object[] pOld,
java.lang.Object[] pNew,
ICondition pPKFilter)
Updates the specified row and return the count of affected rows. |
int |
updateDatabaseSpecific(java.lang.String pWriteBackTable,
java.lang.String sUpdateStatement,
ServerMetaData pServerMetaData,
java.lang.Object[] pOld,
java.lang.Object[] pNew,
ICondition pPKFilter)
Updates the specified row and returns the count of affected rows. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int NCHAR
public static final int NVARCHAR
public static final int LONGNVARCHAR
public static final int BFILE
public static final int TIMESTAMPWITHTIMEZONE
public static final int TIMESTAMPWITHLOCALTIMEZONE
public static final int SQLXML
public static final int NCLOB
public static final java.lang.String QUOTE
Constructor Detail |
---|
public DBAccess()
Method Detail |
---|
public static DBAccess getDBAccess(java.lang.String pJdbcUrl) throws DataSourceException
pJdbcUrl
- the JdbcUrl.
DataSourceException
- if the instance name is unknown or the DBAccess object cannot be created.public static DBAccess getDBAccess(java.lang.String pJdbcUrl, java.lang.String pOptionalUserName, java.lang.String pOptionalPassword) throws DataSourceException
pJdbcUrl
- the JdbcUrl.pOptionalUserName
- optional username for the connectionpOptionalPassword
- optional password for the connection
DataSourceException
- if the instance name is unknown or the DBAccess object cannot be created.public static DBAccess getDBAccess(DBCredentials pCredentials) throws DataSourceException
DBCredentials
.
pCredentials
- the database credentials.
DataSourceException
- if the instance name is unknown or the DBAccess object cannot be created.public static DBAccess getDBAccess(java.sql.Connection pConnection) throws DataSourceException
pConnection
- the database connection.
DataSourceException
- if the instance name is unknown or the DBAccess object cannot be created.public static DBAccess getDBAccess(IConnectionPool pConnectionPool) throws DataSourceException
pConnectionPool
- the connection pool.
DataSourceException
- if the instance name is unknown or the DBAccess object cannot be created.public static void registerDBAccessClass(java.lang.String pJdbcUrlPrefix, java.lang.Class<? extends DBAccess> pClass)
pJdbcUrlPrefix
- the jdbc url prefix.pClass
- the Class.public static void setAutomaticLinkColumnNameTranslation(TranslationMap pTranslationMap)
pTranslationMap
- the TranslationMap to use.public static TranslationMap getAutomaticLinkColumnNameTranslation()
public static long getDefaultCursorCacheTimeout()
public static void setDefaultCursorCacheTimeout(long pDefaultCursorCacheTimeout)
pDefaultCursorCacheTimeout
- the default cursor cache timeout in ms.public static long getDefaultLargeObjectLimit()
fetchLargObjectsLazy
option set to determine if the current object should be lazily fetched or not.
"Lazy" means that the object is only send to the client if the value
is actually requested. It is still fetched from the datasource and
cached on the server side.
Note that the default limit is only applied to new instances of DBAccess
.
public static void setDefaultLargeObjectLimit(long pDefaultLargeObjectLimit)
fetchLargObjectsLazy
option set to determine if the current object should be lazily fetched or not.
"Lazy" means that the object is only send to the client if the value
is actually requested. It is still fetched from the datasource and
cached on the server side.
Note that the default limit is only applied to new instances of DBAccess
.
pDefaultLargeObjectLimit
- the new default limit.protected java.util.List<Key> getUniqueKeysIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use
DataSourceException
- if an error occur during UK search process.public long getLargeObjectLimit()
fetchLargObjectsLazy
option set to determine
if the current object should be lazily fetched or not.
"Lazy" means that the object is only send to the client if the value is
actually requested. It is still fetched from the datasource and cached on
the server side.
protected Key getPrimaryKeyIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use
DataSourceException
- if an error occur during PK search process.protected java.util.List<ForeignKey> getForeignKeysIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use as base table.
DataSourceException
- if an error occur in determining the ForeignKeys.public final java.util.List<Key> getUniqueKeys(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use
DataSourceException
- if an error occur during UK search process.public final Key getPrimaryKey(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use
DataSourceException
- if an error occur during PK search process.public final java.util.List<ForeignKey> getForeignKeys(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use as base table.
DataSourceException
- if an error occur in determining the ForeignKeys.public final java.lang.String getTableForSynonym(java.lang.String pSynomyn) throws DataSourceException
pSynomyn
- the synonym to use.
DataSourceException
- if an error occur in determining the synonyms.protected java.lang.String getTableForSynonymIntern(java.lang.String pSynomyn) throws DataSourceException
pSynomyn
- the synonym to use.
DataSourceException
- if an error occur in determining the synonyms.public java.util.List<java.lang.Object[]> fetch(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereCondition, java.lang.String pAfterWhereClause, SortDefinition pSort, int pFromRow, int pMinimumRowCount, boolean pAllowLazyFetch) throws DataSourceException
fetch
in interface IDBAccess
pServerMetaData
- the MetaDataColumn array to use.pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspFilter
- the filter to usepWhereCondition
- the last where condition in querypAfterWhereClause
- the after where clause in querypSort
- the sort order to usepFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetchpAllowLazyFetch
- if lazy fetch should be allowed.
DataSourceException
- if the fetch fails.public java.util.List<java.lang.Object[]> fetch(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereCondition, java.lang.String pAfterWhereClause, SortDefinition pSort, int pFromRow, int pMinimumRowCount) throws DataSourceException
pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspFilter
- the filter to usepWhereCondition
- the last where condition in querypAfterWhereClause
- the after where clause in querypSort
- the sort order to usepFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetchpServerMetaData
- the MetaDataColumn array to use.
DataSourceException
- if the fetch fails.public java.util.List<java.lang.Object[]> fetch(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereCondition, java.lang.String pAfterWhereClause, SortDefinition pSort, java.lang.String pOrderByClause, int pFromRow, int pMinimumRowCount) throws DataSourceException
fetch(ServerMetaData, String, String[], String, ICondition, String, String, SortDefinition, int, int)
.
This fetch does accept an additional order by clause which will be used
if the given default sort is null.
pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspFilter
- the filter to usepWhereCondition
- the last where condition in querypAfterWhereClause
- the after where clause in querypOrderByClause
- the order by clausepSort
- the sort order to usepFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetchpServerMetaData
- the MetaDataColumn array to use.
DataSourceException
- if the fetch fails.public java.util.List<java.lang.Object[]> fetch(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereCondition, java.lang.String pAfterWhereClause, SortDefinition pSort, java.lang.String pOrderByClause, int pFromRow, int pMinimumRowCount, boolean pAllowLazyFetch) throws DataSourceException
fetch(ServerMetaData, String, String[], String, ICondition, String, String, SortDefinition, int, int)
.
This fetch does accept an additional order by clause which will be used
if the given default sort is null.
pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspFilter
- the filter to usepWhereCondition
- the last where condition in querypAfterWhereClause
- the after where clause in querypOrderByClause
- the order by clausepSort
- the sort order to usepFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetchpServerMetaData
- the MetaDataColumn array to use.pAllowLazyFetch
- if lazy fetch should be allowed.
DataSourceException
- if the fetch fails.public void lockRow(java.lang.String pWriteBackTable, ServerMetaData pServerMetaData, ICondition pPKFilter) throws DataSourceException
lockRow
in interface IDBAccess
pWriteBackTable
- the storage unit to usepServerMetaData
- the MetaDataColumn array to use.pPKFilter
- the PrimaryKey in as an ICondition
to identify the row to lock
DataSourceException
- if an Exception
occur during interacting with the storageprotected int lockRowInternal(java.lang.String pWriteBackTable, ServerMetaData pServerMetaData, ICondition pPKFilter) throws DataSourceException
pWriteBackTable
- the storage unit to usepPKFilter
- the PrimaryKey in as an ICondition
to identify the row to lockpServerMetaData
- the MetaDataColumn array to use.
DataSourceException
- if an Exception
occur during interacting with the storagepublic java.lang.Object[] insert(java.lang.String pWriteBackTable, ServerMetaData pServerMetaData, java.lang.Object[] pNewDataRow) throws DataSourceException
insert
in interface IDBAccess
pWriteBackTable
- the write back table to use.pServerMetaData
- the meta data to use.pNewDataRow
- the new values Object[] to insert.
DataSourceException
- if an Exception
occur during insert the row to the tablepublic void setLargeObjectLimit(long pLargeObjectLimit)
fetchLargObjectsLazy
option set to determine
if the current object should be lazily fetched or not.
"Lazy" means that the object is only send to the client if the value is
actually requested. It is still fetched from the datasource and cached on
the server side.
pLargeObjectLimit
- the new limit.public java.lang.Object[] update(java.lang.String pWriteBackTable, ServerMetaData pServerMetaData, java.lang.Object[] pOld, java.lang.Object[] pNew) throws DataSourceException
update
in interface IDBAccess
pWriteBackTable
- the write back table to use.pServerMetaData
- the meta data to use.pOld
- the old values of the rowpNew
- the new values of the row
DataSourceException
- if an Exception
occur during update.public int updateDatabaseSpecific(java.lang.String pWriteBackTable, java.lang.String sUpdateStatement, ServerMetaData pServerMetaData, java.lang.Object[] pOld, java.lang.Object[] pNew, ICondition pPKFilter) throws DataSourceException
pWriteBackTable
- the table to use for the updatesUpdateStatement
- the SQL Statement to use for the updatepServerMetaData
- the meta data to use.pOld
- the old row (values) to use.pNew
- the new row (values) to use.pPKFilter
- the PrimaryKey equals filter to use.
DataSourceException
- if an Exception
occur during update to the storagepublic int updateAnsiSQL(java.lang.String pWriteBackTable, java.lang.String sUpdateStatement, ServerMetaData pServerMetaData, java.lang.Object[] pOld, java.lang.Object[] pNew, ICondition pPKFilter) throws DataSourceException
pWriteBackTable
- the table to use for the updatesUpdateStatement
- the SQL Statement to use for the updatepServerMetaData
- the meta data to use.pOld
- the old row (values) to use.pNew
- the new row (values) to use.pPKFilter
- the PrimaryKey equals filter to use.
DataSourceException
- if an Exception
occur during update to the storagepublic void delete(java.lang.String pWriteBackTable, ServerMetaData pServerMetaData, java.lang.Object[] pDelete) throws DataSourceException
delete
in interface IDBAccess
pWriteBackTable
- the write back table to use.pServerMetaData
- the meta data to use.pDelete
- the row to delete.
DataSourceException
- if an Exception
occur during delete.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getOpenQuoteCharacter()
public java.lang.String getCloseQuoteCharacter()
protected void setQuoteCharacters(java.lang.String pOpen, java.lang.String pClose)
pOpen
- the open quote characterpClose
- the close quote characterpublic boolean isAutoQuote(java.lang.String pName)
pName
- the name to quote.
public java.lang.String quote(java.lang.String pName)
pName
- the name to use.
public java.lang.String quoteAllways(java.lang.String pName)
pName
- the name to use.
public static java.lang.String removeQuotes(java.lang.String pName)
pName
- the name to use.
public java.lang.String removeDBSpecificQuotes(java.lang.String pName)
pName
- the name to use.
public java.lang.String translateQuotes(java.lang.String pStatement)
pStatement
- the statement to use.
public void open() throws DataSourceException
Connection
object.
DataSourceException
- if the database couldn't openedpublic boolean isOpen() throws DataSourceException
DataSourceException
- if isClosed() on the DB Connection
throws an Exceptionpublic void close() throws DataSourceException
Connection
and releases all memory.
close
in interface ICloseable
DataSourceException
- if database couldn't closed.protected void commitOrRollbackBeforeClose()
public void setAutoCommit(boolean pEnable) throws DataSourceException
pEnable
- true
to enable, false
to disable auto-commit
DataSourceException
- if setting state failedpublic boolean isAutoCommit()
true
if enabled, false
otherwisepublic void rollback() throws DataSourceException
DataSourceException
- if the transaction couldn't rollbackpublic void commit() throws DataSourceException
DataSourceException
- if the transaction couldn't commitpublic int getQueryTimeout()
public void setQueryTimeout(int pQueryTimeout)
pQueryTimeout
- the timeout in secondspublic int getTransactionTimeout()
public void setTransactionTimeout(int pTransactionTimeout)
pTransactionTimeout
- the timeout in secondspublic java.sql.Connection getConnection() throws java.sql.SQLException
connection
to the database.
connection
to the database.
java.sql.SQLException
- if connection is not available.protected java.sql.Connection getConnectionIntern() throws java.sql.SQLException
connection
to the database.
This includes getting the connection from the pool, if needed.
connection
to the database.
java.sql.SQLException
- if connection is not available.public void releaseConnection() throws DataSourceException
connection
to the connection pool.
DataSourceException
- if the DBAccess is in modified state, and the connection cannot be released.public boolean isReleaseConnectionPending()
protected void releaseConnectionIntern()
connection
to the connection pool.
protected void setConnection(java.sql.Connection pConnection)
pConnection
- the connection to the databasepublic IConnectionPool getConnectionPool()
conncetion
to the database.
conncetion
to the database.protected void setConnectionPool(IConnectionPool pConnectionPool)
pConnectionPool
- the connection pool to the databasepublic boolean isConnectionPoolEnabled()
public void setConnectionPoolEnabled(boolean pConnectionPoolEnabled)
pConnectionPoolEnabled
- the connection pool methodpublic EventHandler<IConfigureConnectionListener> eventConfigureConnection()
public EventHandler<IUnconfigureConnectionListener> eventUnconfigureConnection()
protected void fireEventConfigureConnection() throws java.sql.SQLException
java.sql.SQLException
- if the event causes an exception.protected void fireEventUnconfigureConnection()
public java.lang.String getDriver()
String
.
public void setDriver(java.lang.String pDriver)
String
.
pDriver
- the database driver namepublic java.lang.String getUrl()
String
for this database.
String
.public void setUrl(java.lang.String pUrl)
String
for this database.
pUrl
- the jdbc url String
.public java.lang.String getUsername()
public void setUsername(java.lang.String pUsername)
pUsername
- the user namepublic java.lang.String getPassword()
public void setPassword(java.lang.String pPassword)
pPassword
- the password to use for the databasepublic void setDBProperty(java.lang.String pName, java.lang.String pValue)
pName
- the property namepValue
- th valuepublic java.lang.String getDBProperty(java.lang.String pName)
pName
- the property name
null
if the property was not foundpublic void setDBProperties(java.util.Properties pProperties)
Connection
creation.
pProperties
- DB specific initial parameterspublic java.util.Properties getDBProperties()
Connection
creation.
Connection
creation.public int getMaxTime()
public void setMaxTime(int pMaxTime)
pMaxTime
- the iMaxTime to setpublic int getMaxColumnLength()
public IColumnMetaDataCreator getColumnMetaDataCreator()
public void setColumnMetaDataCreator(IColumnMetaDataCreator pColumnMetaDataCreator)
pColumnMetaDataCreator
- the column meta data creator for custom column meta data support.public void setColumnMetaDataCreator(java.lang.Object pListener, java.lang.String pMethodName)
pListener
- the listener instance.pMethodName
- the method name.public void executeProcedure(java.lang.String pProcedureName, java.lang.Object... pParameters) throws java.sql.SQLException
pProcedureName
- the procedure (optional with package) name.pParameters
- the parameters to use with the correct and corresponding java type.
java.sql.SQLException
- if the call failed.public java.lang.Object executeFunction(java.lang.String pFunctionName, int pReturnType, java.lang.Object... pParameters) throws java.sql.SQLException
pFunctionName
- the function (optional with package) name.pReturnType
- the return SQL Type (see Types
pParameters
- the parameters to use with the correct and corresponding java type.
java.sql.SQLException
- if the call failed.public java.lang.Object executeFunction(java.lang.String pFunctionName, OutParam pReturnOutParam, java.lang.Object... pParameters) throws java.sql.SQLException
pFunctionName
- the function (optional with package) name.pReturnOutParam
- the return SQL Type (see Types
pParameters
- the parameters to use with the correct and corresponding java type.
java.sql.SQLException
- if the call failed.public int executeStatement(java.lang.String pStatement, java.lang.Object... pParameters) throws java.sql.SQLException
pStatement
- the statement.pParameters
- the parameters.
java.sql.SQLException
- if an error occur during execution.public java.util.List<Bean> executeQuery(java.lang.String pStatement, java.lang.Object... pParameters) throws java.sql.SQLException
pStatement
- the statement with or without parameterspParameters
- the parameters to use
null
if the command returned no
result
java.sql.SQLException
- if an error occurs during executionpublic java.util.List<java.lang.Object> executeSql(java.lang.String pStatement, java.lang.Object... pParameters) throws java.sql.SQLException
pStatement
- the statement with or without parameterspParameters
- the parameters to use
null
if the command returned no
result
java.sql.SQLException
- if an error occurs during executionprotected java.util.List<java.lang.Object> executeSqlMulti(java.lang.String pStatement, int pResultColumn, java.lang.Object... pParameters) throws java.sql.SQLException
pStatement
- the statement with or without parameterspResultColumn
- the column index which contains the result value. If you set -1
all column
values will be returned as Object[]
pParameters
- the parameters to use
null
if the command returned no
result
java.sql.SQLException
- if an error occurs during executionpublic java.sql.PreparedStatement getPreparedStatement(java.lang.String pSqlStatement) throws java.sql.SQLException
PreparedStatement
for the given SQL statement.
pSqlStatement
- the SQL statement to prepare
PreparedStatement
for the given SQL statement.
java.sql.SQLException
- if the statement couldn't prepared.protected java.sql.PreparedStatement getPreparedStatement(java.lang.String pSqlStatement, boolean pReturnGeneratedKeys) throws java.sql.SQLException
PreparedStatement
for the given SQL statement.
pSqlStatement
- the SQL statement to preparepReturnGeneratedKeys
- if the generated key in insert statements should returned
PreparedStatement
for the given SQL statement.
java.sql.SQLException
- if the statement couldn't prepared.protected java.sql.SQLException formatSQLException(java.sql.SQLException pSqlException)
pSqlException
- the SQL Exception to use.
protected java.sql.SQLException formatSQLException(java.sql.SQLException pSqlException, java.lang.String pMessage, java.lang.String pCode)
pSqlException
- the SQL Exception to use.pMessage
- the message to usepCode
- the detected error code
public DBAccess.ParameterizedStatement getParameterizedSelectStatement(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereClause, java.lang.String pAfterWhereClause, SortDefinition pSort, java.lang.String pOrderByClause, int pFromRow, int pMinimumRowCount) throws DataSourceException
DBAccess.ParameterizedStatement
and returns it.
Note that this function is subject to be changed in a future version, and can there for not be considered stable.
pServerMetaData
- the MetaDataColumn array to use.pBeforeQueryColumns
- the string to place in the SELECT statement between the SELECT and the first query column.pQueryColumns
- the list of query columns to use in the SELECT statement.pFromClause
- the list of query tables to use in the SELECT statement.pFilter
- the Filter
to usepWhereClause
- the string to place in the SELECT statement after the last WHERE condition from the
Filter or MasterReference (Master-Detail Condition).pAfterWhereClause
- the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause.pSort
- the sort definition.pOrderByClause
- the order by clause.pFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetch
DataSourceException
- if it's not possible to build the select statement in fact of missing elementspublic java.lang.String getSelectStatement(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereClause, java.lang.String pAfterWhereClause, SortDefinition pSort, java.lang.String pOrderByClause, int pFromRow, int pMinimumRowCount) throws DataSourceException
pServerMetaData
- the MetaDataColumn array to use.pBeforeQueryColumns
- the string to place in the SELECT statement between the SELECT and the first query column.pQueryColumns
- the list of query columns to use in the SELECT statement.pFromClause
- the list of query tables to use in the SELECT statement.pFilter
- the Filter
to usepWhereClause
- the string to place in the SELECT statement after the last WHERE condition from the
Filter or MasterReference (Master-Detail Condition).pAfterWhereClause
- the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause.pSort
- the sort definition.pOrderByClause
- the order by clause.pFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetch
DataSourceException
- if it's not possible to build the select statement in fact of missing elementspublic java.lang.String getSelectStatement(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereClause, java.lang.String pAfterWhereClause, SortDefinition pSort, java.lang.String pOrderByClause) throws DataSourceException
pServerMetaData
- the MetaDataColumn array to use.pBeforeQueryColumns
- the string to place in the SELECT statement between the SELECT and the first query column.pQueryColumns
- the list of query columns to use in the SELECT statement.pFromClause
- the list of query tables to use in the SELECT statement.pFilter
- the Filter
to usepWhereClause
- the string to place in the SELECT statement after the last WHERE condition from the
Filter or MasterReference (Master-Detail Condition).pAfterWhereClause
- the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause.pSort
- the sort definition.pOrderByClause
- the order by clause.
DataSourceException
- if it's not possible to build the select statement in fact of missing elementsprotected java.lang.String getWhereClause(ServerMetaData pServerMetaData, ICondition pFilter, java.lang.String pWhereClause, boolean pUsePrefix) throws DataSourceException
Filter
.
pServerMetaData
- the MetaData
to usepFilter
- the Filter
to usepWhereClause
- the where clause to usepUsePrefix
- true
to use the prefixed column (real column name) and false
to
ignore prefixes (the simple name of the column)
Filter
.
DataSourceException
- if columns not existingprotected java.lang.String getDatabaseSpecificLockStatement(java.lang.String pWriteBackTable, ServerMetaData pServerMetaData, ICondition pPKFilter) throws DataSourceException
pWriteBackTable
- the table to use.pPKFilter
- the PK filter with the values to use.pServerMetaData
- the MetaDataColumn array to use.
DataSourceException
- if some parts are missing for the statementprotected java.lang.Object[] insertDatabaseSpecific(java.lang.String pWriteBackTable, java.lang.String pInsertStatement, ServerMetaData pServerMetaData, java.lang.Object[] pNewDataRow, java.lang.String pDummyColumn) throws DataSourceException
pWriteBackTable
- the table to use for the insertpInsertStatement
- the SQL Statement to use for the insertpServerMetaData
- the meta data to use.pNewDataRow
- the new row (Object[]) with the values to insertpDummyColumn
- null
, if all writeable columns are null, but for a correct INSERT it have
to be minimum one column to use in the syntax.
DataSourceException
- if an Exception
occur during insert to the storagepublic boolean supportsGetGeneratedKeys()
protected java.lang.Object[] insertAnsiSQL(java.lang.String pWriteBackTable, java.lang.String pInsertStatement, ServerMetaData pServerMetaData, java.lang.Object[] pNewDataRow, java.lang.String pDummyColumn) throws DataSourceException
pWriteBackTable
- the table to use for the insertpInsertStatement
- the SQL Statement to use for the insertpServerMetaData
- the meta data to use.pNewDataRow
- the new row (Object[]) with the values to insertpDummyColumn
- true, if all writeable columns are null, but for a correct INSERT it have
to be minimum one column to use in the syntax.
DataSourceException
- if an Exception
occur during insert to the storageprotected ServerColumnMetaData[] getColumnMetaDataIntern(java.lang.String pFromClause, java.lang.String[] pQueryColumns, java.lang.String pBeforeQueryColumns, java.lang.String pWhereClause, java.lang.String pAfterWhereClause) throws DataSourceException
pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspWhereClause
- the last where condition in querypAfterWhereClause
- the after where clause in query
DataSourceException
- if an Exception
occur during getting the meta data or
if the storage is not opened or
if one columns SQL type is not supportedprotected java.lang.String getRealQueryColumnName(java.lang.String pQueryColumn)
pQueryColumn
- the full query column name with alias
protected ServerColumnMetaData createServerColumnMetaData(java.sql.ResultSetMetaData pResultSetMetaData, int pResultSetColumnIndex, java.lang.String pQueryColumn) throws java.sql.SQLException, DataSourceException
ServerColumnMetaData
based on ResultSetMetaData
.
pResultSetMetaData
- the result set meta data.pResultSetColumnIndex
- the column index.pQueryColumn
- the specific query column of the select statement or null if none
ServerColumnMetaData
java.sql.SQLException
- if an unwanted SQLException occurs
DataSourceException
- if an know problem occurs during creationprotected ServerColumnMetaData initializeServerColumnMetaData(java.sql.ResultSetMetaData pResultSetMetaData, int pResultSetColumnIndex, java.lang.String pQueryColumn, ServerColumnMetaData pServerColumnMetaData) throws java.sql.SQLException, DataSourceException
ServerColumnMetaData
based on ResultSetMetaData
.
pResultSetMetaData
- the result set meta data.pResultSetColumnIndex
- the column index.pQueryColumn
- the specific query column of the select statement or null if nonepServerColumnMetaData
- the ServerColumnMetaData
ServerColumnMetaData
java.sql.SQLException
- if an unwanted SQLException occurs
DataSourceException
- if an know problem occurs during creationpublic void initializeColumnMetaData(java.sql.ResultSetMetaData pResultSetMetaData, int pResultSetColumnIndex, ColumnMetaData pColumnMetaData) throws java.sql.SQLException, DataSourceException
ColumnMetaData
with the given ResultSetMetaData
.
pResultSetMetaData
- the result set meta data.pResultSetColumnIndex
- the column index.pColumnMetaData
- the ColumnMetaData
java.sql.SQLException
- if an unwanted SQLException occurs
DataSourceException
- if an know problem occurs during creationprotected void initializeDataType(java.sql.ResultSetMetaData pResultSetMetaData, int pResultSetColumnIndex, ColumnMetaData pColumnMetaData) throws java.sql.SQLException, DataSourceException
ColumnMetaData
with the given ResultSetMetaData
.
pResultSetMetaData
- the result set meta data.pResultSetColumnIndex
- the column index.pColumnMetaData
- the ColumnMetaData
java.sql.SQLException
- if an unwanted SQLException occurs
DataSourceException
- if an know problem occurs during creationpublic final ServerColumnMetaData[] getColumnMetaData(java.lang.String pFromClause, java.lang.String[] pQueryColumns, java.lang.String pBeforeQueryColumns, java.lang.String pWhereClause, java.lang.String pAfterWhereClause) throws DataSourceException
pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspWhereClause
- the last where condition in querypAfterWhereClause
- the after where clause in query
DataSourceException
- if an Exception
occur during getting the meta data or
if the storage is not opened or
if one columns SQL type is not supportedprotected TableInfo getTableInfoIntern(java.lang.String pWriteBackTable) throws DataSourceException
pWriteBackTable
- the write back table to use for the isWriteable() state (Optional)
DataSourceException
- if an Exception
occur during getting the meta data or
if the storage is not opened or
if one columns SQL type is not supportedpublic final TableInfo getTableInfo(java.lang.String pWriteBackTable) throws DataSourceException
pWriteBackTable
- the write back table to use for the isWriteable() state (Optional)
DataSourceException
- if an Exception
occur during getting the meta data or
if the storage is not opened or
if one columns SQL type is not supportedprotected int setColumnsToStore(java.sql.PreparedStatement pInsert, ServerColumnMetaData[] pServerColumnMetaData, int[] iaWriteables, java.lang.Object[] pNew, java.lang.Object[] pOld) throws DataSourceException
PreparedStatement
and returns the last used parameter index.
pInsert
- the PreparedStatement
to initializepServerColumnMetaData
- the column meta data to use.iaWriteables
- the writable columns as int index arraypNew
- the new values Object[]pOld
- the old values Object[]
PreparedStatement
.
DataSourceException
- if the values can't set into the PreparedStatement
public final java.util.Map<java.lang.String,java.lang.Object> getDefaultValues(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog namepSchema
- the schema namepTable
- the table name
Hashtable
with the column name as key and the default value as value. It only contains columns
with a default value
DataSourceException
- if the database access throws an exceptionprotected java.util.Map<java.lang.String,java.lang.Object> getDefaultValuesIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog namepSchema
- the schema namepTable
- the table name
Hashtable
with the column name as key and the default value as value. It only contains columns
with a default value
DataSourceException
- if the database access throws an exceptionprotected java.lang.Object translateDefaultValue(java.lang.String pColumnName, int pDataType, java.lang.String pDefaultValue) throws java.lang.Exception
pColumnName
- the column name to translatepDataType
- the datatype of the columnpDefaultValue
- the original default value from the database
null
if the default value is not valid
java.lang.Exception
- if the type translation causes an error or the datatype is not supportedprotected java.lang.Object translateValue(int pDataType, java.lang.String pValue) throws java.lang.Exception
pDataType
- the datatype of the columnpValue
- the value from the database
null
if the value is not valid
java.lang.Exception
- if the type translation causes an error or the datatype is not supportedprotected java.util.Map<java.lang.String,java.lang.Object[]> getAllowedValuesIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog namepSchema
- the schema namepTable
- the table to check
Hashtable
with a column name as key and the allowed values as array of Object
s or
null
if there are no allowed values
DataSourceException
- if the database access throws an exceptionpublic final java.util.Map<java.lang.String,java.lang.Object[]> getAllowedValues(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
pCatalog
- the catalog namepSchema
- the schema namepTable
- the table to check
Hashtable
with a column name as key and the allowed values as array of Object
s or
null
if there are no allowed values
DataSourceException
- if the database access throws an exceptionpublic java.lang.Object[] getDefaultAllowedValues(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable, ServerColumnMetaData pMetaData)
pCatalog
- the catalog namepSchema
- the schema namepTable
- the table to checkpMetaData
- the column meta data
null
if there are no default valuesprotected java.lang.String getSQL(ServerMetaData pServerMetaData, ICondition pCondition, boolean pUseRealColumnName) throws DataSourceException
ICondition
.
pServerMetaData
- the MetaDataColumn array to use.pCondition
- the Condition to use.pUseRealColumnName
- true
to use the prefixed column (real column name) and false
to
ignore prefixes (the simple name of the column)
ICondition
.
DataSourceException
- if columns not existingprotected java.lang.String createReplace(java.lang.String pSource, java.lang.String pOld, java.lang.String pNew)
pSource
- the source to replace.pOld
- the old value.pNew
- the new value.
protected java.lang.String createWhereParam(ServerMetaData pServerMetaData, CompareCondition pCompare)
pServerMetaData
- the server metadatapCompare
- the compare condition
protected java.lang.String createWhereColumn(ServerMetaData pServerMetaData, CompareCondition pCompare, java.lang.String pColumnName)
pServerMetaData
- the server metadatapCompare
- the compare conditionpColumnName
- the column name to use
public boolean isTypeEqual(ServerColumnMetaData pServerColumnMetaData, CompareCondition pCompare)
pServerColumnMetaData
- the server column meta data for the column to compare.pCompare
- the compare condition to use.
protected java.lang.Object[] getParameter(ICondition pCondition, int pFromRow, int pMinimumRowCount)
ICondition
.
pCondition
- the Condition to use.pFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetch
ICondition
.protected java.lang.Object[] getParameter(ICondition pCondition)
ICondition
.
pCondition
- the Condition to use.
ICondition
.protected java.lang.String[] splitSchemaTable(java.lang.String pFromClause)
pFromClause
- the from clause
public void setDefaultSchema(java.lang.String pSchema)
pSchema
- the schema namegetDefaultSchema()
public java.lang.String getDefaultSchema()
setDefaultSchema(String)
protected java.lang.Object getObjectFromResultSet(java.sql.ResultSet pResultSet, int pIndex, ServerColumnMetaData pColumnMetaData) throws java.sql.SQLException
pResultSet
- the result setpIndex
- the indexpColumnMetaData
- the server column meta data
java.sql.SQLException
- if it fails.protected java.lang.Object getObjectFromResultSet(java.sql.ResultSet pResultSet, int pIndex) throws java.sql.SQLException
pResultSet
- the result setpIndex
- the index
java.sql.SQLException
- if it fails.protected java.lang.Object convertDatabaseSpecificObjectToValue(ServerColumnMetaData pColumnMetaData, java.lang.Object pObject) throws java.sql.SQLException
pColumnMetaData
- the column metadatapObject
- the read object
java.sql.SQLException
- if it fails.protected java.lang.Object convertValueToDatabaseSpecificObject(java.lang.Object pValue)
pValue
- any value
protected java.lang.String getIdentifier()
public static void clearMetaData()
public static void clearMetaData(java.lang.String pApplicationName)
pApplicationName
- the application namepublic static java.lang.String createIdentifier(java.lang.Object... pIdentifier)
pIdentifier
- the identifier
public void setMetaDataCacheOption(MetaDataCacheOption pOption)
pOption
- the metadata cache optionisMetaDataCacheEnabled()
public MetaDataCacheOption getMetaDataCacheOption()
setMetaDataCacheOption(MetaDataCacheOption)
protected boolean isMetaDataCacheEnabled()
protected void prepareConnection(java.sql.Connection pConnection) throws java.sql.SQLException
Connection
for being used by this
DBAccess
.
pConnection
- the Connection
to configure.
java.sql.SQLException
- if the configuring the Connection
fails.protected void setModified(java.lang.Boolean pModified)
pModified
- true
to set the connection modified, false
to set it not modifiedpublic boolean isModified()
true
if modified, false
otherwiseprotected boolean detectModified()
protected static boolean isLogEnabled(ILogger.LogLevel pLevel)
pLevel
- the level to check
true
if the log level is enabled, false
otherwiseprotected static void debug(java.lang.Object... pInfo)
pInfo
- the debug informationprotected static void info(java.lang.Object... pInfo)
pInfo
- the informationprotected static void error(java.lang.Object... pInfo)
pInfo
- the error informationpublic static boolean isJdbc(java.lang.String pUrl)
pUrl
- the URL
true
if given URL is a jdbc resourceprotected void findNamedParameters(java.lang.String pStatement, java.util.List<java.lang.String> pNameList)
List
.
Note that this function is subject to be changed in a future version, and can there for not be considered stable.
pStatement
- the statement.pNameList
- the List
to add the names to.protected java.lang.String getColumnName(java.sql.ResultSetMetaData pMetaData, int pColumn) throws java.sql.SQLException
pMetaData
- the metadatapColumn
- the column index
java.sql.SQLException
- if accessing metadata failedprotected int getDiscardRowCount(int pFromRow, int pMinimumRowCount)
pFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetch
protected ICondition findAndCreateReducedCondition(ICondition pCondition, java.util.Set<java.lang.String> pNames, java.util.Map<java.lang.String,CompareCondition> pNameToCondition)
ICondition
with the given column names from
the given ICondition
. It adds the name and value to the given
Map
.
Note that this function is subject to be changed in a future version, and can there for not be considered stable.
pCondition
- the ICondition
in which to search.pNames
- the names of the conditions to search.pNameToCondition
- the Map
into which the ICondition
is inserted.
protected java.lang.String getMetaDataWhereClause()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |