SPT RWT Application API

com.sptci.rwt
Class ConnectionManager

java.lang.Object
  extended by com.sptci.rwt.ConnectionManager

public class ConnectionManager
extends Object

A manager used to globally maintain a single means of connecting to a database. Connections are obtained through DataSource or DriverManager.

© Copyright 2007 Sans Pareil Technologies, Inc.

Version:
$Id: ConnectionManager.java 4123 2008-05-25 21:49:01Z rakesh $
Author:
Rakesh Vidyadharan 2007-09-26

Field Summary
private  String dataSource
          The name of the data source to use to obtain connections.
private  ConnectionParameters parameters
          The connection parameters to use to obtain connections.
 
Constructor Summary
private ConnectionManager()
          Default constructor.
  ConnectionManager(ConnectionParameters parameters)
          Create a new instance of the class configured to use the specified parameters.
  ConnectionManager(String dataSource)
          Create a new instance of the class configured to use the specifiedj dataSource.
 
Method Summary
 void close(Connection connection)
          Close the specified connection.
 String getDataSource()
          Returns dataSource.
 ConnectionParameters getParameters()
          Returns parameters.
 String getTitle()
          Return a name indicating the current connection source.
 Connection open()
          Open a connection to the database using the currently active dataSource or parameters.
 void setDataSource(String dataSource)
          Set dataSource.
 void setParameters(ConnectionParameters parameters)
          Set parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSource

private String dataSource
The name of the data source to use to obtain connections.


parameters

private ConnectionParameters parameters
The connection parameters to use to obtain connections.

Constructor Detail

ConnectionManager

private ConnectionManager()
Default constructor. Cannot be instantiated.


ConnectionManager

public ConnectionManager(String dataSource)
Create a new instance of the class configured to use the specifiedj dataSource.

Parameters:
dataSource - The dataSource value to use.

ConnectionManager

public ConnectionManager(ConnectionParameters parameters)
Create a new instance of the class configured to use the specified parameters.

Parameters:
parameters - The parameters to use.
Method Detail

open

public Connection open()
                throws ConnectionException
Open a connection to the database using the currently active dataSource or parameters.

Returns:
The connection to the database.
Throws:
ConnectionException - If errors are encountered while fetching the connection to the database. Can also be thrown if this instance has not been initialised through setDataSource(java.lang.String) or setParameters(com.sptci.rwt.ConnectionParameters).
See Also:
ConnectionFactory.open( String ), ConnectionFactory.open( ConnectionParameters )

close

public void close(Connection connection)
Close the specified connection.

See Also:
ConnectionFactory.close(java.sql.Connection)

getDataSource

public String getDataSource()
Returns dataSource.

Returns:
The value/reference of/to dataSource.

setDataSource

public void setDataSource(String dataSource)
Set dataSource. If a valid string was specified, sets parameters to null.

Parameters:
dataSource - The value to set.

getParameters

public ConnectionParameters getParameters()
Returns parameters.

Returns:
The value/reference of/to parameters.

setParameters

public void setParameters(ConnectionParameters parameters)
Set parameters. If valid parameters were specified, sets dataSource to null.

Parameters:
parameters - The value to set.

getTitle

public String getTitle()
Return a name indicating the current connection source.

Returns:
The name inidicating the connection source in use.

SPT RWT Application API