用户根在Hibernate中已经具有超过'max_user_connections'个活动连接 [英] User root already has more than 'max_user_connections' active connections in Hibernate

查看:36
本文介绍了用户根在Hibernate中已经具有超过'max_user_connections'个活动连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JDBC和Hibernate来连接数据库.

i am using JDBC and Hibernate for Connecting to database.

所以我正在使用JDBC触发选择查询到数据库,但是当我使用Hibernate触发插入查询时,它给出了一个例外:

so i am firing select Query to database using JDBC, but when i fire insert Query using Hibernate it gives an exception:

用户root已经具有超过"max_user_connections"个活动连接.

User root already has more than 'max_user_connections' active connections.

为什么呢?

在调用session.beginTransaction()时是否正在创建连接

is it creating Connection when call session.beginTransaction()

推荐答案

您已经用尽了在数据库中为root配置的连接数.我猜您正在使用MySQL(只是基于userid的预感).您可以尝试几种修复方法:

You have exhausted the number of connections you have configured in you DB for root. I am guessing you are using MySQL (just a hunch based on the userid). There are several fixes you can try:

  1. 为您的所有应用程序创建一个以上的用户,以便您不竞争与数据库的连接
  2. 增加您的用户ID允许的连接数,该用户ID似乎是 root
  3. 减少您的应用程序正在使用的连接数.希望您正在使用连接池.

您可能需要检查代码以确保正确关闭连接.随着时间的流逝,您的代码可能成为孤立的连接.

You probably need to check your code to make sure you are closing connections appropriately. Your code could be orphaning connections over time.

请务必注意,在开发环境之外,您实际上不应以 root 的身份进行任何应用程序编码. root 用户拥有太多特权,从安全性角度来讲,您容易遇到各种令人讨厌的问题.

It would be important to note that outside of a dev environment, you really should not be doing any app coding as root. The root user has too many privileges, and you open yourself to all sorts of nasty problems from a security aspect.

这篇关于用户根在Hibernate中已经具有超过'max_user_connections'个活动连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