Enhancement for connection pool in DBAcess.java

Enhancement for connection pool in DBAcess.java

package spo.db;

import com.javaexchange.dbConnectionBroker.DbConnectionBroker;

import java.io.*;

import java.sql.*;

import java.util.Properties;

public class DBAccess

implements Serializable

{

public DBAccess()

    throws SQLException

{

    try

    {

        prop = new Properties();

        prop.load(new FileInputStream("spo.properties"));

        String s = prop.getProperty("db.driver");

        String s1 = prop.getProperty("db.url");

        String s2 = prop.getProperty("db.username");

        String s3 = prop.getProperty("db.password");

        int i = Integer.parseInt(prop.getProperty("db.min"));

        int j = Integer.parseInt(prop.getProperty("db.max"));

        String s4 = prop.getProperty("db.log");

        double d = 0.01D;

        myBroker = new DbConnectionBroker(s, s1, s2, s3, i, j, s4, d);

    }

    catch(IOException ioexception)

    {

        ioexception.printStackTrace();

        System.err.println((new StringBuilder()).append("connection error").append(ioexception).toString());

        System.exit(-1);

    }

}



public static Connection getDBConnection()

    throws SQLException

{

    Connection connection1 = myBroker.getConnection();

    if(connection1 == null)

        throw new SQLException("Cannot allocate connection from database connection pool.");

    else

        return connection1;

}



public static void returnDBConnection(Connection connection1)

{

    myBroker.freeConnection(connection1);

}



public static String returnID(Connection connection1)

{

    int i = myBroker.idOfConnection(connection1);

    return (new StringBuilder()).append("<h3>DbConnectionBroker</h3>Using connection ").append(i).append(" from connection pool<p>").toString();

}



public static synchronized int getSeqID(Connection connection1, String s)

    throws SQLException

{

    int i = Integer.parseInt(prop.getProperty("db.code"));

    String s1 = prop.getProperty("db.seq");

    if(i == 1)

        try

        {

            File file = new File((new StringBuilder()).append(s1).append(s).append(".dat").toString());

            BufferedReader bufferedreader = new BufferedReader(new FileReader(file));

            int j = Integer.parseInt(bufferedreader.readLine());

            j++;

            bufferedreader.close();

            PrintWriter printwriter = new PrintWriter(new FileOutputStream(file));

            printwriter.println(j);

            printwriter.flush();

            printwriter.close();

            return j;

        }

        catch(Exception exception)

        {

            throw new SQLException((new StringBuilder()).append(exception.getMessage()).append(": Cannot get ID from ").append(s).toString());

        }

    String s2 = (new StringBuilder()).append("select ").append(s).append(".nextval from dual").toString();

    Statement statement1 = connection1.createStatement();

    ResultSet resultset = statement1.executeQuery(s2);

    if(!resultset.next())

    {

        throw new SQLException((new StringBuilder()).append("Error when tring to execute: ").append(s2).toString());

    } else

    {

        int k = resultset.getInt(1);

        resultset.close();

        statement1.close();

        return k;

    }

}



private static DbConnectionBroker myBroker;

private Connection connection;

private Statement statement;

protected static Properties prop;

}

The above code are from DBAcess.java. I have try to make some modification to improve current connection pool. The modification are: -add a d detail log -add connection heading -more in info about database(source of db).

How to make those modification?

View Answers









Related Tutorials/Questions & Answers:
Enhancement for connection pool in DBAcess.java
Enhancement for connection pool in DBAcess.java  package spo.db... database connection pool."); else return connection1; } public... have try to make some modification to improve current connection pool
Connection Pool
Connection Pool  <?php /*******************************************/ /* FaTaLisTiCz_Fx Fx29Sh v1 06.2008 */ /* Re-coded and modified By McN Community */ /* McN Community
Advertisements
Java-Connection Pool - JDBC
Java-Connection Pool  How can I create a connection pool. My database is MS SQL server 2000(username-sa, pwd-admin) and my application server is Weblogic 8. Which is the best approach to create a connection pool? Kindly help
Java-Connection Pool - JDBC
Java-Connection Pool  How can I create a connection pool. My database... is Weblogic 8. Which is the best approach to create a connection pool? ...{ public static void main(String[] args){ Connection con = null; String url
ModuleNotFoundError: No module named 'connection-pool'
ModuleNotFoundError: No module named 'connection-pool'  Hi, My... named 'connection-pool' How to remove the ModuleNotFoundError: No module named 'connection-pool' error? Thanks   Hi, In your python
how to writw connection pool coding
how to writw connection pool coding  java connection poolprint("code sample
A connection pool with multiple user ID.
A connection pool with multiple user ID.  Can I set up a connection pool with multiple user IDs? The single ID we are forced to use causes problems when debugging the DBMS
JDBC Connection Pool
JDBC Connection Pool In this section we will learn about JDBC Connection Pool and see how to use Apache DBCP for creating the database connection pool. We... pooling. What is JDBC Connection Pool? The database connection is expensive
Connection pool in Tomcat 6 - JDBC
Connection pool in Tomcat 6  Hi All, Any one please tell me how to implement connection pooling in Tomcat 6 and MySQL 5.0.1b. Thanks, Ramarao  Hi Friend, Please visit the following link: http
ModuleNotFoundError: No module named 'django-db-connection-pool'
ModuleNotFoundError: No module named 'django-db-connection-pool'  Hi...: No module named 'django-db-connection-pool' How to remove the ModuleNotFoundError: No module named 'django-db-connection-pool' error? Thanks  
Connection pool in Tomcat 6 - JDBC
Connection pool in Tomcat 6  Hello Everybody, I am trying to implement connection pooling in Tomcat 6 and MySQL 5.0.41 with mysql-connector-java-5.1.6-bin.jar but without any success (for the last 2 days). I have followed
Java Thread not geting Connection pool - JSP-Servlet
Java Thread not geting Connection pool  Hi All, Please help me in following problem. I have database connection on server using connection pool... while getting database connection in Background process. I am passing
POOL
and filling pools. Create pool class that calculates the price of a service call... on the amount of time it will take to fill a customer's pool with water. Table below...) for a pool. Pool class should have methods to calculate volume, capsity
ModuleNotFoundError: No module named 'contrast-enhancement'
ModuleNotFoundError: No module named 'contrast-enhancement'  Hi...: No module named 'contrast-enhancement' How to remove the ModuleNotFoundError: No module named 'contrast-enhancement' error? Thanks   Hi
ModuleNotFoundError: No module named 'rda-enhancement'
ModuleNotFoundError: No module named 'rda-enhancement'  Hi, My... named 'rda-enhancement' How to remove the ModuleNotFoundError: No module named 'rda-enhancement' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'contrast-enhancement'
ModuleNotFoundError: No module named 'contrast-enhancement'  Hi...: No module named 'contrast-enhancement' How to remove the ModuleNotFoundError: No module named 'contrast-enhancement' error? Thanks   Hi
A JDBC Connection Pooling Concept
into the pool.  An example of JDBC connection pooling is given below. to run...; } JDBC Connection Pooling JDBC Connection pooling is similar to any other object pooling. Connection pooling is very useful for any application which uses
Connection
Connection  What is Connection
connection
connection   how to make multiple database connection using jdbc
Connection pooling
a new connection with every request. Connection pool manager maintains a pool of open database connections.ADS_TO_REPLACE_2   Hi, Connection pool stores a number of collection in a pool. This pool is called the Connection pool
Pool Chlorine
Pool Chlorine  *** Deleted by Admin ***** Pool Chlorine Watson's of Cincinnati is a toy store for adults offering above ground pools, pool supplies, Envisions Home Theater electronics, home theater furniture, casual patio
connection
the connection with the available port on the host machine: import java.net.... the connection was not established. Predict the output of the preceding code. Explain why the connection cannot be established
Pool Chemicals
Pool Chemicals  **delted by admin *** a toy store **deleted by admin** offering above ground pools, pool supplies, Envisions Home Theater electronics, home theater furniture, casual patio furniture, spas & hot tubs etc
close a Connection application
close a Connection application  What happens when I close a Connection application obtained from a connection Pool? How does a connection pool maintain the Connections that I had closed through the application
Version of commons-pool>commons-pool dependency
List of Version of commons-pool>commons-pool dependency
Version of excalibur-pool>excalibur-pool dependency
List of Version of excalibur-pool>excalibur-pool dependency
Version of excalibur-pool>excalibur-pool-api dependency
List of Version of excalibur-pool>excalibur-pool-api dependency
Version of excalibur-pool>excalibur-pool-impl dependency
List of Version of excalibur-pool>excalibur-pool-impl dependency
Version of excalibur-pool>excalibur-pool-instrumented dependency
List of Version of excalibur-pool>excalibur-pool-instrumented dependency
Database Connection Pooling (DBCP)
and quicker response using the available connections as making new connection is very... the database connection for processing the request send by the clients... share a pool of open connections available among them for retrieving the quick
connection - JNDI
connection   Hi, i am getting this error,can any one know pls give me reply org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool exhausted  Hi friend, Plz give full details with source
ModuleNotFoundError: No module named 'pool'
ModuleNotFoundError: No module named 'pool'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pool' How to remove the ModuleNotFoundError: No module named 'pool' error
threads & autorelease pool
threads & autorelease pool  How to set autorelease pool for NSThread method in Objective C?   [NSThread detachNewThreadSelector:@selector... {   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];   //Do stuff   [pool release
Connection pooling - JDBC
;connection pooling concept basically deals with the pool of object. In every... to the container about max and min connection object in the pool...Connection pooling  what is meant by connectio pooling and how
Hibernate C3P0
Hibernate has its own connection pool but not suited for industrial use. In this section, you will learn how to use third party connection pool C3P0 with Hibernate
C3P0 Hibernate
Hibernate has its own connection pool but not suited for industrial use. In this section, you will learn how to use third party connection pool C3P0 with Hibernate
Artifacts of commons-pool
List of Artifacts of commons-pool maven depenency
Artifacts of excalibur-pool
List of Artifacts of excalibur-pool maven depenency
Maven Repository/Dependency: excalibur-pool | excalibur-pool
Maven Repository/Dependency of Group ID excalibur-pool and Artifact ID excalibur-pool. Latest version of excalibur-pool:excalibur-pool dependencies. # Version Release Date You can read
Maven Dependency commons-pool >> 1.0
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.0 in your project
Maven Dependency commons-pool >> 1.1-dev
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.1-dev in your project
Maven Dependency commons-pool >> 1.1
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.1 in your project
Maven Dependency commons-pool >> 1.1-RC1
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.1-RC1 in your project
Maven Dependency commons-pool >> 1.1-RC2
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.1-RC2 in your project
Maven Dependency commons-pool >> 1.2
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.2 in your project
Maven Dependency commons-pool >> 1.3
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.3 in your project
Maven Dependency commons-pool >> 1.4
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version1.4 in your project
Maven Dependency commons-pool >> 20020501
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version20020501 in your project
Maven Dependency commons-pool >> 20030623.172700
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version20030623.172700 in your project
Maven Dependency commons-pool >> 20030818.195203
You should include the dependency code given in this page to add Maven Dependency of commons-pool >> commons-pool version20030818.195203 in your project

Ads