|
Enterprise Information Portal APIs |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.gcs.db.util.ConnectionManager
The ConnectionManager serves 3 functions:
As part of its initialization, ConnectionManager constructs
an instance of itself using the values in a file called
"db2properties.txt". [Note: In future versions
this intialization might create more than one instance (one per
per database, for example).] This properties file
contains "driver", "database", "user", and "password" properties.
A sample db2 properties file looks as follows:
All objects that need to use a database connection must get the
connnection through a
# The full classname of the JDBC driver to load.
driver = COM.ibm.db2.jdbc.app.DB2Driver
#The URL of the server and database to connect to
database = jdbc:db2:urlpool
#The name of the database user account
user = gcs
#The password for the database user account
password= gcs
ConnectionManager
object. Moreover, they
must obtain the instance of this object through the static method
getManager(). This ensures that only one ConnectionManager
instance
exists per database connection.
Objects may access the database connection object using getConnection()
.
Any object that successfully obtains a connection must return it
through releaseConnection(int) which indicates
whether or not the connection is being returned in an
erroneous state. If the connection state is in error,
the ConnectionManger closes it and establishes a new
connection.
[Eventually, should have a watchdog thread to detect
timed out connections.]
Method Summary | |
java.sql.Connection |
getConnection(int level)
In order to obtain a JDBC connection, the application must request it from the ConnectionManager by calling this method. |
java.lang.String |
getDBName()
Get the database instance name. |
static ConnectionManager |
getManager()
Returns a reference to the ConnectionManager object created at initialization with the default db2 properties. |
int |
getMaxSqlBytes()
|
java.lang.String |
getPassword()
Get the user password. |
java.lang.String |
getUser()
Get the database user name. |
static void |
initialize()
Initializes the ConnectionManager using the default properties file: db2properties.txt |
static void |
initialize(java.lang.String filename)
Create a new instance of the ConnectionManager using the values in a properties file. |
static void |
initialize(java.lang.String driver,
java.lang.String database,
java.lang.String user,
java.lang.String password)
Create a new instance of the ConnectionManager using the specified parameters. |
static void |
main(java.lang.String[] args)
|
void |
releaseConnection(int error)
The application object calls this method to return the connection that it has obtained. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static ConnectionManager getManager()
public java.sql.Connection getConnection(int level) throws TransactionException
level
- The Transaction Isolation level for the connection.
(Defined in java.sql.Connection.)public void releaseConnection(int error)
int
- error -1 if connection is in error, 0 if
connection is okay.public java.lang.String getUser()
public java.lang.String getPassword()
public int getMaxSqlBytes()
public java.lang.String getDBName()
public static void initialize()
public static void initialize(java.lang.String filename)
public static void initialize(java.lang.String driver, java.lang.String database, java.lang.String user, java.lang.String password)
driver
- The full classname of the jdbc driver to use (e.g.,
COM.ibm.db2.jdbc.app.DB2Driver)database
- The uri of the database to connect to
(e.g., jdbc:db2:eip ).user
- The name of the user (e.g., db2admin)password
- The password to use (e.g., foobar )public static void main(java.lang.String[] args)
|
EIP Web Crawler APIs | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |