|
|||||||||
Home >> All >> org >> enableit >> [ db overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
org.enableit.db
Class ConnectionFactory

java.lang.Objectorg.enableit.db.ConnectionFactory
- public class ConnectionFactory
- extends java.lang.Object
General class intended to hide the process of obtaining database connections to any database
The connection properties such as server name, username/password etc
are all stored in a file named db.properties in the package level
directory matching this class (ie thestephensons.db
)
Internal methods then arrange these in the way to construct a Connection of the required type. Because this may vary from one vendor to the next, internally specific methods exist for each database driver vendor
Supported database drivers currently are:
- ASE/ASA (Sybase jConnect 5.x)
- MySQL (MM.MySQL driver)
- Version:
- v1.0
Field Summary | |
static java.lang.String |
about
Information on the exact CVS version accessible after compilation |
protected static org.apache.log4j.Category |
cat
The Log4J Category doing the logging. |
private static java.util.HashMap |
connConfigs
Holds the Provider instances that have been configured as
data sources. |
private static ConnectionFactory |
me
Reference to the singleton instance NB the singleton status is not enforced via a synchronise statement |
private static java.util.Properties |
props
The current database properties to make connections with |
Constructor Summary | |
private |
ConnectionFactory()
Default Constructor |
Method Summary | |
private void |
configureFromProps()
Interpretes the props to create a Provider for each distinct data source configuration. |
static java.sql.Connection |
getConnection()
Returns a connection to the database identified by the class's resource properties |
private java.sql.Connection |
getConnection(java.util.Properties props)
Returns a connection to the database identified by the Properties supplied |
static java.sql.Connection |
getConnection(org.enableit.db.darrt.schema.Provider provider)
Returns a connection to the database identified within the supplied provider. |
java.sql.Connection |
getConnection(java.lang.String name)
Obtain connection for the named configuration. |
static java.sql.Connection |
getConnection(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password)
Returns a connection to the database identified by the supplied properties. |
static java.sql.Connection |
getConnection(java.lang.String driver,
java.lang.String database,
java.lang.String server,
java.lang.String port,
java.lang.String protocol,
java.lang.String user,
java.lang.String password)
Returns a connection to the database identified by the supplied properties. |
java.util.Set |
getConnectionNames()
Returns the names of configured database connections. |
protected java.lang.Object |
getDriver(java.lang.String className)
Obtain a JDBC driver class. |
static ConnectionFactory |
getInstance()
Factory method. |
private java.sql.Connection |
getMySQLConnection(java.util.Properties props)
|
org.enableit.db.darrt.schema.Provider |
getProvider(java.lang.String name)
Obtain connection details for the named configuration. |
private java.sql.Connection |
getSybConnection(java.util.Properties props)
|
private java.sql.Connection |
getUrlConnection(java.util.Properties props)
|
static void |
setProperty(java.lang.String key,
java.lang.String value)
Set a connection property dynamically |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
connConfigs
private static java.util.HashMap connConfigs
- Holds the
Provider
instances that have been configured as data sources.
cat
protected static org.apache.log4j.Category cat
- The Log4J
Category
doing the logging. SameCategory
is used throughout the package.
me
private static ConnectionFactory me
- Reference to the singleton instance
NB the singleton status is not enforced via a synchronise statement
props
private static java.util.Properties props
- The current database properties to make connections with
about
public static final java.lang.String about
- Information on the exact CVS version accessible after compilation
- See Also:
- Constant Field Values
Constructor Detail |
ConnectionFactory
private ConnectionFactory()
- Default Constructor
Method Detail |
getInstance
public static ConnectionFactory getInstance()
- Factory method.
setProperty
public static void setProperty(java.lang.String key, java.lang.String value)
- Set a connection property dynamically
configureFromProps
private void configureFromProps()
- Interpretes the props to create a Provider for each distinct data source
configuration.
throws DBException If the properties are invalid in some way
getConnectionNames
public java.util.Set getConnectionNames()
- Returns the names of configured database connections.
These are names that may be used successfully with
getConnectionByName
.
getProvider
public org.enableit.db.darrt.schema.Provider getProvider(java.lang.String name) throws DBException
- Obtain connection details for the named configuration.
getConnection
public java.sql.Connection getConnection(java.lang.String name) throws DBException
- Obtain connection for the named configuration.
getConnection
public static java.sql.Connection getConnection() throws DBException
- Returns a connection to the database identified by the
class's resource properties
getConnection
public static java.sql.Connection getConnection(java.lang.String driver, java.lang.String database, java.lang.String server, java.lang.String port, java.lang.String protocol, java.lang.String user, java.lang.String password) throws DBException
- Returns a connection to the database identified by the
supplied properties.
Parameters may be empty strings, but may not be null.
getConnection
public static java.sql.Connection getConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password) throws DBException
- Returns a connection to the database identified by the
supplied properties.
Parameters may be empty strings, but may not be null.
getConnection
public static java.sql.Connection getConnection(org.enableit.db.darrt.schema.Provider provider) throws DBException
- Returns a connection to the database identified within the
supplied provider.
Parameters may be empty strings, but may not be null.
getConnection
private java.sql.Connection getConnection(java.util.Properties props) throws DBException
- Returns a connection to the database identified by the
Properties
supplied
getMySQLConnection
private java.sql.Connection getMySQLConnection(java.util.Properties props) throws java.sql.SQLException, DBException
getSybConnection
private java.sql.Connection getSybConnection(java.util.Properties props) throws java.sql.SQLException, DBException
getUrlConnection
private java.sql.Connection getUrlConnection(java.util.Properties props) throws java.sql.SQLException, DBException
getDriver
protected java.lang.Object getDriver(java.lang.String className) throws DBException
- Obtain a JDBC driver class.
|
|||||||||
Home >> All >> org >> enableit >> [ db overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |