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:
- Create an instance of the bean.
- Fill in the bean's properties (described below or in superclass):
- autoCommit
- executeInBackground
- JDBCDriverName
- JDBCURL
- password
- readOnly
- transactionIsolation
- userid
- 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:
- exception
- JDBCConnection
- successful
- Utilize various DDL, InsertUpdateDelete and Select
statements to perform SQL operations against the connected database.
- Use the commit() or rollback() methods to terminate the
database transaction. These methods set values and fire property change
events for the following properties:
- 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:
- excception
- JDBCConnection
- successful
- See Also:
- Statement, ConnectionBeanInfo
-
autoCommit
- A flag that specifies whether auto-commit is performed after every
statement execution.
-
COMMIT
- Background thread processing database commit.
-
CONNECT
- Background thread processing connect to database.
-
DISCONNECT
- Background thread processing disconnect from database.
-
JDBCConnection
- The JDBC java.sql.connection.
-
JDBCDriverName
- The JDBC Driver Name is used to instantiate the JDBC Connection.
-
JDBCURL
- The JDBC URL used to instantiate the JDBC Connection.
-
password
- The password of the user using the database.
-
readOnly
- A flag that specifies if the database connection is read-only.
-
ROLLBACK
- Background thread processing database rollback.
-
transactionIsolation
- Transaction isolation values.
-
userid
- The userid of the user using the database.
-
Connection()
- Default constructor.
-
commit()
- Explicitly commit changes to the current database.
-
commitBackground()
- The actual background thread code that explicitly commits changes to
a database.
-
connect()
- Connect to a specified database.
-
connectBackground()
- The actual background thread code that connects to the database.
-
disconnect()
- Disconnect from the current database.
-
disconnectBackground()
- The actual background thread code that disconnects from a database.
-
finalize()
- Finalize this object.
-
getAutoCommit()
- Get the auto-commit flag for the database connection.
-
getJDBCConnection()
- Returns the JDBC database connection object.
-
getJDBCDriverName()
- Get the JDBC Driver Name.
-
getJDBCURL()
- Get the JDBC URL.
-
getPassword()
- Get the password of the user connecting to the database.
-
getReadOnly()
- Get the read-only flag for the database connection.
-
getTransactionIsolation()
- Get the transaction isolation level for the database connection.
-
getUserid()
- Get the userid of the database connection.
-
performWork()
- Call method based on the background task to be performed.
-
rollback()
- Explicitly rollback changes to the current database.
-
rollbackBackground()
- The actual background thread code that explicitly rollbacks changes to
a database.
-
setAutoCommit(boolean)
- Set the auto-commit flag for the database connection.
-
setJDBCConnection(Connection)
- Set the JDBC database connection object.
-
setJDBCDriverName(String)
- Set the JDBC Driver Name.
-
setJDBCURL(String)
- Set the JDBC URL.
-
setPassword(String)
- Set the password of the user connecting to the database.
-
setReadOnly(boolean)
- Set the read-only flag for the database connection.
-
setTransactionIsolation(int)
- Set the transaction isolation level for the database connection.
-
setUserid(String)
- Set the userid of the database connection.
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
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.
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.
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.
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.
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.
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.
transactionIsolation
protected int transactionIsolation
- Transaction isolation values.
This value is used by the connectBackground() method.
Possible values are:
- java.sql.Connection.TRANSACTION_NONE,
- java.sql.Connection.TRANSACTION_READ_COMMITTED,
- java.sql.Connection.TRANSACTION_READ_UNCOMMITTED,
- java.sql.Connection.TRANSACTION_REPEATABLE_READ,
- java.sql.Connection.TRANSACTION_SERIALIZABLE
It must be set prior to execution of the connect() method.
- See Also:
- IsolationEditor
CONNECT
protected static final transient int CONNECT
- Background thread processing connect to database.
DISCONNECT
protected static final transient int DISCONNECT
- Background thread processing disconnect from database.
COMMIT
protected static final transient int COMMIT
- Background thread processing database commit.
ROLLBACK
protected static final transient int ROLLBACK
- Background thread processing database rollback.
Connection
public Connection()
- Default constructor.
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
getJDBCConnection
public Connection getJDBCConnection()
- Returns the JDBC database connection object.
- Returns:
- The java.sql.Connection object; null if not connected.
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.
getJDBCDriverName
public String getJDBCDriverName()
- Get the JDBC Driver Name.
- Returns:
- The JDBC Driver Name specifying how to find the JDBC database driver.
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.
getJDBCURL
public String getJDBCURL()
- Get the JDBC URL.
- Returns:
- The JDBC URL specifying how to find the JDBC database.
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.
getUserid
public String getUserid()
- Get the userid of the database connection.
- Returns:
- The userid for the database connection.
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.
getPassword
public String getPassword()
- Get the password of the user connecting to the database.
- Returns:
- The password for the database password.
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.
getAutoCommit
public boolean getAutoCommit()
- Get the auto-commit flag for the database connection.
- Returns:
- The boolean auto-commit flag for the database connection.
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.
getReadOnly
public boolean getReadOnly()
- Get the read-only flag for the database connection.
- Returns:
- The boolean read-only flag for the database connection.
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.
getTransactionIsolation
public int getTransactionIsolation()
- Get the transaction isolation level for the database connection.
- Returns:
- The integer transaction isolation level for the database
connection.
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
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
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.
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
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.
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
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.
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
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.
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