|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enableit.db.ConnectionFactory
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:
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 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 | |
static java.sql.Connection |
getConnection()
Returns a connection to the database identified by the class's resource properties |
protected static java.sql.Connection |
getConnection(java.util.Properties props)
Returns a connection to the database identified by the Properties supplied |
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 |
static ConnectionFactory |
getInstance()
Factory method |
private static java.sql.Connection |
getMySQLConnection(java.util.Properties props)
|
private static java.sql.Connection |
getSybConnection(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 |
|
Field Detail |
protected static org.apache.log4j.Category cat
Category
doing the logging.
Same Category
is used throughout the package.private static ConnectionFactory me
private static java.util.Properties props
public static final java.lang.String about
Constructor Detail |
private ConnectionFactory()
Method Detail |
public static ConnectionFactory getInstance()
public static void setProperty(java.lang.String key, java.lang.String value)
public static java.sql.Connection getConnection() throws DBException
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
Returns a connection to the database identified by the supplied properties
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 connectionprotected static java.sql.Connection getConnection(java.util.Properties props) throws DBException
Properties
suppliedDBException
- in the event of a problem creating the connectionprivate static java.sql.Connection getMySQLConnection(java.util.Properties props) throws java.sql.SQLException, DBException
private static java.sql.Connection getSybConnection(java.util.Properties props) throws java.sql.SQLException, DBException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |