|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.db.DBConnection
Generic database connection object - hides the implementation details of using jdbc and allows for JDBC message and exceptions to be handled better than by default. DBConnection's are also designed to be used in conjunction with connection pooling, and have special methods to support this.
| Field Summary | |
static String |
DEFAULT_DB_CONTEXT_NAME
Constant name for the 'Default' database context |
static int |
LIMITATION_AFTER_ORDER_BY
Insert the limitation syntax after ORDER BY key words
SELECT {COLUMNS}... |
static int |
LIMITATION_AFTER_SELECT
Insert the limitation syntax after TABLE nomination
SELECT {limitation-syntax}
{COLUMNS}... |
static int |
LIMITATION_AFTER_TABLE
Insert the limitation syntax after TABLE nomination
SELECT {COLUMNS}... |
static int |
LIMITATION_AFTER_WHERE
Insert the limitation syntax after WHERE key word
SELECT {COLUMNS}... |
static int |
LIMITATION_DISABLED
Limitation syntax database vendor specific optimisation is disabled author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001 |
protected DBConnectionPool |
parentPool
The ConnectionPool that created this connection. |
static int |
TRANSACTION_DIRTY_MODE
Uncommitted read transaction mode author Yves Henri AMAIZO, Mon Dec 22 10:30:59 2003 |
static int |
TRANSACTION_EXCLUSIVE_MODE
Serializable read transaction mode author Yves Henri AMAIZO, Mon Dec 22 10:30:59 2003 |
static int |
TRANSACTION_NORMAL_MODE
Committed read transaction mode author Yves Henri AMAIZO, Mon Dec 22 10:30:59 2003 |
static int |
TRANSACTION_RESTRICTIVE_MODE
Repeatable read transaction mode author Yves Henri AMAIZO, Mon Dec 22 10:30:59 2003 |
| Constructor Summary | |
DBConnection(com.jcorporate.expresso.core.db.config.JDBCConfig newConfigJdbc)
Constructor Create a new connection object |
|
DBConnection(String newDBDriver,
String newDBURL,
String newDBConnectFormat)
Constructor Create a new connection object |
|
DBConnection(String newDBDriverType,
String newDBDriver,
String newDBURL,
String newDBConnectFormat)
Constructor Create a new connection object |
|
| Method Summary | |
void |
checkTimeOut()
Checks if this connectino has timed out. |
void |
clear()
Clear all result sets and statements associated with this connection |
void |
clearCallableStatement()
Clear a callable statement associated with this record. |
void |
clearPreparedStatement()
Clear a prepared statement associated with this record. |
void |
commit()
Send a COMMIT to the database, closing the current transaction If the database driver claims it doesn't support transactions, then we skip this. |
void |
connect(JndiDataSource newJndiDS)
Connect to the database, ready to execute statements |
void |
connect(String newLogin,
String newPassword)
Connect to the database, ready to execute statements |
void |
connectionSetup(String newDBDriverType,
String newDBDriver,
String newDBURL,
String newDBConnectFormat)
Sets up the connection whether JDBC or JNDI Datasources |
CallableStatement |
createCallableStatement(String sqlString)
Creates a CallableStatment object. |
PreparedStatement |
createPreparedStatement(String sqlString)
Creates a PreparedStatment object. |
Statement |
createStatement()
Return a Statement object from this connection - for compatibility with the DBConnection object in Turbine |
void |
disconnect()
Close the connection to the database |
void |
execute()
Execute the actual query Queries executed by this method are expected to return a result - use executeUpdate for queries that do not. |
void |
execute(String theSQL)
One-step execute that sets the query on the fly NOTE: Do not use for UPDATE or DELETE, use executeUpdate instead This method throws DBException if no result set is returned |
void |
executeProcedure()
Execute the actual store procedure in callableStatment Store procedures method are expected to return a result - use executeUpdate for queries that do not. |
void |
executeUpdate(String theSQL)
One-step executeUpdate - for statements that don't return a result set No result set is expected from this method, but the getUpdateCount() method can be called to see how many rows were affected |
void |
finalize()
Disconnect abandoned connections |
boolean |
first()
Scroll to the first record in the result set |
boolean |
getAutoCommit()
Return the state of the auto-commit flag |
BigDecimal |
getBigDecimal(int fieldNum)
Retrieves a BigDecimal object from the resultset |
InputStream |
getBinaryStream(int fieldNum)
Retrieves a Large object as a binary stream. |
InputStream |
getBinaryStream(String fieldName)
Retrieves a Large object as a binary stream. |
Blob |
getBlob(int fieldNum)
Retrieves a BLOB object from the result set. |
Blob |
getBlob(String fieldName)
Retrieves a BLOB object from the result set. |
byte[] |
getBytes(int fieldNum)
Get the BLOB bytes for this particular dataset row. |
String |
getCatalog()
Return the Catalog for the current connection |
Clob |
getClob(int fieldNum)
Retrieves a BLOB object from the result set. |
Clob |
getClob(String fieldName)
Retrieves a BLOB object from the result set. |
Connection |
getConnection()
Low level function that allows you to retrieve the JDBC connection associated with this DBConnection. |
long |
getCreatedTime()
Retrieve the time that this connection was created in System time. |
String |
getDataContext()
Retrieve the data context name we're associated with |
Date |
getDate(int fieldNum)
Return the value in the named field as a string, trimming off any trailing whitespace |
Date |
getDate(String fieldName)
Return the value in the named field as a string, trimming off any trailing whitespace |
String |
getDateTimeType()
getDateTimeType allows DBObjects to ask what the correct database type is for date/time values |
String |
getDBDriver()
Send back the name of the JDBC driver class being used to access the database |
DatabaseMetaData |
getDBMetaData()
Return the DatabaseMetaData for the connection |
String |
getDBName()
Returns the name of the currently set DataContext |
String |
getDBURL()
Return the URL field for this connection |
String |
getDescription()
Returns the text description of this connection. |
double |
getDouble(int fieldNum)
Fetch the given field of the current row as a double |
EscapeHandler |
getEscapeHandler()
Gets the Escape Handler class for this connection |
Hashtable |
getFields(String tableName)
Deprecated. Use getFieldsMap() instead |
HashMap |
getFieldsMap(String tableName)
Get a hashtable that contains a set of field/type values for the given table |
int |
getId()
Get's the id of this connection. |
boolean |
getImmortal()
Gets whether or not if this connection times out. |
int |
getInt(int fieldNum)
Fetch the given field of the current row as an integer |
com.jcorporate.expresso.core.db.config.JNDIConfig |
getJNDIConfig(com.jcorporate.expresso.core.db.config.JDBCConfig curConfig)
|
long |
getLastTouched()
getLastTouched method is used to tell when the last time a connection was used. |
int |
getLimitationPosition()
programmatically gets the limitation optimisation insertion position author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001 |
String |
getLimitationSyntax()
programmatically gets the limitation syntax string |
String |
getLogin()
Return the login name used to connect to the database |
long |
getLong(int fieldNum)
Fetch the given field of the current row as a long |
ResultSetMetaData |
getMetaData()
Return the ResultSetMetaData from the last executed query |
DBConnectionPool |
getParentPool()
Retrieve what DBConnectionPool 'owns' this pool |
String |
getPassword()
Return the password string being used to connect to the database |
ResultSet |
getResultSet()
Retrieve the current result set in the connection. |
String |
getSQL()
Gets the SQL string to be executed |
String |
getString(int fieldNum)
Return the value in the numbered field as a string, trimming off any trailing whitespace |
String |
getString(String fieldName)
Return the value in the named field as a string, trimming off any trailing whitespace |
String |
getStringNoTrim(int fieldNum)
Return the numbered field as a string, not trimming any trailing spaces |
String |
getStringNoTrim(String fieldName)
Return the value in the named field as a string |
Date |
getTime(int fieldNum)
Return the value in the named field as a string, trimming off any trailing whitespace |
Date |
getTime(String fieldName)
Return the value in the named field as a string, trimming off any trailing whitespace |
Date |
getTimestamp(int fieldNum)
Return the value in the named field as a string, trimming off any trailing whitespace |
Date |
getTimestamp(String fieldName)
Return the value in the named field as a string, trimming off any trailing whitespace |
int |
getTransactionMode()
Return the Database current transaction mode set. |
Hashtable |
getTypeMap()
Attempt to return a mapping of java.sql.Type types to actual type names used by this database. |
int |
getUpdateCount()
Returns the number of rows affected by the last operation . |
Enumeration |
getWildCards()
Deprecated. 9/04, v5.5+ use DBConnectionPool.getDefaultWildCards() instead |
ArrayList |
getWildCardsList()
Deprecated. 9/04, v5.5+ use DBConnectionPool.getDefaultWildCards() instead |
boolean |
isAvailable()
When this connection is used as part of a pool of connections, tell whether or not it is available to be re-allocated |
boolean |
isClosed()
When this connection has lost its connection to the server, tell whether or not it is available to be re-allocated |
boolean |
isStringNotTrim()
Trim or not trim parameter set for this connection |
boolean |
isTransactionNotActive()
Trim or not trim parameter set for this connection |
boolean |
next()
Scroll to the next record in the result set |
void |
release()
Releases the DBConnection back into the parent DBConnectionPool. |
void |
rollback()
Roll back the current transaction, as if it were never requested. |
void |
setAutoCommit(boolean b)
Set auto-commit on or off for this connection. |
void |
setAvailable(boolean newAvailable)
When this connection is used as part of a pool of connections, tell whether or not it is available to be re-allocated |
void |
setDataContext(String newDBName)
Sets the data context for the connection. |
void |
setDateTimeType(String newDateTimeType)
setDateTimeType method allows the default database type of "datetime" to be overridden for databases where this is not the type for date and time values (e.g. |
void |
setDBName(String newDBName)
Sets the data context for the connection. |
void |
setDescription(String newDescription)
Set a description for this database connection. |
void |
setEscapeHandler(EscapeHandler newValue)
Sets the Escape Handler class for this connection |
void |
setImmortal(boolean newImmortal)
Sets this connection to be immortal, ie it never gets removed or disconnected |
void |
setJDBCCondig(com.jcorporate.expresso.core.db.config.JDBCConfig config)
|
void |
setParentPool(DBConnectionPool newParentPool)
Sets the parentPool... this is done by the DBConnecitonPool object. |
void |
setSQL(String sqlStatement)
Set the SQL to be run against the database |
void |
setTransactionCommittedMode()
Set EXPRESSO transaction mode for the current DBConnection. |
void |
setTransactionIsolation(int isolationMode)
Set Database transaction isolation mode. |
void |
setTransactionMode(int transactionMode)
Set EXPRESSO transaction mode for the current DBConnection. |
void |
setTransactionRepeatableMode()
Set EXPRESSO transaction mode for the current DBConnection. |
void |
setTransactionSerializableMode()
Set EXPRESSO transaction mode for the current DBConnection. |
void |
setTransactionUncommittedMode()
Set EXPRESSO transaction mode for the current DBConnection. |
boolean |
supportsTransactions()
Checks if the Database Metadata claims that this database supports transactions. |
void |
touch()
Update the last touched date/time for this connection |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String DEFAULT_DB_CONTEXT_NAME
public static final int LIMITATION_DISABLED
public static final int LIMITATION_AFTER_TABLE
SELECT {COLUMNS}... FROM {TABLE}
{limitation-syntax}
[ WHERE {where_clause}... ]
[ ORDER BY {order_by_clause}... ]
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
public static final int LIMITATION_AFTER_WHERE
SELECT {COLUMNS}... FROM {TABLE}
[ WHERE {where_clause}... ]
AND {limitation-syntax}
[ ORDER BY {order_by_clause}... ]
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
public static final int LIMITATION_AFTER_ORDER_BY
SELECT {COLUMNS}... FROM {TABLE}
[ WHERE {where_clause}... ]
[ ORDER BY {order_by_clause}... ]
{limitation-syntax}
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
public static final int LIMITATION_AFTER_SELECT
SELECT {limitation-syntax}
{COLUMNS}... FROM {TABLE}
[ WHERE {where_clause}... ]
[ ORDER BY {order_by_clause}... ]
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
public static final int TRANSACTION_NORMAL_MODE
public static final int TRANSACTION_DIRTY_MODE
public static final int TRANSACTION_RESTRICTIVE_MODE
public static final int TRANSACTION_EXCLUSIVE_MODE
protected DBConnectionPool parentPool
| Constructor Detail |
public DBConnection(String newDBDriver,
String newDBURL,
String newDBConnectFormat)
throws DBException
newDBDriver - The class name of the JDBC driver to use for this
connectionnewDBURL - The URL passed to the driver to connect to the
databasenewDBConnectFormat - The style or format of the call to actually
connect to the database. The options are as follows:
DBException - If the information provided cannot be used to
create a new connection
public DBConnection(com.jcorporate.expresso.core.db.config.JDBCConfig newConfigJdbc)
throws DBException
newConfigJdbc - The JDBC driver configuration retrieve from the context
DBException - If the information provided cannot be used to
create a new connection
public DBConnection(String newDBDriverType,
String newDBDriver,
String newDBURL,
String newDBConnectFormat)
throws DBException
newDBDriverType - The JDBC driver Type name to use for this
connectionnewDBDriver - The class name of the JDBC driver to use for this
connectionnewDBURL - The URL passed to the driver to connect to the
databasenewDBConnectFormat - The style or format of the call to actually
connect to the database. The options are as follows:
DBException - If the information provided cannot be used to
create a new connection| Method Detail |
public void connectionSetup(String newDBDriverType,
String newDBDriver,
String newDBURL,
String newDBConnectFormat)
throws DBException
newDBDriverType - The driver type, either "e;datasource"e; or another name
if you want a straight JDBC DrivernewDBDriver - The driver namenewDBURL - the URL of the database drivernewDBConnectFormat - The connection format. See the DBConnection constructors
for more information on what this paramter means.
DBException
public void checkTimeOut()
throws DBException
DBException
public void clear()
throws DBException
DBException
public void commit()
throws DBException
DBException - If the commit does not succeed
public void connect(String newLogin,
String newPassword)
throws DBException
newLogin - Login user name to connect withnewPassword - Password to connect with
DBException - If the connection does not succeed
public void connect(JndiDataSource newJndiDS)
throws DBException
newJndiDS - a configuration bean describing the connection
datasource properties.
DBException - If the connection does not succeed
author Yves Henri AMAIZO (Creation)public Statement createStatement()
public PreparedStatement createPreparedStatement(String sqlString)
PreparedStatment object.
sqlString - The string to create the prepared statement with.
public void clearPreparedStatement()
public CallableStatement createCallableStatement(String sqlString)
CallableStatment object.
sqlString - The string to create the callable statement with.
public void clearCallableStatement()
public void disconnect()
throws DBException
DBException - If the connection could not be closed successfully.
public void execute()
throws DBException
DBException - If the query fails or is an update query.
public void execute(String theSQL)
throws DBException
theSQL - An SQL statement to be executed on the database
DBException
public void executeUpdate(String theSQL)
throws DBException
theSQL - The SQL Statement to be executed. May be null if you're
executing a prepared statement
DBException - If the update fails
public void executeProcedure()
throws DBException
DBException - If the query fails or is an update query.public void finalize()
public boolean first()
throws DBException
DBException - If the database connection returns an error
public boolean getAutoCommit()
throws DBException
DBException - If the current state of auto-commit cannot
be determined due to an invalid connection
or other database error.
public String getCatalog()
throws DBException
DBException
public Clob getClob(int fieldNum)
throws DBException
Important Note: Unlike any of the other data types, You must be finished with BLOBs and CLOBs before closing the connection or moving on to other result sets
fieldNum - The field number [ie order in the resultset]
DBException - upon error retrieving the BLOB data type.
public Clob getClob(String fieldName)
throws DBException
Important Note: Unlike any of the other data types, You must be finished with BLOBs and CLOBs before closing the connection or moving on to other result sets
fieldName - The field name to retrieve
DBException - upon error retrieving the BLOB data type.public long getCreatedTime()
public BigDecimal getBigDecimal(int fieldNum)
throws DBException
fieldNum - the column index
DBException - upon error accessing the object
public Blob getBlob(int fieldNum)
throws DBException
Important Note: Unlike any of the other data types, You must be finished with BLOBs and CLOBs before closing the connection or moving on to other result sets
fieldNum - The field number [ie order in the resultset]
DBException - upon error retrieving the BLOB data type.
public Blob getBlob(String fieldName)
throws DBException
Important Note: Unlike any of the other data types, You must be finished with BLOBs and CLOBs before closing the connection or moving on to other result sets
fieldName - The field name to retrieve
DBException - upon error retrieving the BLOB data type.
public InputStream getBinaryStream(String fieldName)
throws DBException
fieldName - the name of the field to retrieve
DBException - if there's an error retrieving from the database
public InputStream getBinaryStream(int fieldNum)
throws DBException
fieldNum - the number of the field to retrieve
DBException - if there's an error retrieving from the database
public byte[] getBytes(int fieldNum)
throws DBException
fieldNum - The number in the row to retrieve
DBException - upon error accessing the streampublic String getDateTimeType()
public Connection getConnection()
public String getDBDriver()
public DatabaseMetaData getDBMetaData()
throws DBException
DBException
public boolean supportsTransactions()
throws DBException
DBExceptionpublic String getDBURL()
public String getDescription()
public double getDouble(int fieldNum)
throws DBException
fieldNum - The number of the field to return
DBException - if no such field or some other JDBC error
public Hashtable getFields(String tableName)
throws DBException
tableName - Name of the table to read fields for
DBException - If the given table cannot be scanned for
it's fields.public EscapeHandler getEscapeHandler()
EscapeHandler compliant interface
public HashMap getFieldsMap(String tableName)
throws DBException
tableName - Name of the table to read fields for
DBException - If the given table cannot be scanned for
it's fields.public int getId()
public boolean getImmortal()
public int getInt(int fieldNum)
throws DBException
fieldNum - The number of the desired field
DBException - If an error occurrs accessing the valuepublic long getLastTouched()
public int getLimitationPosition()
public String getLimitationSyntax()
public String getLogin()
public long getLong(int fieldNum)
throws DBException
fieldNum - The long value of the given field number
DBException - if no such field or some other JDBC errorpublic ResultSetMetaData getMetaData()
public String getPassword()
public ResultSet getResultSet()
Like any of the lower level methods such as getConnection(), be careful with what you do with the ResultSet or you may leave the entire Connection Pool in an undefined state
You do not have to explicitly close the ResultSet when you're done with it because DBConnectionPool.release(DBConnection) will explicitly clear all resultsets
public String getSQL()
public String getString(int fieldNum)
throws DBException
fieldNum - The desired field number
DBException - If the value cannot be accessed
public String getStringNoTrim(int fieldNum)
throws DBException
fieldNum - The number of the desired field
DBException - If an error occurrs accessing the given field
public String getString(String fieldName)
throws DBException
fieldName - The desired column name
DBException - If the value cannot be accessed
public String getStringNoTrim(String fieldName)
throws DBException
fieldName - The desired column name
DBException - If the value cannot be accessed
public Date getTimestamp(String fieldName)
throws DBException
fieldName - The desired column name
DBException - If the value cannot be accessed
author Yves Henri AMAIZO
public Date getTimestamp(int fieldNum)
throws DBException
fieldNum - The desired column number
DBException - If the value cannot be accessed
author Yves Henri AMAIZO
public Date getTime(String fieldName)
throws DBException
fieldName - The desired column name
DBException - If the value cannot be accessed
author Yves Henri AMAIZO
public Date getTime(int fieldNum)
throws DBException
fieldNum - The desired column number
DBException - If the value cannot be accessed
author Yves Henri AMAIZO
public Date getDate(String fieldName)
throws DBException
fieldName - The desired column name
DBException - If the value cannot be accessed
author Yves Henri AMAIZO
public Date getDate(int fieldNum)
throws DBException
fieldNum - The desired column name
DBException - If the value cannot be accessed
author Yves Henri AMAIZOpublic Hashtable getTypeMap()
public int getUpdateCount()
public Enumeration getWildCards()
public ArrayList getWildCardsList()
public int getTransactionMode()
throws DBException
DBExceptionpublic boolean isAvailable()
public boolean isClosed()
throws DBException
DBException
public boolean next()
throws DBException
DBException - If a JDBC error occurred while scrolling
public void rollback()
throws DBException
DBException - If the rollback encounters an error
public void setAutoCommit(boolean b)
throws DBException
b - True to enable auto-commit, false to disable it
DBException - upon errorpublic void setAvailable(boolean newAvailable)