com.darwinsys.sql
Class ConnectionUtil

java.lang.Object
  extended by com.darwinsys.sql.ConnectionUtil

public class ConnectionUtil
extends java.lang.Object

Encapsulate the Connection-related operations that every JDBC program seems to use.


Field Summary
static java.lang.String DEFAULT_NAME
          The default config filename, relative to ${user.home}
 
Constructor Summary
ConnectionUtil()
           
 
Method Summary
static java.lang.String getConfigFileName()
          Returns the full path of the configuration file being used.
static Configuration getConfiguration(java.lang.String config)
          Get a SimpleSQLConfiguration for the given config using the default or set property file name
static java.util.Set<java.lang.String> getConfigurationNames()
          Generate a Set of the config names available from the current configuration file.
static java.util.List<Configuration> getConfigurations()
          Return all the configurations as SimpleSQLConfiguration objects
static java.sql.Connection getConnection(Configuration c)
           
static java.sql.Connection getConnection(java.util.Properties p, java.lang.String configName)
          Get a Connection for the given config name from a provided Properties
static java.sql.Connection getConnection(java.lang.String configName)
          Get a Connection for the given config using the default or set property file name
static java.sql.Connection getConnection(java.lang.String dbUrl, java.lang.String dbDriver, java.lang.String dbUserName, java.lang.String dbPassword)
           
static void setConfigFileName(java.lang.String configFileNam)
          Sets the full path of the config file to read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAME

public static final java.lang.String DEFAULT_NAME
The default config filename, relative to ${user.home}

See Also:
Constant Field Values
Constructor Detail

ConnectionUtil

public ConnectionUtil()
Method Detail

setConfigFileName

public static void setConfigFileName(java.lang.String configFileNam)
Sets the full path of the config file to read.

Parameters:
configFileNam - The FileName of the configuration file to use.

getConfigFileName

public static java.lang.String getConfigFileName()
Returns the full path of the configuration file being used.

Returns:
Returns the configFileName.

getConfiguration

public static Configuration getConfiguration(java.lang.String config)
                                      throws DataBaseException
Get a SimpleSQLConfiguration for the given config using the default or set property file name

Throws:
DataBaseException

getConnection

public static java.sql.Connection getConnection(java.lang.String configName)
                                         throws DataBaseException
Get a Connection for the given config using the default or set property file name

Throws:
DataBaseException

getConnection

public static java.sql.Connection getConnection(java.util.Properties p,
                                                java.lang.String configName)
                                         throws DataBaseException
Get a Connection for the given config name from a provided Properties

Throws:
DataBaseException

getConnection

public static java.sql.Connection getConnection(java.lang.String dbUrl,
                                                java.lang.String dbDriver,
                                                java.lang.String dbUserName,
                                                java.lang.String dbPassword)
                                         throws java.lang.ClassNotFoundException,
                                                java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException

getConnection

public static java.sql.Connection getConnection(Configuration c)
                                         throws java.lang.ClassNotFoundException,
                                                java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException

getConfigurationNames

public static java.util.Set<java.lang.String> getConfigurationNames()
Generate a Set of the config names available from the current configuration file.

Returns:
Set of the configurations

getConfigurations

public static java.util.List<Configuration> getConfigurations()
Return all the configurations as SimpleSQLConfiguration objects



Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.