safejdbc
Class SimpleConnectionProvider

java.lang.Object
  |
  +--safejdbc.SimpleConnectionProvider
All Implemented Interfaces:
ConnectionProvider

public class SimpleConnectionProvider
extends java.lang.Object
implements ConnectionProvider

This class provides JDBC connection via the JDBC 1 Driver. But this is only an example-implementation and should not be used in real-world-projects, because connections are not cached. This means every call to getConnection() is delegated to the underlying driver. The driver than creates a connection, wich is a very expensive (time consuming) operation.


Constructor Summary
SimpleConnectionProvider(java.lang.String url, java.util.Properties info, java.lang.String drivername)
          This constructor initializes the driver using a map containing login information.
SimpleConnectionProvider(java.lang.String user, java.lang.String password, java.lang.String url, java.lang.String drivername)
          This constructor initializes the driver via separate strings.
 
Method Summary
 java.sql.Connection getConnection()
          This method is called by the framework to yield a database connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleConnectionProvider

public SimpleConnectionProvider(java.lang.String user,
                                java.lang.String password,
                                java.lang.String url,
                                java.lang.String drivername)
                         throws java.lang.Exception
This constructor initializes the driver via separate strings.
Example:
 ConnectionProvider conprovider = new SimpleConnectionProvider
       ("hermanns", "password",
        "jdbc:db2://192.168.11.10:8400/Test",
        "COM.ibm.db2.jdbc.net.DB2Driver");     
 
Parameters:
user - specifies the database user that is used for login
password - specifies the database password that is used for login
url - specifies the database URL
drivername - contains the fully qualified class name of the driver class

SimpleConnectionProvider

public SimpleConnectionProvider(java.lang.String url,
                                java.util.Properties info,
                                java.lang.String drivername)
                         throws java.lang.Exception
This constructor initializes the driver using a map containing login information.
Parameters:
url - contains the database URL
info - must contain entries at least for the two keys "user" and "password", containing login information for the database
drivername - must contain the fully qualified class name of the driver class
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
This method is called by the framework to yield a database connection.
Specified by:
getConnection in interface ConnectionProvider


Copyright (c) 2001, 2002 by Jan Hermanns and Arno Haase. All Rights Reserved.