Class powersoft.jcm.db.JDBCTransaction
All Packages Class Hierarchy This Package Previous Next Index
Class powersoft.jcm.db.JDBCTransaction
java.lang.Object
|
+----powersoft.jcm.db.JDBCTransaction
- public class JDBCTransaction
- extends Object
- implements Transaction
Encapsulates the connection to a database. This includes a specific
implementation of the Transaction interface.
- See Also:
- Transaction, Query
-
JDBCTransaction()
-
-
addQuery(Query)
- Associates a query with the transaction object.
Notes: This method is automatically called by a JDBC Query
object.
-
commit()
- Requests a commit for all active data source operations on all
query objects associated with the transaction object.
-
connect()
- Connects the transaction object to a data source.
-
createStatement()
- Creates a java.sql.Statement object from the connection.
-
disconnect()
- Closes the connection, if one exists, between a data source and
the transaction object.
-
finalize()
- Calls setTransactionObject(null) on all associated queries.
-
getAutoCommit()
- Gets the auto-commit mode.
-
getConnected()
- Determines whether the transaction object is connected to a
data source.
-
getConnectionObject()
- Gets the internal java.sql.Connection object used by this Transaction
object.
-
getDataSource()
- Gets the name of the data source (database) the transaction
object is connected to.
-
getLoginTimeout()
- Gets the maximum time in seconds that all JDBCTransaction objects
can wait when attempting to connect to a database.
-
getPassword()
- Gets the password used in the connection.
-
getProperty(String)
- Gets a property used in the connection.
-
getTraceToLog()
- Gets the TraceToLog property.
-
getUserid()
- Gets the user ID used in the connection.
-
loadDriver(String)
- Loads a JDBC driver.
-
removeQuery(Query)
- Disassociates a query with the transaction object.
Notes: This method is automatically called by a JDBC Query
object.
-
rollback()
- Requests a rollback of all active data source operations on all
query objects associated with the transaction object since the
last time the Commit method was invoked.
-
setAutoCommit(boolean)
- Sets the auto-commit mode.
The default value of the property is true.
-
setDataSource(String)
- Sets the URL of the data source the transaction object is to
connected to.
-
setLoginTimeout(int)
- Set the maximum time in seconds that all JDBCTransaction objects
can wait when attempting to connect to a database.
-
setPassword(String)
- Sets the password used in the connection.
-
setProperty(String, String)
- Sets a property used in the connection.
-
setTraceToLog(boolean)
- Sets the TraceToLog property.
The TraceToLog property determines whether the object records
important actions in the debug log.
Notes: Information is only written to the debug log when
you run a Debug version of the application.
-
setUserid(String)
- Sets the user ID used in the connection.
JDBCTransaction
public JDBCTransaction()
addQuery
public void addQuery(Query query)
- Associates a query with the transaction object.
Notes: This method is automatically called by a JDBC Query
object.
- Parameters:
- query - The query to be associated with the transaction object.
commit
public synchronized boolean commit()
- Requests a commit for all active data source operations on all
query objects associated with the transaction object. The
transaction object must be in manual-commit mode for this
method to have any effect.
- Returns:
-
true
if the commit operation was successful,
false
if the commit operation failed.
- Throws: IllegalStateException
- if a
connection doesn't exist
connect
public synchronized boolean connect()
- Connects the transaction object to a data source.
- Returns:
-
true
if the connection was succesfully established;
false
otherwise.
createStatement
public synchronized Statement createStatement()
- Creates a java.sql.Statement object from the connection.
- Throws: IllegalStateException
- if a connection
has not been made
- Throws: RuntimeExceptionBase
- if a statement cannot be created
using the connection
disconnect
public synchronized boolean disconnect()
- Closes the connection, if one exists, between a data source and
the transaction object.
- Returns:
-
true
if it was successfully closed or if there was no
connection. false
if the connection could not be closed.
removeQuery
public synchronized void removeQuery(Query query)
- Disassociates a query with the transaction object.
Notes: This method is automatically called by a JDBC Query
object.
- Parameters:
- query - The query to be disassociated.
rollback
public synchronized boolean rollback()
- Requests a rollback of all active data source operations on all
query objects associated with the transaction object since the
last time the Commit method was invoked. The transaction object
must be in manual-commit mode for this method to have any effect.
- Returns:
-
true
if the rollback operation was successful;
false
otherwise.
- Throws: IllegalStateException
- a connection
doesn't exist
loadDriver
public static synchronized boolean loadDriver(String driverName)
- Loads a JDBC driver.
- Parameters:
- driverName - class name of the JDBC driver
- Returns:
-
true
if the JDBC driver is successfully loaded or has
been loaded before; false
otherwise.
getAutoCommit
public boolean getAutoCommit()
- Gets the auto-commit mode.
- Returns:
- the auto-commit mode
setAutoCommit
public synchronized void setAutoCommit(boolean autoCommit)
- Sets the auto-commit mode.
The default value of the property is true.
- Parameters:
- autoCommit - If
true
, the transaction object is in
auto-commit mode. If false
, the transaction object is in
manual-commit mode.
getConnected
public boolean getConnected()
- Determines whether the transaction object is connected to a
data source.
- Returns:
-
true
if the transaction object is connected;
false
otherwise.
getConnectionObject
public Connection getConnectionObject()
- Gets the internal java.sql.Connection object used by this Transaction
object.
Notes: Direct use of the Connection object may make the state
of this JDBCTransaction object inconsistent.
- Returns:
- The JDBC Connection object.
getDataSource
public String getDataSource()
- Gets the name of the data source (database) the transaction
object is connected to.
- Returns:
- The name of the data source.
- See Also:
- connect
setDataSource
public void setDataSource(String dataSource)
- Sets the URL of the data source the transaction object is to
connected to.
- Parameters:
- The - name of the data source.
- See Also:
- connect
getPassword
public String getPassword()
- Gets the password used in the connection.
- Returns:
- The password to be used in the connection.
- See Also:
- connect, setPassword
setPassword
public synchronized void setPassword(String password)
- Sets the password used in the connection.
- Parameters:
- password - The password to be used in the connection.
- See Also:
- connect, getPassword
getProperty
public String getProperty(String property)
- Gets a property used in the connection.
- Returns:
- The value of a property; null if the property has not been
set.
- See Also:
- connect, setProperty
setProperty
public synchronized void setProperty(String property,
String value)
- Sets a property used in the connection.
- See Also:
- connect, getProperty
getUserid
public String getUserid()
- Gets the user ID used in the connection.
- Returns:
- The user ID to be used in the connection.
- See Also:
- connect, setUserid
setUserid
public synchronized void setUserid(String userid)
- Sets the user ID used in the connection.
- Parameters:
- userid - The user ID to be used in the connection.
- See Also:
- connect, getUserid
getTraceToLog
public boolean getTraceToLog()
- Gets the TraceToLog property.
- See Also:
- setTraceToLog
setTraceToLog
public void setTraceToLog(boolean traceToLog)
- Sets the TraceToLog property.
The TraceToLog property determines whether the object records
important actions in the debug log.
Notes: Information is only written to the debug log when
you run a Debug version of the application. With Release versions,
the TraceToLog property has no effect.
- Parameters:
- traceToLog - If
true
and a debug version of the
application is running, information will be written to the debug
log. If false
or a release version of the application
is running, no information will be written to the debug log.
setLoginTimeout
public static void setLoginTimeout(int seconds)
- Set the maximum time in seconds that all JDBCTransaction objects
can wait when attempting to connect to a database.
- Parameters:
- seconds - The login time limit, in seconds.
getLoginTimeout
public static int getLoginTimeout()
- Gets the maximum time in seconds that all JDBCTransaction objects
can wait when attempting to connect to a database.
- Returns:
- The login time limit, in seconds.
finalize
protected void finalize()
- Calls setTransactionObject(null) on all associated queries.
- Overrides:
- finalize in class Object
All Packages Class Hierarchy This Package Previous Next Index