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