public class ConnectionFactory
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DRIVER_JDBC_OBDC
String constant for the JDBC/ODBC bridge driver
|
static java.lang.String |
DRIVER_MYSQL
String constant for the commonly used MySQL JDBC driver
|
static java.lang.String |
PROTOCOL_JDBC
Protocol prefix for JDBC URLs
|
static java.lang.String |
SUBPROTOCOL_JDBC_ODBC
Sub-protocol prefix for JDBC/ODBC bridge connections
|
static java.lang.String |
SUBPROTOCOL_MYSQL
Sub-protocol prefix for MySQL connections
|
| Constructor and Description |
|---|
ConnectionFactory() |
| Modifier and Type | Method and Description |
|---|---|
static DatabaseDataSource |
getDatabaseConnection(java.sql.Connection conn)
Get a new database connection, using a default handler.
|
static DatabaseDataSource |
getDatabaseConnection(java.sql.Connection conn,
SQLDataHandler handler)
Get a new database connection.
|
static DatabaseDataSource |
getDatabaseConnection(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password)
Get a new database connection, using a default handler.
|
static DatabaseDataSource |
getDatabaseConnection(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password,
SQLDataHandler handler)
Get a new database connection.
|
static SQLDataHandler |
getDefaultHandler()
Get an instance of the default SQL data handler.
|
static DatabaseDataSource |
getMySQLConnection(java.lang.String host,
java.lang.String database,
java.lang.String user,
java.lang.String password)
Get a new database connection to a MySQL database, using a default
handler.
|
static DatabaseDataSource |
getMySQLConnection(java.lang.String host,
java.lang.String database,
java.lang.String user,
java.lang.String password,
SQLDataHandler handler)
Get a new database connection to a MySQL database.
|
public static final java.lang.String DRIVER_MYSQL
public static final java.lang.String DRIVER_JDBC_OBDC
public static final java.lang.String PROTOCOL_JDBC
public static final java.lang.String SUBPROTOCOL_MYSQL
public static final java.lang.String SUBPROTOCOL_JDBC_ODBC
public static SQLDataHandler getDefaultHandler()
public static DatabaseDataSource getDatabaseConnection(java.sql.Connection conn, SQLDataHandler handler) throws java.sql.SQLException
conn - the Connection object to the databasehandler - the data handler to usejava.sql.SQLException - if an SQL error occurspublic static DatabaseDataSource getDatabaseConnection(java.sql.Connection conn) throws java.sql.SQLException
conn - the Connection object to the databasejava.sql.SQLException - if an SQL error occurspublic static DatabaseDataSource getDatabaseConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password, SQLDataHandler handler) throws java.sql.SQLException, java.lang.ClassNotFoundException
driver - the database driver to use, must resolve to a valid Java
class on the current classpath.url - the url for the database, of the form
"jdbc:<database_sub_protocol>://<hostname>/<database_name>user - the database usernamepassword - the database passwordhandler - the sql data handler to usejava.sql.SQLExceptionjava.lang.ClassNotFoundExceptionpublic static DatabaseDataSource getDatabaseConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password) throws java.sql.SQLException, java.lang.ClassNotFoundException
driver - the database driver to use, must resolve to a valid Java
class on the current classpath.url - the url for the database, of the form
"jdbc:<database_sub_protocol>://<hostname>/<database_name>user - the database usernamepassword - the database passwordjava.sql.SQLExceptionjava.lang.ClassNotFoundExceptionpublic static DatabaseDataSource getMySQLConnection(java.lang.String host, java.lang.String database, java.lang.String user, java.lang.String password, SQLDataHandler handler) throws java.sql.SQLException, java.lang.ClassNotFoundException
host - the ip address or host name of the database serverdatabase - the name of the particular database to useuser - the database usernamepassword - the database passwordhandler - the sql data handler to usejava.sql.SQLExceptionjava.lang.ClassNotFoundExceptionpublic static DatabaseDataSource getMySQLConnection(java.lang.String host, java.lang.String database, java.lang.String user, java.lang.String password) throws java.sql.SQLException, java.lang.ClassNotFoundException
host - the ip address or host name of the database serverdatabase - the name of the particular database to useuser - the database usernamepassword - the database passwordjava.sql.SQLExceptionjava.lang.ClassNotFoundException