com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Posted by: ma haibo
Date: March 03, 2008 09:08PM

help!
most of the time connection works ok.
somtime we are getting

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 119977 ms ago.

I use mysql 5.0.27.
The server have 4G memory.
in my.cnf:
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer = 384M
max_allowed_packet = 10M
max_connections=1000
table_cache = 512
sort_buffer_size = 1024M
read_buffer_size = 1024M
join_buffer_size = 2000M
key_buffer_size = 1024M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 1024M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

innodb_additional_mem_pool_size = 64M
innodb_autoextend_increment = 256M

innodb_buffer_pool_size = 2096M # 50% ~ 80% of system memory
innodb_additional_mem_pool_size = 64M


java code :
public synchronized static DataSource createDataSource(String driver,String url,String username,String password) throws SQLException, ClassNotFoundException {

Class.forName(driver);

DataSource ds_unpooled = DataSources.unpooledDataSource(url,username,password);

Map overrides = new HashMap();

overrides.put("acquireIncrement", 2);
overrides.put("minPoolSize", 15);
overrides.put("maxPoolSize", 30);

overrides.put("maxStatements", 10000);

overrides.put("maxIdleTime", 3600 );

overrides.put("automaticTestTable", "C3P0TestTable");
overrides.put("testConnectionOnCheckin", true);

overrides.put("idleConnectionTestPeriod",180);
overrides.put("testConnectionOnCheckout", true);

// create the PooledDataSource using the default configuration and our overrides
DataSource ds_pooled = DataSources.pooledDataSource( ds_unpooled, overrides );
return ds_pooled;
}

Any help will be greatly appreciated!thank you!

Options: ReplyQuote


Subject
Written By
Posted
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
March 03, 2008 09:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.