All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.samples.daps.sql.Connection

java.lang.Object
   |
   +----com.ibm.beans.samples.daps.sql.Common
           |
           +----com.ibm.beans.samples.daps.sql.Connection

public class Connection
extends Common
The Connection class supports a single JDBC database connection.

The JDBCConnection property is then shared by multiple instances of subclasses of the Statement class.

To use the Connection bean, do the following:

  1. Create an instance of the bean.
  2. Fill in the bean's properties (described below or in superclass):
  3. Use the connect() method to connect to the database. The connect() method uses all the above properties to control connection to a database. The connect() method sets values and fires property change events for the following properties on completion:
  4. Utilize various DDL, InsertUpdateDelete and Select statements to perform SQL operations against the connected database.
  5. Use the commit() or rollback() methods to terminate the database transaction. These methods set values and fire property change events for the following properties:
  6. Use the disconnect() method to disconnect from the database. The disconnect() method sets values and fires property change events for the following properties on completion:

See Also:
Statement, ConnectionBeanInfo

Variable Index

 o autoCommit
A flag that specifies whether auto-commit is performed after every statement execution.
 o COMMIT
Background thread processing database commit.
 o CONNECT
Background thread processing connect to database.
 o DISCONNECT
Background thread processing disconnect from database.
 o JDBCConnection
The JDBC java.sql.connection.
 o JDBCDriverName
The JDBC Driver Name is used to instantiate the JDBC Connection.
 o JDBCURL
The JDBC URL used to instantiate the JDBC Connection.
 o password
The password of the user using the database.
 o readOnly
A flag that specifies if the database connection is read-only.
 o ROLLBACK
Background thread processing database rollback.
 o transactionIsolation
Transaction isolation values.
 o userid
The userid of the user using the database.

Constructor Index

 o Connection()
Default constructor.

Method Index

 o commit()
Explicitly commit changes to the current database.
 o commitBackground()
The actual background thread code that explicitly commits changes to a database.
 o connect()
Connect to a specified database.
 o connectBackground()
The actual background thread code that connects to the database.
 o disconnect()
Disconnect from the current database.
 o disconnectBackground()
The actual background thread code that disconnects from a database.
 o finalize()
Finalize this object.
 o getAutoCommit()
Get the auto-commit flag for the database connection.
 o getJDBCConnection()
Returns the JDBC database connection object.
 o getJDBCDriverName()
Get the JDBC Driver Name.
 o getJDBCURL()
Get the JDBC URL.
 o getPassword()
Get the password of the user connecting to the database.
 o getReadOnly()
Get the read-only flag for the database connection.
 o getTransactionIsolation()
Get the transaction isolation level for the database connection.
 o getUserid()
Get the userid of the database connection.
 o performWork()
Call method based on the background task to be performed.
 o rollback()
Explicitly rollback changes to the current database.
 o rollbackBackground()
The actual background thread code that explicitly rollbacks changes to a database.
 o setAutoCommit(boolean)
Set the auto-commit flag for the database connection.
 o setJDBCConnection(Connection)
Set the JDBC database connection object.
 o setJDBCDriverName(String)
Set the JDBC Driver Name.
 o setJDBCURL(String)
Set the JDBC URL.
 o setPassword(String)
Set the password of the user connecting to the database.
 o setReadOnly(boolean)
Set the read-only flag for the database connection.
 o setTransactionIsolation(int)
Set the transaction isolation level for the database connection.
 o setUserid(String)
Set the userid of the database connection.

Variables

 o JDBCConnection
 protected transient Connection JDBCConnection
The JDBC java.sql.connection.

This instance variable is only modified internally. The connectBackground() method sets this value and the disconnectBackground() method clears it. The disconnectBackground(), commitBackground() and rollbackBackground() methods use this property.

The DDL, InsertUpdateDelete and the Select statement beans use this property.

See Also:
Connection
 o JDBCDriverName
 protected String JDBCDriverName
