MDi JLib
1.7.4

com.microdeveloper.db.jndi
Interface ConnectionPoolInterface


public interface ConnectionPoolInterface

Interface class used by the ConnectionPool implementation class.

Revision History:
May 16, 2005 20:27:01 Open nows throws SQLException and setDB Jan 18, 2005 12:40:22 Created.

Version:
1.0
Author:
Gregg Lagnese
See Also:
DesEncrypter, ConnectionPool

Method Summary
 void close()
          Closes the current pooled connection.
 String generatePassword(String database, String name, String password)
          Generates a new encrypted password and returns the result.
 Connection getConnection()
          Returns the active java.sql.Connection object.
 String getDb()
          Returns the currently established database name
 String getDbAlias()
          Returns the currently established database alias
 String getDriver()
          Returns the driver currently in effect from the dbnames file.
 String getJNDIDbFromAlias(String alias)
          Returns the associated JNDI database name for the given alias name
 String getPassword()
          Returns the encrypted password for the current user
 String getSid()
          Returns the optional established sid for Oracle databases.
 String getUrl()
          Returns the URL to the database connection from the dbnames file.
 String getUsername()
          Returns the current username for the ConnectionPool
 boolean isOpen()
          Determines if the connection is open or not.
 void open()
          Opens the connection to the database using the established properties.
 void open(String database)
          Open the connection to database
 void open(String database, String name, String pw)
          Open the connection to database using name and password given
 boolean setDb(String dbAlias)
          Sets the name of the database to use for subsequent connections.
 boolean setDbAlias(String dbAlias)
          Sets the name of the database to use for subsequent connections.
 void setDbNamesFile(String value)
          Set the name and path of the database name lookup file.
 void setPassword(String pw)
          Sets the password for the ConnectionPool and subsequent connections.
 void setSid(String s)
          Sets the Oracle Sid variable but has no effect on the connection.
 void setUsername(String name)
          Sets the username for the ConnectionPool and subsequent connections.
 

Method Detail

open

void open(String database)
          throws SQLException,
                 NamingException
Open the connection to database

Parameters:
database - the alias name of the database from the database properties file
Throws:
SQLException
NamingException

open

void open(String database,
          String name,
          String pw)
          throws SQLException,
                 NamingException
Open the connection to database using name and password given

Parameters:
database - the alias name of the database from the database properties file
name - username to connect as
pw - password for the given name
Throws:
SQLException
NamingException

open

void open()
          throws SQLException,
                 NamingException
Opens the connection to the database using the established properties. If none are established the connection will fail.

Throws:
SQLException - thrown if an error occurs while connecting to the database
NamingException - thrown if an error occurs while attempting to read the parameters for the database
See Also:
(String, String, String), (String), open(String)

setDbNamesFile

void setDbNamesFile(String value)
Set the name and path of the database name lookup file. The file contains the meta data needed to connect to the target database such as usernames and encrypted passwords. The default location for the file is:
META-INF/dbnames

Parameters:
value - the relative path the file (must be readable by server process)

getUsername

String getUsername()
Returns the current username for the ConnectionPool

Returns:
the database username currently in use

getPassword

String getPassword()
Returns the encrypted password for the current user

Returns:
encrypted password

setSid

void setSid(String s)
Sets the Oracle Sid variable but has no effect on the connection.

Parameters:
s - SID to set for this connection

setUsername

void setUsername(String name)
Sets the username for the ConnectionPool and subsequent connections.

Parameters:
name - database username

setPassword

void setPassword(String pw)
Sets the password for the ConnectionPool and subsequent connections. This password is not saved with the connection meta-data and is only in effect while the object persists. The password should be given in clear text, not encrypted.

Parameters:
pw - clear text password for the current user

setDb

boolean setDb(String dbAlias)
              throws NamingException
Sets the name of the database to use for subsequent connections. The name should be given as the Database alias name, not the JNDI name.

Parameters:
dbAlias - database alias name from the dbnames properties file.
Returns:
true if the operation is successful
Throws:
NamingException

setDbAlias

boolean setDbAlias(String dbAlias)
                   throws NamingException
Sets the name of the database to use for subsequent connections. The name should be given as the Database alias name, not the JNDI name.

Parameters:
dbAlias - database alias name from the dbnames properties file.
Returns:
true if the operation is successful
Throws:
NamingException

getDb

String getDb()
Returns the currently established database name

Returns:
the name of the current database

getDriver

String getDriver()
Returns the driver currently in effect from the dbnames file.

Returns:
the fully qualified driver as defined in the dbnames file (not the JNDI configuration).

getUrl

String getUrl()
Returns the URL to the database connection from the dbnames file.

Returns:
full URL as defined in the dbnames file (not the JNDI configuration).

getSid

String getSid()
Returns the optional established sid for Oracle databases. This parameter is not used by the pool but may be used for other purposes.

Returns:
the sid of the current Oracle database, if any or null if not set

getDbAlias

String getDbAlias()
Returns the currently established database alias

Returns:
name of the current database alias

isOpen

boolean isOpen()
Determines if the connection is open or not.

Returns:
true if the database connection is open, otherwise false

close

void close()
Closes the current pooled connection. If the connection is not open, no error is thrown.


getConnection

Connection getConnection()
Returns the active java.sql.Connection object.

Returns:
current Connection object

getJNDIDbFromAlias

String getJNDIDbFromAlias(String alias)
Returns the associated JNDI database name for the given alias name

Parameters:
alias - alias name of the database to lookup
Returns:
corresponding JNDI database name

generatePassword

String generatePassword(String database,
                        String name,
                        String password)
Generates a new encrypted password and returns the result. Use this method to create a new encrypted password for an account so it can be stored in the database properties configuration file.

Parameters:
name - name of the user account to be stored or set
password - associated to the user that will be encrypted
database - to associate with this password
See Also:
generatePassword(String,String,String)

MDi JLib
1.7.4

Copyright©2001-2007 MicroDeveloper, Inc. All Rights Reserved.