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

Constructor Index

 o JDBCTransaction()

Method Index

 o addQuery(Query)
Associates a query with the transaction object.

Notes: This method is automatically called by a JDBC Query object.

 o commit()
Requests a commit for all active data source operations on all query objects associated with the transaction object.
 o connect()
Connects the transaction object to a data source.
 o createStatement()
Creates a java.sql.Statement object from the connection.
 o disconnect()
Closes the connection, if one exists, between a data source and the transaction object.
 o finalize()
Calls setTransactionObject(null) on all associated queries.
 o getAutoCommit()
Gets the auto-commit mode.
 o getConnected()
Determines whether the transaction object is connected to a data source.
 o getConnectionObject()
Gets the internal java.sql.Connection object used by this Transaction object.
 o getDataSource()
Gets the name of the data source (database) the transaction object is connected to.
 o getLoginTimeout()
Gets the maximum time in seconds that all JDBCTransaction objects can wait when attempting to connect to a database.
 o getPassword()
Gets the password used in the connection.
 o getProperty(String)
Gets a property used in the connection.
 o getTraceToLog()
Gets the TraceToLog property.
 o getUserid()
Gets the user ID used in the connection.
 o loadDriver(String)
Loads a JDBC driver.
 o removeQuery(Query)
Disassociates a query with the transaction object.

Notes: This method is automatically called by a JDBC Query object.

 o 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.
 o setAutoCommit(boolean)
Sets the auto-commit mode.

The default value of the property is true.

 o setDataSource(String)
Sets the URL of the data source the transaction object is to connected to.
 o setLoginTimeout(int)
Set the maximum time in seconds that all JDBCTransaction objects can wait when attempting to connect to a database.
 o setPassword(String)
Sets the password used in the connection.
 o setProperty(String, String)
Sets a property used in the connection.
 o 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.

 o setUserid(String)
Sets the user ID used in the connection.

Constructors

 o JDBCTransaction
  public JDBCTransaction()

Methods

 o 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.
 o 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
 o connect
  public synchronized boolean connect()
Connects the transaction object to a data source.
Returns:
true if the connection was succesfully established; false otherwise.
 o 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
 o 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.
 o 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.
 o 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
 o 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.
 o getAutoCommit
  public boolean getAutoCommit()
Gets the auto-commit mode.
Returns:
the auto-commit mode
 o 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.
 o 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.
 o 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.
 o 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
 o 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
 o getPassword
  public String getPassword()
Gets the password used in the connection.
Returns:
The password to be used in the connection.
See Also:
connect, setPassword
 o 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
 o 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
 o setProperty
  public synchronized void setProperty(String property,
                                       String value)
Sets a property used in the connection.
See Also:
connect, getProperty
 o 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
 o 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
 o getTraceToLog
  public boolean getTraceToLog()
Gets the TraceToLog property.
See Also:
setTraceToLog
 o 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.
 o 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.
 o 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.
 o 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