The JDBC Driver Name is used to instantiate the JDBC Connection.

This string identifies the database driver for the connection and is used by the connectBackground() method. It must be set prior to execution of the connect() method.

 o JDBCURL
 protected String JDBCURL
The JDBC URL used to instantiate the JDBC Connection.

This string identifies the database target for the connection and is used by the connectBackground() method. It must be set prior to execution of the connect() method.

 o userid
 protected String userid
The userid of the user using the database.

This string is used by the connectBackground() method. It must be set prior to execution of the connect() method.

 o password
 protected String password
The password of the user using the database.

This string is used by the connectBackground() method. It must be set prior to execution of the connect() method.

 o autoCommit
 protected boolean autoCommit
A flag that specifies whether auto-commit is performed after every statement execution.

This flag is used by the connectBackground() method. It must be set prior to execution of the connect() method.

 o readOnly
 protected boolean readOnly
A flag that specifies if the database connection is read-only.

This flag is used by the connectBackground() method. It must be set prior to execution of the connect() method.

 o transactionIsolation
 protected int transactionIsolation
Transaction isolation values.

This value is used by the connectBackground() method. Possible values are:

It must be set prior to execution of the connect() method.

See Also:
IsolationEditor
 o CONNECT
 protected static final transient int CONNECT
Background thread processing connect to database.

 o DISCONNECT
 protected static final transient int DISCONNECT
Background thread processing disconnect from database.

 o COMMIT
 protected static final transient int COMMIT
Background thread processing database commit.

 o ROLLBACK
 protected static final transient int ROLLBACK
Background thread processing database rollback.

Constructors

 o Connection
 public Connection()
Default constructor.

Methods

 o finalize
 protected void finalize() throws Throwable
Finalize this object.

Disconnect from database if not yet disconnected.

Throws: Throwable
Possibly thrown by the superclass.
Overrides:
finalize in class Common
 o getJDBCConnection
 public Connection getJDBCConnection()
Returns the JDBC database connection object.

Returns:
The java.sql.Connection object; null if not connected.
 o setJDBCConnection
 protected void setJDBCConnection(Connection JDBCConnection)
Set the JDBC database connection object.

Fire the property change event for the JDBCConnection object.

This method can only be called internally via the connect() and disconnect() methods.

Parameters:
JDBCConnection - The JDBC database connection.
 o getJDBCDriverName
 public String getJDBCDriverName()
Get the JDBC Driver Name.

Returns:
The JDBC Driver Name specifying how to find the JDBC database driver.
 o setJDBCDriverName
 public synchronized void setJDBCDriverName(String JDBCDriverName)
Set the JDBC Driver Name.

This value is used by the connect() method.

Fire the property change event for the JDBCDriverName string.

Parameters:
JDBCDriverName - The JDBC Driver name specifying how to find the JDBC database driver.
 o getJDBCURL
 public String getJDBCURL()
Get the JDBC URL.

Returns:
The JDBC URL specifying how to find the JDBC database.
 o setJDBCURL
 public synchronized void setJDBCURL(String JDBCURL)
Set the JDBC URL.

This value is used by the connect() method.

Fire the property change event for the JDBCURL string.

Parameters:
JDBCURL - The JDBC URL specifying how to find the JDBC database.
 o getUserid
 public String getUserid()
Get the userid of the database connection.

Returns:
The userid for the database connection.
 o setUserid
 public synchronized void setUserid(String userid)
Set the userid of the database connection.

This value is used by the connect() method.

Fire the property change event for the userid string.

Parameters:
userid - The userid for the database connection.
 o getPassword
 public String getPassword()
Get the password of the user connecting to the database.

Returns:
The password for the database password.
 o setPassword
 public synchronized void setPassword(String password)
Set the password of the user connecting to the database.

This value is used by the connect() method.

Fire the property change event for the password string.

Parameters:
password - The password for the database password.
 o getAutoCommit
 public boolean getAutoCommit()
