net.agmodel.dbUtility
Class JDBC

java.lang.Object
  extended bynet.agmodel.dbUtility.InternetHost
      extended bynet.agmodel.dbUtility.JDBC
All Implemented Interfaces:
AccessMechanism, DBAccessMechanism
Direct Known Subclasses:
JDBCBorland, JDBCMySQL, JDBCOracle, JDBCPostgres, JDBCRjj

public abstract class JDBC
extends InternetHost
implements DBAccessMechanism

Provides access to JDBC databases by wrapping java.sql.
Addresses differences between vendor implementations of JDBC drivers.

Author:
Matthew Laurenson with improvements by Kei Tanaka

Constructor Summary
JDBC(String host, int port, String databaseName)
           
 
Method Summary
 void checkForDatabaseUpdates()
          connect to database and check the metadata
 boolean connect(String username, String password)
          Establishes a JDBC connection to the remote database, using the supplied username and password.
 boolean connectForData(String username, String password)
          Called before data is retrieved from the AccessMechanism
 boolean connectForMetaData(String username, String password)
          Called before metadata is retrieved from the AccessMechanism
 void disconnectFromData()
          Called after data is retrieved from the AccessMechanism using connectForData.
 void disconnectFromMetaData()
          Called after meta data is retrieved from the AccessMechanism using connectForMetaData.
 Connection getConn()
          Returns the database connection object created by DriverManager.getConnection()
Uses the form of DriverManager.getConnection where the usercode and password are passed as separate parameters.
 
Methods inherited from class net.agmodel.dbUtility.InternetHost
getHost, getPort
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBC

public JDBC(String host,
            int port,
            String databaseName)
Method Detail

connect

public boolean connect(String username,
                       String password)
                throws ConnectionException
Establishes a JDBC connection to the remote database, using the supplied username and password. Calls getConnectString() for the connection string, getDriver() for the driver, and passes the username and password as properties.

Throws:
ConnectionException

connectForData

public boolean connectForData(String username,
                              String password)
                       throws ConnectionException
Description copied from interface: DBAccessMechanism
Called before data is retrieved from the AccessMechanism

Specified by:
connectForData in interface DBAccessMechanism
Parameters:
username - a valid username for the database if it requires it, or null otherwise.
password - the corresponding password (not encrypted) if required, or null otherwise.
Returns:
true if the connection was established, false otherwise
Throws:
ConnectionException - if a connection could not be established

disconnectFromData

public void disconnectFromData()
                        throws ConnectionException
Description copied from interface: DBAccessMechanism
Called after data is retrieved from the AccessMechanism using connectForData.

Specified by:
disconnectFromData in interface DBAccessMechanism
Throws:
ConnectionException - if a connection could not be disconnected

connectForMetaData

public boolean connectForMetaData(String username,
                                  String password)
                           throws ConnectionException
Description copied from interface: DBAccessMechanism
Called before metadata is retrieved from the AccessMechanism

Specified by:
connectForMetaData in interface DBAccessMechanism
Parameters:
username - a valid username for the database if it requires it, or null otherwise.
password - the corresponding password (not encrypted) if required, or null otherwise.
Returns:
true if the connection was established, false otherwise
Throws:
ConnectionException - if a connection could not be established

disconnectFromMetaData

public void disconnectFromMetaData()
                            throws ConnectionException
Description copied from interface: DBAccessMechanism
Called after meta data is retrieved from the AccessMechanism using connectForMetaData.

Specified by:
disconnectFromMetaData in interface DBAccessMechanism
Throws:
ConnectionException - if a connection could not be disconnected

getConn

public Connection getConn()
Returns the database connection object created by DriverManager.getConnection()
Uses the form of DriverManager.getConnection where the usercode and password are passed as separate parameters.

Returns:
a URL suitable for passing to java.sql.DriverManager.getConnection(URL,String,String)

checkForDatabaseUpdates

public void checkForDatabaseUpdates()
                             throws ConnectionException
Description copied from interface: DBAccessMechanism
connect to database and check the metadata

Specified by:
checkForDatabaseUpdates in interface DBAccessMechanism
Throws:
ConnectionException


Copyright (C) NARC 2001 All Rights Reserved.