Results 1 to 7 of 7
- 02-24-2012, 08:28 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 4
- Rep Power
- 0
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
- 02-24-2012, 09:05 AM #2
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 managementWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-24-2012, 09:21 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
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.
- 02-24-2012, 10:29 AM #4
Member
- Join Date
- Feb 2009
- Posts
- 4
- Rep Power
- 0
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
- 02-24-2012, 10:49 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
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.
- 02-24-2012, 11:05 AM #6
Member
- Join Date
- Feb 2009
- Posts
- 4
- Rep Power
- 0
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.
- 02-24-2012, 11:11 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
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.
Similar Threads
-
Error "org.apache.commons.logging package does not exist" appeared
By vjoshi in forum Java ServletReplies: 2Last Post: 06-16-2011, 04:44 PM -
Communication link failure using hibernate
By bentoi in forum JDBCReplies: 1Last Post: 12-15-2010, 08:16 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM -
failure at Class.forName("oracle.jdbc.driver.OracleDriver");
By RonNYC in forum EclipseReplies: 1Last Post: 03-14-2008, 02:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks