|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.Db
public class Db
A logical database connection.
Db connections are an abstraction for a connection between a client
and a server, whereas "server" is not necessarily a database server,
because Db connections can be either local or remote.
A local Db talks to a database backend via a ConnectionManager
which is responsible for the physical JDBC-connection. However, there
is no 1:1 relationship between a Db and a physical connection. This is up
to the connection manager.
Local Db connections are used in client applications running in 2-tier mode
or in application servers.
Remote Db connections are connected to a Tentackle application server
via RMI. Client applications running in 3-tier mode (more precise n-tier, with n >= 3)
use remote connections.
With the abstraction of a logical Db connection, Tentackle applications
are able to run both in 2- or n-tier mode without a single modification
to the source code. It's just a small change in a config file.
The configuration is achieved by a property file, which is located
by the UserInfo passed to the Db.
Local connections can be either a DataSource bound via JNDI or a direct
JDBC connection. JNDI is used in application servers, for example running
a JRuby on Rails WebApplication from within Glassfish.
JDBC connections are for standalone 2-tier applications or Tentackle application servers.
For local connections via JDBC the file contains at least the following properties:
driver=jdbc-driver url=jdbc-url Example: driver=org.postgresql.Driver url=jdbc:postgresql://gonzo.krake.local/erpLocal connections via JNDI need only the url. The url starts with "jndi:" and is followed by the JNDI-name. The optional database backend type is only necessary if it cannot be determined from the connection's metadata. The following types are currently supported: db2, ingres, informix, mssql, mysql, oracle and postgres.
url=jndi:name[:database-type] Example: url=jndi:jdbc/erpPoolFor remote connections only one line is required at minimum:
url=rmi://hostname[:port]/service Example: url=rmi://gonzo.krake.local:28004/ErpServerThe port is optional and defaults to 1099 (the default RMI registry). For setting up an application server please refer to
DbServer.
Optionally, the following properties can be defined:
For local connections via JDBC:
usernameObfuscator.
Obfuscation is also an effective solution to prevent users from connecting
with popular tools like Access to the database backend. Anyway, for larger sites,
consider going n-tier.
obfuscate=yes|no The default is no.
dbuser=fixed-user dbpasswd=fixed-password Example: dbuser=harald dbpasswd=xyzzy
UserInfo that provides the username
and password. This class can do the weirdest things, for example connect
to an LDAP-server. For skilled users, however, this isn't safe
enough either. Again, consider going n-tier.
dbuserinfo=classname Example: dbuserinfo=de.krake.lager.auth.LdapUserInfo
For local connections via JDBC or JNDI:
IdSource. The default source is ObjectId.
idsource=id-source-descriptorSee
IdSourceConfigurator for details.
For remote connections, the property file will be sent to the server. This can be used to set some application specific options or to tune the connection. For example, if the server requires an SSL connection, the client can request to turn off SSL after successful login. Or clients using slow communication lines may request compression. The following properties are already predefined:
keystore=name of the keystore file keystorepassword=keystore password truststore=name of the truststore file truststorepassword=truststore passwordThe truststore is only necessary for servers requesting client authentication.
compressed
ssl
uncompressed
nossl
plain
csf=client socket factory ssf=server socket factorySee
RemoteDbSessionImpl for more details.
| Field Summary | |
|---|---|
static CharConverter |
passwordObfuscator
The current password obfuscator |
static CharConverter |
usernameObfuscator
The current username obfuscator |
static String |
WHERE_CLAUSE
"WHERE" |
static String |
WHEREALL_CLAUSE
"WHERE 1=1" allows AND to be added |
static String |
WHEREAND_CLAUSE
WHEREALL_CLAUSE + AND will be replaced by... |
static String |
WHEREOR_CLAUSE
WHEREALL_CLAUSE + OR will be replaced by... |
| Constructor Summary | |
|---|---|
Db(ConnectionManager conMgr,
UserInfo ui)
Creates an instance of a logical db connection. |
|
Db(UserInfo ui)
Creates an instance of a db-connection with the default connection manager as defined by DbGlobal.connectionManager. |
|
| Method Summary | |
|---|---|
int |
addIdSource(IdSource idSource)
Subclasses get their default ID-Source from the Db-connection. |
StringBuilder |
addLimitOffsetToSql(StringBuilder sql,
int limit,
int offset)
Adds a limit and offset clause to an SQL statement according to the database backend in use. |
void |
appendDeferredModificationLog(ModificationLog log)
Appends a ModificationLog object to the deferred log list. |
int |
appendLimitOffsetToPreparedStatement(int ndx,
PreparedStatementWrapper st,
int limit,
int offset)
Appends limit and offset parameters to a prepared statement according to the database in use. |
static void |
applyToCollection(Db db,
Collection<? extends DbObject> list)
Sets the context in a collection of DbObjects. |
static void |
applyToDbObject(Db db,
DbObject obj)
Sets the db in a DbObject if not null. |
void |
assertNotRemote()
asserts that this is not a remote connection |
void |
assertRemote()
asserts that this is a remote connection |
boolean |
begin()
Starts a transaction. Does nothing if a transaction is already running! |
boolean |
begin(String txName)
Starts a transaction. Does nothing if a transaction is already running! |
void |
clearCloned()
Clears the cloned state. |
void |
clearPassword()
Clears all passwords (stored in char[]-arrays) so that they are no more visible in memory. |
Db |
clone()
Clones a logical connection. |
void |
close()
Close a database connection. |
boolean |
commit(boolean autoCommit)
Commits a transaction if the corresponding begin() has started it. |
int |
compareTo(Db db)
Compares two db instances. |
Connection |
connect()
Creates a physical low level connection to the local db server via JDBC using this Db (authentication by userinfo or fixed user/password). |
Thread |
createKeepAliveThread(long interval)
Creates a simple thread that keeps this db connection "alive", for example while the user is prompted to answer a question from within ModificationThread.runOnce(java.lang.Runnable).If remote connections don't receive an alive signal within a given timeout the server usually assumes a dead session and closes it. |
StatementWrapper |
createStatement()
Creates a non-prepared statement. |
void |
finalize()
finalizer if connection is broken |
Db |
getClonedFromDb()
Gets the original db if this db is cloned. |
int |
getConnectionId()
Gets the connection id. |
ConnectionManager |
getConnectionManager()
Gets the connection manager for this Db. |
char[] |
getDbPassword()
Gets the fixed password |
String |
getDbUser()
Gets the name of the effective database user. |
IdSource |
getDefaultIdSource()
Gets the default IdSource. |
List<ModificationLog> |
getDeferredModificationLogList()
Gets the deferred ModificationLogs. |
String |
getDriver()
Gets the driver of the connection. |
int |
getFetchSize()
Gets the default fetchsize |
int |
getGroupId()
Gets the group instance number. |
IdSource |
getIdSource(int id)
Gets the idsource by handle local to this db |
IdSourceConfigurator |
getIdSourceConfigurator()
Gets the ID-Source configurator. |
Exception |
getLoginFailedCause()
Gets the Exception that caused the last open() to fail. |
long |
getLogModificationTxId()
Returns the current transaction id from the last BEGIN modification log. |
int |
getMaxRows()
gets the maximum number of rows in resultsets. |
ModificationCounter |
getModificationCounter(String tableName)
Gets the ModificationCounter for a given tablename. |
DbPool |
getPool()
Gets the pool manager. |
int |
getPoolId()
Gets the poolid. |
PreparedStatementWrapper |
getPreparedStatement(int id)
Gets the prepared statement. |
PreparedStatementWrapper |
getPreparedStatement(String sql)
Get prepared statement with ResultSet.TYPE_FORWARD_ONLY and ResultSet.CONCUR_READ_ONLY. |
PreparedStatementWrapper |
getPreparedStatement(String sql,
int resultSetType)
Get prepared statement with ResultSet.CONCUR_READ_ONLY. |
PreparedStatementWrapper |
getPreparedStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Combination of prepareStatement(sql,...) and getPreparedStatement(stmtId). |
RemoteDbConnection |
getRemoteConnection()
Gets the remote connection object. |
RemoteDelegate |
getRemoteDelegate(int id)
Gets the remote delegate by its id. |
RemoteDbSession |
getRemoteSession()
Gets the remote session object. |
int |
getResultSetConcurrency(int stmtId)
Get the resultSetConcurrency of a prepared statement. |
int |
getResultSetType(int stmtId)
Gets the resultSetType of a prepared statement. |
String |
getSqlText(int stmtId)
Gets the sql-string of a prepared statement. |
int |
getStatementId(String sql)
Get the ID of a prepared statement by its SQL-string. |
int |
getStatementId(String sql,
int resultSetType)
Get the ID of a prepared statement by its SQL-string and result set type. |
int |
getStatementId(String sql,
int resultSetType,
int resultSetConcurrency)
Get the ID of a prepared statement by its SQL-string, result set type and concurrency. |
long |
getTxCount()
Transactions get a unique transaction number by counting the transactions per Db instance. |
String |
getTxName()
Gets the optional transaction name. |
DbObject |
getTxObject()
Gets the optional transaction object. |
int |
getUpdateCount()
Gets the number of objects modified since the last begin(). |
String |
getUrl()
Gets the url if this is a remote connection |
UserInfo |
getUserInfo()
Gets the current user info. |
boolean |
isAlive()
Checks whether the db connection is still in use. |
boolean |
isAutoCommit()
Gets the current autocommit state. |
boolean |
isCloned()
Gets the cloned state. |
boolean |
isCountModificationAllowed()
Checks whether objects are allowed to count modifications. |
boolean |
isDb2()
For applications that need to know the kind of database backend. |
boolean |
isInformix()
For applications that need to know the kind of database backend. |
boolean |
isIngres()
For applications that need to know the kind of database backend. |
boolean |
isLogModificationAllowed()
Gets the state of logModificationAllowed. |
boolean |
isLogModificationDeferred()
Gets the state for logModificationDeferred. |
boolean |
isLogModificationTxEnabled()
Gets the value of logModificationTx. |
boolean |
isMssql()
For applications that need to know the kind of database backend. |
boolean |
isMysql()
For applications that need to know the kind of database backend. |
boolean |
isObfuscatedLogin()
Gets the obfuscated login flag (a feature that will be removed soon...) |
boolean |
isOpen()
Gets the connection state. |
boolean |
isOracle()
For applications that need to know the kind of database backend. |
boolean |
isPooled()
Checks whether this Db is pooled. |
boolean |
isPostgres()
For applications that need to know the kind of database backend. |
boolean |
isRemote()
Gets the type of the logical connection. |
boolean |
isUniqueViolation()
When updates or inserts fail this might be due to a unique voilation. |
boolean |
isUniqueViolationLogEnabled()
Checks whether unique violations are logged. |
boolean |
open()
Open a database connection. |
static int |
prepareRemoteDelegate(Class clazz)
Prepares a RemoteDelegate. |
int |
prepareStatement(String sql)
Creates a prepared statement with ResultSet.TYPE_FORWARD_ONLY and ResultSet.CONCUR_READ_ONLY. |
int |
prepareStatement(String sql,
int resultSetType)
Creates a prepared statement with ResultSet.CONCUR_READ_ONLY. |
int |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Creates a prepared statement. Statements are bound to the db (i.e. |
int |
prependLimitOffsetToPreparedStatement(int ndx,
PreparedStatementWrapper st,
int limit,
int offset)
Prepends limit and offset parameters to a prepared statement according to the database in use. |
void |
registerCommitTxRunnable(CommitTxRunnable txRunnable)
Registers a CommitTxRunnable to be invoked just before
committing a transaction. |
void |
registerRollbackTxRunnable(RollbackTxRunnable txRunnable)
Registers a RollbackTxRunnable to be invoked just before
rolling back a transaction. |
boolean |
rollback(boolean autoCommit)
Rolls back a transaction if the corresponding begin() has started it. |
void |
setAlive(boolean alive)
Sets the db connection's alive state. |
void |
setCountModificationAllowed(boolean countModificationAllowed)
Defines whether objects are allowed to count modifications. |
void |
setDefaultIdSource(IdSource idSource)
Set the default IdSource.This is the source that is used to generate unique object IDs if classes did not configure their own source. |
void |
setFetchSize(int fetchSize)
Sets the default fetchsize for all "wrapped" statements (PreparedStatementWrapper and StatementWrapper) |
void |
setGroupId(int number)
Sets the group number for this db. |
void |
setIdSource(int id,
IdSource idSource)
Sets the idsource by handle local to this db. |
void |
setIdSourceConfigurator(IdSourceConfigurator idConfig)
Sets the ID-Source configurator. |
void |
setLoginFailedCause(Exception loginFailedCause)
Sets the cause for login failed. |
void |
setLogModificationAllowed(boolean logModificationAllowed)
Sets the modification allowed state. |
void |
setLogModificationDeferred(boolean logModificationDeferred)
Sets the modification deferred state. In deferred mode the ModificationLog objects are not written to the database. |
void |
setLogModificationTxEnabled(boolean logModificationTxEnabled)
Turn transaction-logging on or off. |
void |
setLogModificationTxId(long logModificationTxId)
Sets the transaction id. |
void |
setMaxRows(int maxRows)
sets the maximum number of rows in resultsets. |
void |
setPool(DbPool dbPool)
Sets the pool manager. |
void |
setPoolId(int poolId)
Sets the pool id. |
void |
setTxObject(DbObject txObject)
Sets the optional transaction object. By default, whenever a transaction is initiated by a persistence operation of a DbObject or DbObject.isTxObject() returns true, that object becomes the "parent" of the
transaction. |
void |
setUniqueViolation(boolean uniqueViolation)
Sets the unique violation flag. |
void |
setUniqueViolationLogEnabled(boolean logUniqueViolation)
By default, unique violations are logged. |
void |
setUserInfo(UserInfo ui)
Sets the userInfo. |
String |
sqlFormatLimitClause(String par)
Returns the limit clause formatted for the given database. |
String |
sqlFormatLimitOffsetClause(String limitPar,
String offsetPar)
Returns the limit clause formatted for the given database. |
String |
sqlFormatOffsetClause(String par)
Returns the limit clause formatted for the given database. |
boolean |
sqlRequiresExtraCommit()
According to the JDBC-specs Connection.setAutoCommit(boolean)(true)
should commit, but some backends require an extra Connection.commit(). |
boolean |
sqlRequiresLimitAppended()
The top/limit/first clause has to be appended by some dbms and to be prepended by others. |
boolean |
sqlRequiresLimitBeforeOffset()
The limit + offset/skip clause has to be appended by some dbms and to be prepended by others. |
boolean |
sqlRequiresLimitOffsetAppended()
The limit + offset/skip clause has to be appended by some dbms and to be prepended by others. |
boolean |
sqlRequiresNestedLimitOffsetSelect()
Returns true if limit+offset clause requires a nested select. |
boolean |
sqlRequiresNestedLimitSelect()
Returns true if limit clause requires a nested select. |
boolean |
sqlRequiresNestedOffsetSelect()
Returns true if offset clause requires a nested select. |
boolean |
sqlRequiresOffsetAppended()
The offset/skip clause has to be appended by some dbms and to be prepended by others. |
boolean |
sqlResultSetIsClosedSupported()
|
String |
toString()
for logging |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String WHEREALL_CLAUSE
public static final String WHEREAND_CLAUSE
public static final String WHEREOR_CLAUSE
public static final String WHERE_CLAUSE
public static CharConverter passwordObfuscator
public static CharConverter usernameObfuscator
| Constructor Detail |
|---|
public Db(ConnectionManager conMgr,
UserInfo ui)
conMgr - the connection manager to use for this dbui - user informationpublic Db(UserInfo ui)
DbGlobal.connectionManager.
ui - user information| Method Detail |
|---|
public String toString()
toString in class Objectpublic int compareTo(Db db)
compareTo in interface Comparable<Db>db - the db connection to compare this db with
public ConnectionManager getConnectionManager()
public void setPool(DbPool dbPool)
dbPool - the db pool, null = not pooledpublic DbPool getPool()
public boolean isPooled()
public void setPoolId(int poolId)
poolId - the ID given by the pool (> 1), 0 = not used (free Db)public int getPoolId()
public RemoteDbConnection getRemoteConnection()
public RemoteDbSession getRemoteSession()
public Connection connect()
throws SQLException
SQLException - if connection failedpublic boolean isAlive()
StatementWrapper or PreparedStatementWrapper is used
(i.e executeQuery or executeUpdate), the db connection is set to be alive.
Some other thread may clear this flag regulary and check whether it has
been set in the meantime.
public void setAlive(boolean alive)
alive - is true to signal it's alive, false to clearpublic void setIdSourceConfigurator(IdSourceConfigurator idConfig)
idConfig - the configuratorpublic IdSourceConfigurator getIdSourceConfigurator()
public boolean open()
handleConnectException(java.lang.Exception) is invoked.
If the application is not terminated due a severe error,
getLoginFailedCause() holds the reason,
for example "already logged in".
public Exception getLoginFailedCause()
public void setLoginFailedCause(Exception loginFailedCause)
loginFailedCause - the Exceptionpublic void clearPassword()
public void close()
public void finalize()
finalize in class Objectpublic boolean isOpen()
public long getTxCount()
public String getTxName()
public void setTxObject(DbObject txObject)
DbObject or DbObject.isTxObject() returns true, that object becomes the "parent" of the
transaction. The txObject
is mainly used for logging and enhanced auditing (partial history) during transactions.
The txObject is cleared at the end of the transaction.
txObject - the transaction object, null to clearpublic DbObject getTxObject()
public boolean begin(String txName)
txName - is the optional transaction name, null if none
public boolean begin()
public int getUpdateCount()
public void registerCommitTxRunnable(CommitTxRunnable txRunnable)
CommitTxRunnable to be invoked just before
committing a transaction.
txRunnable - the runnable to registerpublic void registerRollbackTxRunnable(RollbackTxRunnable txRunnable)
RollbackTxRunnable to be invoked just before
rolling back a transaction.
txRunnable - the runnable to registerpublic boolean commit(boolean autoCommit)
autoCommit - the old autoCommit state before begin()
public boolean rollback(boolean autoCommit)
autoCommit - the old autoCommit state before begin()
public int getConnectionId()
public void setGroupId(int number)
number - is the group number, 0 = no grouppublic int getGroupId()
public StatementWrapper createStatement()
Non-prepared statements attach the db as soon as they are instatiated! The db is detached after executeUpdate or after executeQuery when its result set is closed.
public int prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
sql - the SQL stringresultSetType - is one of ResultSet.TYPE_...resultSetConcurrency - is one of ResultSet.CONCUR_..
public int prepareStatement(String sql,
int resultSetType)
sql - the SQL stringresultSetType - is one of ResultSet.TYPE_...
public int prepareStatement(String sql)
sql - the SQL string
public int getResultSetType(int stmtId)
stmtId - the statement id
public int getResultSetConcurrency(int stmtId)
stmtId - the statement id
public String getSqlText(int stmtId)
stmtId - the statement id
public int getStatementId(String sql,
int resultSetType,
int resultSetConcurrency)
sql - the sql stringresultSetType - the result set typeresultSetConcurrency - the concurrency
ResultSet
public int getStatementId(String sql,
int resultSetType)
ResultSet.CONCUR_READ_ONLY.
sql - the sql stringresultSetType - the result set type
ResultSetpublic int getStatementId(String sql)
ResultSet.TYPE_FORWARD_ONLY
and the concurrency as ResultSet.CONCUR_READ_ONLY.
sql - the sql string
ResultSetpublic PreparedStatementWrapper getPreparedStatement(int id)
Getting the prepared statement will attach the db to a connection. The db will be detached after executeUpdate() or executeQuery when its result set is closed.
id - the statement id
public PreparedStatementWrapper getPreparedStatement(String sql,
int resultSetType,
int resultSetConcurrency)
sql - the SQL stringresultSetType - is one of ResultSet.TYPE_...resultSetConcurrency - is one of ResultSet.CONCUR_..
public PreparedStatementWrapper getPreparedStatement(String sql,
int resultSetType)
sql - the SQL stringresultSetType - is one of ResultSet.TYPE_...
public PreparedStatementWrapper getPreparedStatement(String sql)
sql - the SQL string
public boolean isAutoCommit()
public UserInfo getUserInfo()
public void setUserInfo(UserInfo ui)
ui - the userinfo.public String getUrl()
public String getDriver()
public Db clone()
Connections may be cloned, which results in a new connection using the cloned userinfo of the original connection. If the old db is already open, the new db will be opened as well. If the old db is closed, the cloned db will be closed.
clone in class ObjectCloneablepublic Db getClonedFromDb()
public void clearCloned()
public boolean isCloned()
public int getFetchSize()
public void setFetchSize(int fetchSize)
fetchSize - the new default fetchSizepublic int getMaxRows()
public void setMaxRows(int maxRows)
maxRows - the max rows, 0 = no limit (default)public boolean isRemote()
public void assertNotRemote()
public void assertRemote()
public static int prepareRemoteDelegate(Class clazz)
RemoteDelegate.
The delegates for the DbObject-classes "live" in the db, i.e. the remote session. Thus, delegates are unique per class AND db! In order for the DbObject-derived classes to quickly map to the corresponding delegate, the delegates get a unique handle, i.e. an index to an array of delegates, which in turn is unique among ALL sessions.
clazz - is the DbObject-class
public RemoteDelegate getRemoteDelegate(int id)
id - is the handle for the delegate
public boolean isCountModificationAllowed()
public void setCountModificationAllowed(boolean countModificationAllowed)
countModificationAllowed - true if allowed, false if turned offpublic ModificationCounter getModificationCounter(String tableName)
ModificationCounter for a given tablename.
If a counter does not exists, a new one will be created.
tableName - is the name of the table
public void setLogModificationAllowed(boolean logModificationAllowed)
logModificationAllowed - true to allow, false to denypublic boolean isLogModificationAllowed()
public void setLogModificationDeferred(boolean logModificationDeferred)
ModificationLog objects are not written to the database.
Instead they are kept in memory and can be processed later via
getDeferredModificationLogList().
The state will be handed over to the remote db-connection as well.
Note: deferred logs are used to minimize roundtrips in distributed applications. See the PoolKeeper project for more details.
logModificationDeferred - true to allow, false to denypublic boolean isLogModificationDeferred()
public void appendDeferredModificationLog(ModificationLog log)
ModificationLog object to the deferred log list.
log - the modlog object to appendpublic List<ModificationLog> getDeferredModificationLogList()
ModificationLogs.
Upon return the list of deferred logs is always cleared.
public static void applyToDbObject(Db db,
DbObject obj)
db - the db connectionobj - the database object
public static void applyToCollection(Db db,
Collection<? extends DbObject> list)
db - the db connectionlist - the collection of database objectspublic IdSource getDefaultIdSource()
IdSource.
public void setDefaultIdSource(IdSource idSource)
IdSource.
idSource - New value of property idSource.public int addIdSource(IdSource idSource)
idSource - source to get a handle for
public IdSource getIdSource(int id)
id - handle of the IdSource
public void setIdSource(int id,
IdSource idSource)
id - handle of the IdSourceidSource - the IdSource or null if not prepared yet for this db-connectionpublic boolean isUniqueViolation()
public void setUniqueViolation(boolean uniqueViolation)
uniqueViolation - true if violation, false if notpublic boolean isUniqueViolationLogEnabled()
public void setUniqueViolationLogEnabled(boolean logUniqueViolation)
logUniqueViolation - true if unique violations are logged (default)public long getLogModificationTxId()
public void setLogModificationTxId(long logModificationTxId)
logModificationTxId - the transaction IDpublic boolean isLogModificationTxEnabled()
public void setLogModificationTxEnabled(boolean logModificationTxEnabled)
ModificationLog
as well.
logModificationTxEnabled - true to turn on transaction logging.public String getDbUser()
public char[] getDbPassword()
public boolean isObfuscatedLogin()
public boolean isPostgres()
public boolean isIngres()
public boolean isMysql()
public boolean isOracle()
public boolean isInformix()
public boolean isMssql()
public boolean isDb2()
public boolean sqlRequiresExtraCommit()
Connection.setAutoCommit(boolean)(true)
should commit, but some backends require an extra Connection.commit().
public boolean sqlRequiresLimitAppended()
public boolean sqlRequiresNestedLimitSelect()
public String sqlFormatLimitClause(String par)
par - is either a hard-coded parameter or '?' in prepared statements
public boolean sqlRequiresOffsetAppended()
public boolean sqlRequiresNestedOffsetSelect()
public String sqlFormatOffsetClause(String par)
par - is either a hard-coded parameter or '?' in prepared statements
public boolean sqlRequiresLimitOffsetAppended()
public boolean sqlRequiresLimitBeforeOffset()
public boolean sqlRequiresNestedLimitOffsetSelect()
public String sqlFormatLimitOffsetClause(String limitPar,
String offsetPar)
limitPar - the sql string for the limit parameter valueoffsetPar - the sql string for the offset parameter value
public boolean sqlResultSetIsClosedSupported()
public StringBuilder addLimitOffsetToSql(StringBuilder sql,
int limit,
int offset)
sql - the original SQL string bufferlimit - the limit value, ≤ 0 if no limit clauseoffset - the offset value, ≤ 0 if no offset clause
prependLimitOffsetToPreparedStatement(int, org.tentackle.db.PreparedStatementWrapper, int, int),
appendLimitOffsetToPreparedStatement(int, org.tentackle.db.PreparedStatementWrapper, int, int)
public int prependLimitOffsetToPreparedStatement(int ndx,
PreparedStatementWrapper st,
int limit,
int offset)
ndx - starting parameter index, usually 1st - the prepared statementlimit - the limit value, ≤ 0 if no limit clauseoffset - the offset value, ≤ 0 if no offset clause
#addLimitOffsetToSql(java.lang.String, int, int)
public int appendLimitOffsetToPreparedStatement(int ndx,
PreparedStatementWrapper st,
int limit,
int offset)
ndx - starting parameter indexst - the prepared statementlimit - the limit value, ≤ 0 if no limit clauseoffset - the offset value, ≤ 0 if no offset clause
#addLimitOffsetToSql(java.lang.String, int, int)public Thread createKeepAliveThread(long interval)
ModificationThread.runOnce(java.lang.Runnable).
Example:
Thread keepAliveThread = db.createKeepAliveThread(5000);
keepAliveThread.start();
...
...
keepAliveThread.interrupt();
keepAliveThread.join();
interval - the interval in [ms] to trigger the alive signal
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||