Get the auto-commit flag for the database connection.

Returns:
The boolean auto-commit flag for the database connection.
 o setAutoCommit
 public synchronized void setAutoCommit(boolean autoCommit)
Set the auto-commit flag for the database connection.

This value is used by the connect() method.

Fire the property change event for the auto-commit boolean.

Parameters:
autoCommit - The boolean auto-commit flag for the database connection.
 o getReadOnly
 public boolean getReadOnly()
Get the read-only flag for the database connection.

Returns:
The boolean read-only flag for the database connection.
 o setReadOnly
 public synchronized void setReadOnly(boolean readOnly)
Set the read-only flag for the database connection.

This value is used by the connect() method.

Fire the property change event for the read-only boolean.

Parameters:
readOnly - The boolean read-only flag for the database connection.
 o getTransactionIsolation
 public int getTransactionIsolation()
Get the transaction isolation level for the database connection.

Returns:
The integer transaction isolation level for the database connection.
 o setTransactionIsolation
 public synchronized void setTransactionIsolation(int transactionIsolation)
Set the transaction isolation level for the database connection.

This value is used by the connect() method.

Fire the property change event for the transactionIsolation value.

Parameters:
transactionIsolation - The integer transaction isolation level for the database connection.
See Also:
IsolationEditor
 o connect
 public synchronized void connect()
Connect to a specified database.

The JDBCDriverName, JDBCURL, userid, password, autoCommit, readOnly and transactionIsolation properties are used by this method's background thread operation.

The exception, successful and JDBCConnection properties are set indirectly by this method.

See Also:
connectBackground
 o connectBackground
 protected void connectBackground() throws SQLException, ClassNotFoundException, NullPointerException
The actual background thread code that connects to the database.

The JDBCDriverName, JDBCURL, userid, password, autoCommit, readOnly and transactionIsolation properties are used by this method.

The JDBCConnection property is set by this method.

Throws: SQLException
SQL Exception.
Throws: ClassNotFoundException
Class not found.
Throws: NullPointerException
Pointer not set.
 o disconnect
 public synchronized void disconnect()
Disconnect from the current database.

The JDBCConnection property is used by this method's background thread operation.

The exception, successful and JDBCConnection properties are indirectly set by this method.

See Also:
disconnectBackground
 o disconnectBackground
 protected void disconnectBackground() throws SQLException, NullPointerException
The actual background thread code that disconnects from a database.

Throws: SQLException
SQL Exception.
Throws: NullPointerException
Pointer not set.
 o commit
 public synchronized void commit()
Explicitly commit changes to the current database.

The JDBCConnection property is used by this method's background thread operation.

The exception and successful properties are indirectly set by this method.

See Also:
commitBackground
 o commitBackground
 protected void commitBackground() throws SQLException, NullPointerException
The actual background thread code that explicitly commits changes to a database.

The JDBCConnection property is used by this method.

Throws: SQLException
SQL Exception.
Throws: NullPointerException
Pointer not set.
 o rollback
 public synchronized void rollback()
Explicitly rollback changes to the current database.

The JDBCConnection property is used by this method's background thread operation.

The exception and successful properties are indirectly set by this method.

See Also:
rollbackBackground
 o rollbackBackground
 protected void rollbackBackground() throws SQLException, NullPointerException
The actual background thread code that explicitly rollbacks changes to a database.

The JDBCConnection property is used by this method.

Throws: SQLException
SQL Exception.
Throws: NullPointerException
Pointer not set.
 o performWork
 protected void performWork() throws SQLException, ClassNotFoundException, NullPointerException
Call method based on the background task to be performed. The caller has guaranteed this will NOT be called for the INITIAL task.

Throws: SQLException
SQL Exception.
Throws: ClassNotFoundException
Class not found.
Throws: NullPointerException
Pointer not set.
Overrides:
performWork in class Common

All Packages  Class Hierarchy  This Package  Previous  Next  Index