prefuse.data.io.sql
Class ConnectionFactory

java.lang.Object
  extended by prefuse.data.io.sql.ConnectionFactory

public class ConnectionFactory
extends java.lang.Object

Author:
jeffrey heer

Field Summary
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 Summary
ConnectionFactory()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DRIVER_MYSQL

public static final java.lang.String DRIVER_MYSQL
String constant for the commonly used MySQL JDBC driver

See Also:
Constant Field Values

DRIVER_JDBC_OBDC

public static final java.lang.String DRIVER_JDBC_OBDC
String constant for the JDBC/ODBC bridge driver

See Also:
Constant Field Values

PROTOCOL_JDBC

public static final java.lang.String PROTOCOL_JDBC
Protocol prefix for JDBC URLs

See Also:
Constant Field Values

SUBPROTOCOL_MYSQL

public static final java.lang.String SUBPROTOCOL_MYSQL
Sub-protocol prefix for MySQL connections

See Also:
Constant Field Values

SUBPROTOCOL_JDBC_ODBC

public static final java.lang.String SUBPROTOCOL_JDBC_ODBC
Sub-protocol prefix for JDBC/ODBC bridge connections

See Also:
Constant Field Values
Constructor Detail

ConnectionFactory

public ConnectionFactory()
Method Detail

getDefaultHandler

public static SQLDataHandler getDefaultHandler()
Get an instance of the default SQL data handler.

Returns:
an instance of the default SQL data handler

getDatabaseConnection

public static DatabaseDataSource getDatabaseConnection(java.sql.Connection conn,
                                                       SQLDataHandler handler)
                                                throws java.sql.SQLException
Get a new database connection.

Parameters:
conn - the Connection object to the database
handler - the data handler to use
Returns:
a DatabaseDataSource for interacting with the database
Throws:
java.sql.SQLException - if an SQL error occurs

getDatabaseConnection

public static DatabaseDataSource getDatabaseConnection(java.sql.Connection conn)
                                                throws java.sql.SQLException
Get a new database connection, using a default handler.

Parameters:
conn - the Connection object to the database
Returns:
a DatabaseDataSource for interacting with the database
Throws:
java.sql.SQLException - if an SQL error occurs

getDatabaseConnection

public 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
Get a new database connection.

Parameters:
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:://<hostname>/<database_name>
user - the database username
password - the database password
handler - the sql data handler to use
Returns:
a DatabaseDataSource for interacting with the database
Throws:
java.sql.SQLException
java.lang.ClassNotFoundException

getDatabaseConnection

public 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
Get a new database connection, using a default handler.

Parameters:
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:://<hostname>/<database_name>
user - the database username
password - the database password
Returns:
a DatabaseDataSource for interacting with the database
Throws:
java.sql.SQLException
java.lang.ClassNotFoundException

getMySQLConnection

public 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
Get a new database connection to a MySQL database.

Parameters:
host - the ip address or host name of the database server
database - the name of the particular database to use
user - the database username
password - the database password
handler - the sql data handler to use
Returns:
a DatabaseDataSource for interacting with the database
Throws:
java.sql.SQLException
java.lang.ClassNotFoundException

getMySQLConnection

public 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
Get a new database connection to a MySQL database, using a default handler.

Parameters:
host - the ip address or host name of the database server
database - the name of the particular database to use
user - the database username
password - the database password
Returns:
a DatabaseDataSource for interacting with the database
Throws:
java.sql.SQLException
java.lang.ClassNotFoundException


Copyright 2007 Regents of the University of California