public class SQLConnection
extends java.lang.Object
implements java.io.Serializable
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 via the URL or other property, it will be serialized.
SQLConnection objects generate the following events:
Constructor and Description |
---|
SQLConnection()
Deprecated.
Creates a SQLConnection object.
|
SQLConnection(java.lang.String URL)
Deprecated.
Creates a SQLConnection object.
|
SQLConnection(java.lang.String URL,
java.util.Properties properties)
Deprecated.
Creates a SQLConnection object.
|
SQLConnection(java.lang.String URL,
java.lang.String userName)
Deprecated.
Creates a SQLConnection object.
|
SQLConnection(java.lang.String URL,
java.lang.String userName,
java.lang.String password)
Deprecated.
Creates a SQLConnection object.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Adds a listener to be notified when the value of any bound
property is changed.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Deprecated.
Adds a listener to be notified when the value of any constrained
property is changed.
|
void |
addWorkingListener(WorkingListener listener)
Deprecated.
Adds a listener to be notified when work starts and stops
on potentially long-running operations.
|
void |
close()
Deprecated.
Closes the SQL connection, if it is open.
|
java.sql.Connection |
getConnection()
Deprecated.
Returns a JDBC connection.
|
java.util.Properties |
getProperties()
Deprecated.
Returns the properties for this connection.
|
java.lang.String |
getURL()
Deprecated.
Returns the URL for this connection.
|
java.lang.String |
getUserName()
Deprecated.
Returns the user name for this connection.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Removes a listener from being notified when the value of any bound
property is changed.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Deprecated.
Removes a listener from being notified when the value of any constrained
property is changed.
|
void |
removeWorkingListener(WorkingListener listener)
Deprecated.
Removes a listener from being notified when work starts and stops
on potentially long-running operations.
|
void |
setPassword(java.lang.String password)
Deprecated.
Sets the password used to connect to the database.
|
void |
setProperties(java.util.Properties properties)
Deprecated.
Sets the properties used to connect to the database.
|
void |
setURL(java.lang.String URL)
Deprecated.
Sets the URL used to connect to the database.
|
void |
setUserName(java.lang.String userName)
Deprecated.
Sets the user name used to connect to the database.
|
public SQLConnection()
public SQLConnection(java.lang.String URL)
URL
- The URL used to connect to the database.public SQLConnection(java.lang.String URL, java.lang.String userName)
URL
- The URL used to connect to the database.userName
- The user name used to connect to the database.public SQLConnection(java.lang.String URL, java.lang.String userName, java.lang.String password)
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.public SQLConnection(java.lang.String URL, java.util.Properties properties)
URL
- The URL used to connect to the database.properties
- The properties used to connect to the database.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener.public void addWorkingListener(WorkingListener listener)
listener
- The listener.public void close() throws java.sql.SQLException
java.sql.SQLException
- If there is an error closing the connection.public java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
- If there is an error connecting to
the database.public java.util.Properties getProperties()
public java.lang.String getURL()
public java.lang.String getUserName()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener.public void removeWorkingListener(WorkingListener listener)
listener
- The listener.public void setPassword(java.lang.String password) throws java.beans.PropertyVetoException
password
- The password used to connect to the database.java.beans.PropertyVetoException
- If the change is vetoed.public void setProperties(java.util.Properties properties) throws java.beans.PropertyVetoException
properties
- The properties used to connect to the database.java.beans.PropertyVetoException
- If the change is vetoed.public void setURL(java.lang.String URL) throws java.beans.PropertyVetoException
URL
- The URL used to connect to the database.java.beans.PropertyVetoException
- If the change is vetoed.public void setUserName(java.lang.String userName) throws java.beans.PropertyVetoException
userName
- The user name used to connect to the database.java.beans.PropertyVetoException
- If the change is vetoed.