All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.vaccess.SQLConnection

java.lang.Object
   |
   +----com.ibm.as400.vaccess.SQLConnection

public class SQLConnection
extends Object
implements Serializable
SQLConnection objects represent a SQL Connection. A SQLConnection object encapsulates the properties needed to make a JDBC Connection into a Java Bean. A connection can only be made once. Once a connection is closed, it cannot be opened again.

The actual connection is made when getConnection() is called.

Users should call close() when the connection is no longer needed.

Properties cannot be changed once a connection is made.

Note that the password is not serialized if it is provided by the password parameter on the constructor or setPassword(), or if it is provided using the 'password' property in the constructor 'properties' parameter or using setProperties(). If the password is supplied through the URL or other property, it will be serialized.

SQLConnection objects generate the following events:


Constructor Index

 o SQLConnection()
Creates a SQLConnection object.
 o SQLConnection(String)
Creates a SQLConnection object.
 o SQLConnection(String, Properties)
Creates a SQLConnection object.
 o SQLConnection(String, String)
Creates a SQLConnection object.
 o SQLConnection(String, String, String)
Creates a SQLConnection object.

Method Index

 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property is changed.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property is changed.
 o addWorkingListener(WorkingListener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.
 o close()
Closes the SQL connection, if it is open.
 o getConnection()
Returns a JDBC connection.
 o getProperties()
Returns the properties for this connection.
 o getURL()
Returns the URL for this connection.
 o getUserName()
Returns the user name for this connection.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a listener from being notified when the value of any bound property is changed.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a listener from being notified when the value of any constrained property is changed.
 o removeWorkingListener(WorkingListener)
Removes a listener from being notified when work starts and stops on potentially long-running operations.
 o setPassword(String)
Sets the password used to connect to the database.
 o setProperties(Properties)
Sets the properties used to connect to the database.
 o setURL(String)
Sets the URL used to connect to the database.
 o setUserName(String)
Sets the user name used to connect to the database.

Constructors

 o SQLConnection
 public SQLConnection()
Creates a SQLConnection object.

 o SQLConnection
 public SQLConnection(String URL)
Creates a SQLConnection object.

Parameters:
URL - The URL used to connect to the database.
 o SQLConnection
 public SQLConnection(String URL,
                      String userName)
Creates a SQLConnection object.

Parameters:
URL - The URL used to connect to the database.
userName - The user name used to connect to the database.
 o SQLConnection
 public SQLConnection(String URL,
                      String userName,
                      String password)
Creates a SQLConnection object.

Parameters:
URL - The URL used to connect to the database.
userName - The user name used to connect to the database.
password - The password used to connect to the database.
 o SQLConnection
 public SQLConnection(String URL,
                      Properties properties)
Creates a SQLConnection object.

Parameters:
URL - The URL used to connect to the database.
properties - The properties used to connect to the database.

Methods

 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property is changed. The listener's propertyChange() method will be called.

Parameters:
listener - The listener.
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed. The listener's vetoableChange() method will be called.

Parameters:
listener - The listener.
 o addWorkingListener
 public void addWorkingListener(WorkingListener listener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o close
 public void close() throws SQLException
Closes the SQL connection, if it is open. Once a connection is closed, it cannot be opened again.

Throws: SQLException
If there is an error closing the connection.
 o getConnection
 public Connection getConnection() throws SQLException
Returns a JDBC connection. If a successful connection has not yet been made, a new connection will be made. Subsequent invocations will reuse the connection. It is up to the user to close the connection, or allow garbage collection to do so.

Returns:
The connection.
Throws: SQLException
If there is an error connecting to the database.
 o getProperties
 public Properties getProperties()
Returns the properties for this connection. This method will return the properties as set by the constructor or the last setProperties() call, minus the 'password' property, if included.

Returns:
The properties for this connection.
 o getURL
 public String getURL()
Returns the URL for this connection. If a connection has not yet been made, this method will return the URL supplied on the constructor or the last setURL() call. If a connection has been made, the URL will be the URL for the connection.

Returns:
The URL for this connection.
 o getUserName
 public String getUserName()
Returns the user name for this connection. If a connection has not yet been made, this method will return the user name supplied on the constructor or the last setUserName() call. If a connection has been made, the user name will be the user name being used for the connection.

Returns:
The user name for this connection.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from being notified when the value of any bound property is changed.

Parameters:
listener - The listener.
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a listener from being notified when the value of any constrained property is changed.

Parameters:
listener - The listener.
 o removeWorkingListener
 public void removeWorkingListener(WorkingListener listener)
Removes a listener from being notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o setPassword
 public void setPassword(String password) throws PropertyVetoException
Sets the password used to connect to the database. This property cannot be changed after a connection is made by calling getConnection(). This property is bound and constrained. The events will always have null and an empty string for the old and new value, respectively.

Parameters:
password - The password used to connect to the database.
Throws: PropertyVetoException
If the change is vetoed.
 o setProperties
 public void setProperties(Properties properties) throws PropertyVetoException
Sets the properties used to connect to the database. This property cannot be changed after a connection is made by calling getConnection(). This property is bound and constrained.

Parameters:
properties - The properties used to connect to the database.
Throws: PropertyVetoException
If the change is vetoed.
 o setURL
 public void setURL(String URL) throws PropertyVetoException
Sets the URL used to connect to the database. This property cannot be changed after a connection is made by calling getConnection(). This property is bound and constrained.

Parameters:
URL - The URL used to connect to the database.
Throws: PropertyVetoException
If the change is vetoed.
 o setUserName
 public void setUserName(String userName) throws PropertyVetoException
Sets the user name used to connect to the database. This property cannot be changed after a connection is made by calling getConnection(). This property is bound and constrained.

Parameters:
userName - The user name used to connect to the database.
Throws: PropertyVetoException
If the change is vetoed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index