net.walend.jdbc
Class ConnectionSource

java.lang.Object
  |
  +--net.walend.jdbc.ConnectionSource

public class ConnectionSource
extends java.lang.Object

A static class that hands out database connections.

Since:
20001127
Author:
David Walend

Field Summary
private static java.lang.String DEFAULT
           
private static java.lang.Object guard
          guard for protecting theSource and namesToURLs.
private  MutableMap namesToDataSources
           
private static ConnectionSource theSource
          Singleton.
 
Constructor Summary
private ConnectionSource(java.lang.String driverName, javax.sql.DataSource dataSource)
           
 
Method Summary
private  void addDataSource(java.lang.String name, javax.sql.DataSource dataSource)
           
static void addDB(java.lang.String name, javax.sql.DataSource dataSource)
           
static void addDB(java.lang.String name, java.lang.String driverName, java.lang.String dbURL, java.lang.String userName, java.lang.String passWord)
           
private  boolean containsDataSource(java.lang.String name)
           
static boolean containsDB(java.lang.String name)
           
static java.sql.Connection getConnection()
          Get a connection to a database.
static java.sql.Connection getConnection(java.lang.String connectionName)
          Get a connection to a database.
private  javax.sql.DataSource getDataSourceForName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theSource

private static ConnectionSource theSource
Singleton.


guard

private static java.lang.Object guard
guard for protecting theSource and namesToURLs.


DEFAULT

private static final java.lang.String DEFAULT

namesToDataSources

private MutableMap namesToDataSources
Constructor Detail

ConnectionSource

private ConnectionSource(java.lang.String driverName,
                         javax.sql.DataSource dataSource)
                  throws java.sql.SQLException
Parameters:
defaultDBURL - the url to use to grab connections in the (no parameter) getConnection() method
Method Detail

addDataSource

private void addDataSource(java.lang.String name,
                           javax.sql.DataSource dataSource)
                    throws java.sql.SQLException

addDB

public static void addDB(java.lang.String name,
                         java.lang.String driverName,
                         java.lang.String dbURL,
                         java.lang.String userName,
                         java.lang.String passWord)
                  throws java.sql.SQLException

addDB

public static void addDB(java.lang.String name,
                         javax.sql.DataSource dataSource)
                  throws java.sql.SQLException

containsDB

public static boolean containsDB(java.lang.String name)

containsDataSource

private boolean containsDataSource(java.lang.String name)

getDataSourceForName

private javax.sql.DataSource getDataSourceForName(java.lang.String name)
                                           throws java.sql.SQLException

getConnection

public static java.sql.Connection getConnection()
                                         throws java.sql.SQLException
Get a connection to a database.


getConnection

public static java.sql.Connection getConnection(java.lang.String connectionName)
                                         throws java.sql.SQLException
Get a connection to a database.



Copyright (c) 2000, 2001, David Walend