SPT RWT Application API

com.sptci.rwt
Class ConnectionFactory

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

public class ConnectionFactory
extends Object

A factory used to obtain database connections. Database connections can be obtained through DataSource or DriverManager.

© Copyright 2007 Sans Pareil Technologies, Inc.

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

Field Summary
private static Map<String,DataSource> cache
          A map used to maintain DataSource references to avoid having to look it up each time.
 
Constructor Summary
ConnectionFactory()
           
 
Method Summary
static void close(Connection connection)
          Close the specified connection.
static Connection open(ConnectionParameters parameters)
          Fetch a connection to the database defined by the specified parameters object.
static Connection open(String name)
          Fetch a connection to the database via a relative DataSource name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

private static final Map<String,DataSource> cache
A map used to maintain DataSource references to avoid having to look it up each time.

Constructor Detail

ConnectionFactory

public ConnectionFactory()
Method Detail

open

public static Connection open(ConnectionParameters parameters)
                       throws ConnectionException
Fetch a connection to the database defined by the specified parameters object.

Parameters:
parameters - The value object with the connection parameters.
Returns:
The connection to the database.
Throws:
ConnectionException - If errors are encountered while fetching the connection.

open

public static Connection open(String name)
                       throws ConnectionException
Fetch a connection to the database via a relative DataSource name.

Parameters:
name - The name of the datasource from which to fetch a connection.
Returns:
The connection to the database.
Throws:
ConnectionException - If errors are encountered while fetching the connection.

close

public static final void close(Connection connection)
Close the specified connection. Fail-safe method that only logs errors.

Parameters:
connection - The connection that is to be closed.
See Also:
CloseJDBCResources.close( Connection )

SPT RWT Application API