|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enableit.db.ConnFactory | +--org.enableit.db.ConnectionFactory
General class intended to hide the process of obtaining database connections to any database.
Over time this class has evolved to fulfil different goals, but is maintained for backwards compatibility. There are two principle uses:
In the first case, 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 (i.e. org.enableit.db
). These
may be overridden by the use of the setProperty
method.
In the second case this class is simply for encapsulation. In other words it offers a way to hide the actual mechanism of finding the database connection to the higher level (application) logic. This allows a J2EE application to use JNDI to obtain connections and a thick-client application configured by a logon screen to both employ common logic whilst this factory takes care of how to find connections at runtime.
This class has been tested with the following database drivers:
Field Summary | |
static java.lang.String |
ABOUT
Deprecated. Information on the exact CVS version accessible after compilation |
protected static org.apache.log4j.Category |
logger
Deprecated. The Log4J Category doing the logging. |
Method Summary | |
static java.sql.Connection |
getConnection()
Deprecated. Returns a connection to the database identified by the class's resource properties. |
static java.sql.Connection |
getConnection(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password)
Deprecated. 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)
Deprecated. Returns a connection to the database identified by the supplied properties. |
java.util.Set |
getConnectionNames()
Deprecated. Returns the names of configured database connections. |
protected java.lang.Object |
getDriver(java.lang.String className)
Deprecated. Obtain a JDBC driver class. |
static org.enableit.db.ConnectionFactory |
getInstance()
Deprecated. Factory method to obtain the connection factory itself. |
org.enableit.db.beans.Provider |
getProvider(java.lang.String name)
Deprecated. Obtain connection details for the named configuration. |
static void |
setProperty(java.lang.String key,
java.lang.String value)
Deprecated. Set a connection property dynamically. |
Methods inherited from class org.enableit.db.ConnFactory |
getConnection, getConnection, registerDriver, registerDriverFromUrl |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Category logger
Category
doing the logging.
Same Category
is used throughout the package.
public static final java.lang.String ABOUT
Method Detail |
public static org.enableit.db.ConnectionFactory getInstance()
ConnectionFactory
singleton.public static void setProperty(java.lang.String key, java.lang.String value)
This will override defaults changing the behaviour of the
ConnectionFactory
singleton.
public java.util.Set getConnectionNames()
These are names that may be used successfully with
.
java.util.Set
of connection names (of type
String
).getProvider(java.lang.String)
public org.enableit.db.beans.Provider getProvider(java.lang.String name) throws DBException
name
- configuration name.
DBException
- If the named configuration is not found.getConnectionNames()
public static java.sql.Connection getConnection() throws DBException
This is a very simplistic configuration option for applications that do not have any JNDI or user-maintained configuration options. It is not recommended.
DBException
- in the event of a problem creating the connectionpublic 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
Parameters may be empty strings, but may not be null.
driver
- database
- server
- port
- protocol
- user
- password
-
DBException
- in the event of a problem creating the connectionpublic static java.sql.Connection getConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password) throws DBException
Parameters may be empty strings, but may not be null.
driver
- url
- user
- password
-
DBException
- in the event of a problem creating the connectionprotected java.lang.Object getDriver(java.lang.String className) throws DBException
DBException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |