Connections

In an enterprise application scenario, multiple users vie for server resources such as message queues, enterprise servers, and database information. Today and tomorrow you will be focusing on the database server resources, and hence you will be studying database connections. Connections to the other server resources, such as message queues, will be covered in the coming days.

The common factor of most of these resources is their entry point, a database connection. To establish a database connection, you would need to access the database over the network. All operations requiring network access take up time and resources. These operations are very time-consuming and hence must be avoided as far as possible.

It can be clearly seen that, in order to optimize the performance of the application, it is essential to manage the database connections with prudence.

To connect to the database, JDBC uses drivers to translate the JDBC calls into database-specific calls. The JDBC applications are abstracted by the JVM and hence don't need to worry about platform-independence issues.

The JDBC API provides a DriverManager class, which must be implemented by a JDBC driver vendor. The DriverManager class is the entry point to writing JDBC code in a Java application. Every time you ask the DriverManager to give you a connection to the database, the DriverManager performs a series of tasks. The DriverManager class provides methods to support these tasks.

The DriverManager establishes a connection with the database by authenticating the Java application with the database, using a user ID and password that is provided by the programmer.

The DriverManager opens a socket connection to the database and requests the database engine to open a connection. The URL, user ID, and password for opening this connection are to be specified in the parameters to the DriverManager. The database engine then authenticates the user ID and password, allocates the necessary communication and memory resources, loads the roles and corresponding security context, and then passes a handle to the connection back to the DriverManager. Hence, it normally takes around two to three seconds for a single database connection under ideal network conditions. When the calling class has finished executing the function, it instructs the database to close the connection. If you forget to close the database connection, then you have multiple open database connections, which impairs the database performance.

Also, all proprietary software involves user-licensing issues. If the number of users connecting to a database exceeds the licensed limit, when multiple users access the system, an error can occur each time a connection is made dynamically. This can be a very unpleasant scenario if it involves a system such as credit card processing or any other financial transaction. Here connection pools, MultiPools, and DataSources come into the picture. The following sections discuss each of these concepts.



Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net