com.nqadmin.swingSet.datasources
Class SSConnection

java.lang.Object
  extended by com.nqadmin.swingSet.datasources.SSConnection
All Implemented Interfaces:
java.io.Serializable

public class SSConnection
extends java.lang.Object
implements java.io.Serializable

SSConnection.java

SwingSet - Open Toolkit For Making Swing Controls Database-Aware

 The SSConnection class is a wrapper for Connection.
 It provides methods to specify the url, username, password & driver class name.
 The createConnection should be called before calling the getConnection method.
 When ever any connection parameters are changed createConnection has to be called
 to change to connection object.

Version:
$Revision: 1.9 $
Author:
$Author: prasanth $
See Also:
Serialized Form

Field Summary
protected  java.sql.Connection connection
          Database connection object.
protected  java.lang.String driverName
          Database driver class name.
protected  java.lang.String password
          Password to be used for the username specified.
protected  java.lang.String url
          URL to the database.
protected  java.lang.String username
          Username to be used while connecting to the database.
 
Constructor Summary
SSConnection()
          Constructs a default SSConnection object.
SSConnection(java.lang.String _url)
          Constructs a SSConnection object with the specified database url.
SSConnection(java.lang.String _url, java.lang.String _username, java.lang.String _password)
          Constructs a SSConnection object with the specified database url.
SSConnection(java.lang.String _url, java.lang.String _username, java.lang.String _password, java.lang.String _driverName)
          Constructs a SSConnection object with the specified database url.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener _listener)
          Method to add bean property change listeners.
 void addVetoableChangeListener(java.beans.VetoableChangeListener _listener)
          Method to add bean vetoable change listeners.
 void createConnection()
          Creates a connection to the database based on the information provided by the user.
 java.sql.Connection getConnection()
          Returns the database connection object.
 java.lang.String getDriverName()
          Returns the database driver being used.
 java.lang.String getPassword()
          Returns the password being used to connect to the database.
 java.lang.String getUrl()
          Returns the url to the database.
 java.lang.String getUsername()
          Returns the username being used to connect to the database.
protected  void readObject(java.io.ObjectInputStream objIn)
          Recreates the connection when the object is deserialized.
 void removePropertyChangeListener(java.beans.PropertyChangeListener _listener)
          Method to remove bean property change listeners.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener _listener)
          Method to remove bean veto change listeners.
 void setDriverName(java.lang.String _driverName)
          Sets the database driver class name.
 void setPassword(java.lang.String _password)
          Sets the password to be used while connecting to the database.
 void setUrl(java.lang.String _url)
          Sets the url to the database.
 void setUsername(java.lang.String _username)
          Sets the username to be used while connecting to the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

url

protected java.lang.String url
URL to the database.


username

protected java.lang.String username
Username to be used while connecting to the database.


password

protected java.lang.String password
Password to be used for the username specified.


driverName

protected java.lang.String driverName
Database driver class name.


connection

protected transient java.sql.Connection connection
Database connection object.

Constructor Detail

SSConnection

public SSConnection()
Constructs a default SSConnection object.


SSConnection

public SSConnection(java.lang.String _url)
Constructs a SSConnection object with the specified database url.

Parameters:
_url - - url to the database to which connection has to be established. the url should be of the form jdbc:subprotocol:subname

SSConnection

public SSConnection(java.lang.String _url,
                    java.lang.String _username,
                    java.lang.String _password)
Constructs a SSConnection object with the specified database url.

Parameters:
_url - - url to the database to which connection has to be established. the url should be of the form jdbc:subprotocol:subname
_username - - the database username on whose behalf the connection is being made
_password - - the user's password

SSConnection

public SSConnection(java.lang.String _url,
                    java.lang.String _username,
                    java.lang.String _password,
                    java.lang.String _driverName)
Constructs a SSConnection object with the specified database url.

Parameters:
_url - - url to the database to which connection has to be established. the url should be of the form jdbc:subprotocol:subname
_username - - the database username on whose behalf the connection is being made
_password - - the user's password
_driverName - - name of the database driver to be used.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener _listener)
Method to add bean property change listeners.

Parameters:
_listener - bean property change listener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener _listener)
Method to remove bean property change listeners.

Parameters:
_listener - bean property change listener

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener _listener)
Method to add bean vetoable change listeners.

Parameters:
_listener - bean vetoable change listener

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener _listener)
Method to remove bean veto change listeners.

Parameters:
_listener - bean veto change listener

setUrl

public void setUrl(java.lang.String _url)
Sets the url to the database.

Parameters:
_url - - url to the database to which connection has to be established. the url should be of the form jdbc:subprotocol:subname

getUrl

public java.lang.String getUrl()
Returns the url to the database.

Returns:
returns the database url.

setUsername

public void setUsername(java.lang.String _username)
Sets the username to be used while connecting to the database.

Parameters:
_username - - the database username on whose behalf the connection is being made

getUsername

public java.lang.String getUsername()
Returns the username being used to connect to the database.

Returns:
returns the database username.

setPassword

public void setPassword(java.lang.String _password)
Sets the password to be used while connecting to the database.

Parameters:
_password - - the user's password to be used.

getPassword

public java.lang.String getPassword()
Returns the password being used to connect to the database.

Returns:
returns the user's password.

setDriverName

public void setDriverName(java.lang.String _driverName)
Sets the database driver class name.

Parameters:
_driverName - - name of the database driver to be used.

getDriverName

public java.lang.String getDriverName()
Returns the database driver being used.

Returns:
returns the database driver being used.

getConnection

public java.sql.Connection getConnection()
Returns the database connection object.

Returns:
returns the database connection object.

createConnection

public void createConnection()
                      throws java.sql.SQLException,
                             java.lang.ClassNotFoundException
Creates a connection to the database based on the information provided by the user.

Throws:
java.sql.SQLException
java.lang.ClassNotFoundException

readObject

protected void readObject(java.io.ObjectInputStream objIn)
                   throws java.io.IOException,
                          java.lang.ClassNotFoundException
Recreates the connection when the object is deserialized.

Throws:
java.io.IOException
java.lang.ClassNotFoundException