Eclipse配置JNDI连接池
JNDI就是(JavaNaming and Directory Inteface)Java名称目录接口
概念参考-JNDI 的理解
1、预加载连接池时出错
2、数据源拒绝建立连接,来自服务器的消息:“连接太多”
java.sql.SQLException: Error preloading the connection pool
Caused by: java.sql.SQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "`Too many connections`"
java.sql.SQLException: Cannot create PoolableConnectionFactory (Data source rejected establishment of connection, message from server: "Too many connections")
解决方案:
连接数设置大点,超时时间设小点,自动清除时间短一点
set global max_connections = 1000; set global wait_timeout=20;set global interactive_timeout=30;
mysql默认是28800,即8小时。
(1)interactive_timeout: 服务器关闭交互式连接前等待活动的秒数
(2)wait_timeout: 服务器关闭非交互连接之前等待活动的秒数。
两者生效取决于:客户端是交互或者非交互的连接。
通过Navicat客户端工具连接是交互连接,通过web浏览器客户端访问时非交互连接。
MySQL安装路径
C:Program Files (x86)MySQLMySQL Server 5.5my.ini
#最大连接数
show variables like 'max_connections';
#响应的连接数
show status like 'max_used_connections';
参考博客
如果你的项目重启数据库连接数突增!连接数据库超时!
配置数据库连接池使用之JNDI的方式
关于mysql的wait_timeout参数 设置不生效的问题



