Holger's
Java API

com.antelmann.sql
Class Connector

java.lang.Object
  extended by com.antelmann.sql.Connector
All Implemented Interfaces:
ThirdParty

public final class Connector
extends Object
implements ThirdParty

The Connector class provides some simplified access to several database systems through static methods. Although the class doesn't require any additional driver software for compilation, certain methods may through SQLException if the specified driver is not present at the time.

Author:
Holger Antelmann

Method Summary
static Connection getHsqldbConnection(String dbName, String login, String password)
          provides JDBC access through the Hsqldb driver (http://hsqldb.sourceforge.net/)
static Connection getHsqldbConnection(String host, String dbName, String login, String password)
          provides JDBC access through the Hsqldb driver (http://hsqldb.sourceforge.net/)
static Connection getMDBConnection(File mdbFile)
          provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge
static Connection getMDBConnection(File mdbFile, File workGroupFile, Properties props)
          provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge
static Connection getMDBConnection(File mdbFile, File workGroupFile, String user, String password, Properties props)
          provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge
static Connection getMDBConnection(File mdbFile, Properties props)
          provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge
static Connection getMySQLConnection(String dbName)
          returns getMySQLConnection("localhost", dbName)
static Connection getMySQLConnection(String host, String dbName)
          provides simplified access to a MySQL database using the MySQL Connector/J 3.1 driver.
static Connection getMySQLConnection(String host, String dbName, int port, String login, String password)
          provides simplified access to a MySQL database using MySQL Connector/J 3.1
static Connection getMySQLConnection(String host, String dbName, String login, String password)
          uses the standard port 3306
static Connection getODBCConnection(String dbName)
          provides some simplified access to existing ODBC connections through Sun's JDBC/ODBC bridge
static Connection getODBCConnection(String dbName, Properties props)
           
static Connection getODBCConnection(String dbName, String login, String password)
          provides some simplified access to existing ODBC connections through Sun's JDBC/ODBC bridge
static Connection getSQLServerConnection(String host, String dbName, String login, String password)
          getSQLServerConnection() provides access to a Microsoft SQL-Server database.
static String getSQLServerDriver()
           
static void setSQLServerDriver(String driverClassName)
          sets the name of the driver class to be used by getSQLServerConnection().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMySQLConnection

public static Connection getMySQLConnection(String dbName)
                                     throws SQLException
returns getMySQLConnection("localhost", dbName)

Throws:
SQLException
See Also:
getMySQLConnection(String, String)

getMySQLConnection

public static Connection getMySQLConnection(String host,
                                            String dbName)
                                     throws SQLException
provides simplified access to a MySQL database using the MySQL Connector/J 3.1 driver. If the MySQL driver is not present, this method will throw a RuntimeException.

Parameters:
host - hostname; unless a port is specified, 3306 is used
dbName - name of the database
Throws:
SQLException

getMySQLConnection

public static Connection getMySQLConnection(String host,
                                            String dbName,
                                            String login,
                                            String password)
                                     throws SQLException
uses the standard port 3306

Throws:
SQLException

getMySQLConnection

public static Connection getMySQLConnection(String host,
                                            String dbName,
                                            int port,
                                            String login,
                                            String password)
                                     throws SQLException
provides simplified access to a MySQL database using MySQL Connector/J 3.1

Throws:
SQLException

getMDBConnection

public static Connection getMDBConnection(File mdbFile)
                                   throws SQLException
provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge

Throws:
SQLException

getMDBConnection

public static Connection getMDBConnection(File mdbFile,
                                          Properties props)
                                   throws SQLException
provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge

Throws:
SQLException

getMDBConnection

public static Connection getMDBConnection(File mdbFile,
                                          File workGroupFile,
                                          String user,
                                          String password,
                                          Properties props)
                                   throws SQLException
provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge

Throws:
SQLException

getMDBConnection

public static Connection getMDBConnection(File mdbFile,
                                          File workGroupFile,
                                          Properties props)
                                   throws SQLException
provides some simplified access to an existing Microsoft Access database through Sun's JDBC/ODBC bridge

Throws:
SQLException

getODBCConnection

public static Connection getODBCConnection(String dbName)
                                    throws SQLException
provides some simplified access to existing ODBC connections through Sun's JDBC/ODBC bridge

Throws:
SQLException

getODBCConnection

public static Connection getODBCConnection(String dbName,
                                           Properties props)
                                    throws SQLException
Throws:
SQLException

getODBCConnection

public static Connection getODBCConnection(String dbName,
                                           String login,
                                           String password)
                                    throws SQLException
provides some simplified access to existing ODBC connections through Sun's JDBC/ODBC bridge

Throws:
SQLException

getSQLServerDriver

public static String getSQLServerDriver()

setSQLServerDriver

public static void setSQLServerDriver(String driverClassName)
                               throws IllegalArgumentException
sets the name of the driver class to be used by getSQLServerConnection(). Currently known drivers:

getSQLServerConnection

public static Connection getSQLServerConnection(String host,
                                                String dbName,
                                                String login,
                                                String password)
                                         throws SQLException
getSQLServerConnection() provides access to a Microsoft SQL-Server database. The driver to be used depends on what has been configured.

Throws:
SQLException
See Also:
setSQLServerDriver(String)

getHsqldbConnection

public static Connection getHsqldbConnection(String host,
                                             String dbName,
                                             String login,
                                             String password)
                                      throws SQLException
provides JDBC access through the Hsqldb driver (http://hsqldb.sourceforge.net/)

Throws:
SQLException

getHsqldbConnection

public static Connection getHsqldbConnection(String dbName,
                                             String login,
                                             String password)
                                      throws SQLException
provides JDBC access through the Hsqldb driver (http://hsqldb.sourceforge.net/)

Parameters:
dbName - the path and name of the database (example: /dir/db1)
login - as a default, sa can be used for the system administrator
Throws:
SQLException


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads