Results 1 to 7 of 7
  1. #1
    yhqian99 is offline Member
    Join Date
    Feb 2009
    Posts
    8
    Rep Power
    0

    Default Apache Commons DBCP problem "Communication Link Failure " after 10 hours

    hi,

    I am developing a Client-Server java application, and use Apache Commons DBCP (commons-dbcp-1.4.jar) Connection pool at the server side to access MySQL5, when the client login in, the server will access database to verify the username/passord. The Connection Pool seems works fine, except that error "Communication Link Failure " occurs after no access to db in 10 hours.

    the code snips I used as follows:

    // database param
    dbHost = defaultProps.getProperty("mysql.host", "localhost").trim();
    dbPort = defaultProps.getProperty("mysql.port", "3306").trim();
    dbDatabase = defaultProps.getProperty("mysql.database", "ictbox").trim();
    dbUser = defaultProps.getProperty("mysql.user", "root");
    dbPassword = defaultProps.getProperty("mysql.password", "passw0rd").trim();

    maxActive = Integer.parseInt(defaultProps.getProperty("pool.co nn.maxActive", "30").trim());
    maxIdle = Integer.parseInt(defaultProps.getProperty("pool.co nn.maxIdle", "10").trim());
    minIdle = Integer.parseInt(defaultProps.getProperty("pool.co nn.minIdle", "6").trim());
    maxWait = Integer.parseInt(defaultProps.getProperty("pool.co nn.maxWait", "200").trim());

    dbURL = "jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbDatabase;
    dbURL = dbURL + "?useUnicode=true&characterEncoding=gbk&tcpKeepAli ve=true&autoReconnect=true";


    try
    {
    Class.forName(dbDriver);
    } catch (ClassNotFoundException e)
    {
    dblog.error(e.getMessage());
    }

    // an object pool
    GenericObjectPool.Config config = new GenericObjectPool.Config();
    config.maxActive = maxActive;
    config.maxIdle = maxIdle;
    config.minIdle = minIdle;
    config.maxWait = maxWait;
    ObjectPool pool = new GenericObjectPool(null, config);

    // Connection Factory, the pool use it to create Connections
    ConnectionFactory connectionFactory =
    new DriverManagerConnectionFactory(dbURL, dbUser, dbPassword);

    // PoolableConnectionFactory wraps the "real" Connections
    PoolableConnectionFactory poolableConnectionFactory =
    new PoolableConnectionFactory(connectionFactory, pool, null, null, false, true);

    // Finally, we create the PoolingDriver itself, passing in the object
    // pool we created.
    dataSource = new PoolingDataSource(pool);





    How to solve this problem? Can we solve this problem in source code or updating the configuration of MySQL5?

    Thanks

    yhqian

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Apache Commons DBCP problem "Communication Link Failure " after 10 hours

    Don't use the browser's back button to edit your posts, as that creates multiple posts.

    I've removed the other one.

    db

    edit You didn't bother to return to the first thread you started. Why should we expect anything different here?
    Java license management
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: Apache Commons DBCP problem "Communication Link Failure " after 10 hours

    Have you got the stack trace?
    Is it causing a failure in your code, or is it simply the pool discovering a broken connection and rebuilding it?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    yhqian99 is offline Member
    Join Date
    Feb 2009
    Posts
    8
    Rep Power
    0

    Default Re: Apache Commons DBCP problem "Communication Link Failure " after 10 hours

    I usually put the stack trace to my log file, but I did not see any error mesage in my log, I think it is not causing a failure in my code.

    The interesting thing is that after the "Communication Link Failure " occurs , I use the Client to login in again and the second login goes smoothly, and no problem at all afterwords

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: Apache Commons DBCP problem "Communication Link Failure " after 10 hours

    If your first login attempt fails when it should succeed then I don't think it's DBCP rebuilding a Connection, since I think (you'd have to read the docs on that) it should do that behind the scenes.

    Also if the login fails then I would expect you to be logging that. So where are you getting the "Communication Link Failure" message if not your logs?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    yhqian99 is offline Member
    Join Date
    Feb 2009
    Posts
    8
    Rep Power
    0

    Default Re: Apache Commons DBCP problem "Communication Link Failure " after 10 hours

    hi,

    My Server runs on linux Platform like follows:

    java -jar XXXXX.jar 1>ictback.log 2>&1 &

    I got the "Communication Link Failure" in ictback.log, which is System level error, not the code error.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: Apache Commons DBCP problem "Communication Link Failure " after 10 hours

    Does that not give a stack trace?
    Just wondering where it's happening and on what call chain.
    DBCP probably periodically checks the connections to ensure they're alive and refreshes any that aren't (as well as logging the fact).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 2
    Last Post: 06-16-2011, 05:44 PM
  2. Replies: 1
    Last Post: 12-15-2010, 09:16 AM
  3. Replies: 1
    Last Post: 10-20-2008, 08:35 AM
  4. Replies: 1
    Last Post: 03-14-2008, 03:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •