Java Reference
In-Depth Information
// Create the statement
Statement statement = con.createStatement();
// Use the created statement to SELECT the DATA
// FROM the Titles Table.
ResultSet rs = statement.executeQuery(“SELECT * “ +
“FROM Titles”);
// iterate over the results here, if you choose!!!
// Close the ResultSet
catch (SQLException sqle) {
catch (Exception e) {
finally {
// Release the connection
When the doPost() method is finished with the connection, it must return it to the pool. To do
this, it calls the ConnectionPools 's releaseConnection() method, passing it the Connection
// Release the connection
The releaseConnection() method searches the pool for the Connection object and marks it
as available for use.
The last interaction a servlet has with the ConnectionPool is when it shuts down. In its
destroy() method, the servlet calls the ConnectionPool.emptyPool() method. This method
iterates over the entire pool, closing connections until all the Connection objects are closed.
Now you have access to pre-opened connections to the database and can service just about any
number of simultaneous requests.
Search WWH ::

Custom Search