com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 在 mysql

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1392304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:04:08  来源:igfitidea点击:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: in mysql

mysqljdbc

提问by

Hi I have created jdbc program and database is MySQL 5.1 Also all my friends using same database for connection. Total number of connection became 150 from all of us. So when i want to connect more then i got the following error

嗨,我已经创建了 jdbc 程序,数据库是 MySQL 5.1 还有我所有的朋友都使用相同的数据库进行连接。总连接数从我们所有人变成了150个。所以当我想连接更多时,我收到以下错误

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:无法创建到数据库服务器的连接。尝试重新连接 3 次。放弃。

How to resolve this error.

如何解决此错误。

Thanks Sunil Kumar Sahoo

感谢 Sunil Kumar Sahoo

回答by

I solved the problem by increasing number of connection

我通过增加连接数解决了这个问题

set @@global.max_connections = 1250;

设置@@global.max_connections = 1250;

Have a look on the below link http://www.netadmintools.com/art573.html

看看下面的链接 http://www.netadmintools.com/art573.html

回答by Daniel

Maybe you haven't create the databases or tables in the databases. Please check the reason behind "Could not create connection to database server."

也许您还没有在数据库中创建数据库或表。请检查“无法创建与数据库服务器的连接”背后的原因。

I have met this error, because I didn't create the database.

我遇到了这个错误,因为我没有创建数据库。

回答by óscar uno mas

when you make a connection from higher versions of android version 9 to a mysql server you must always allow connections through:

当您从更高版本的 android 版本 9 连接到 mysql 服务器时,您必须始终允许通过以下方式连接:

if (Constants.VERSION_SDK > 9) {
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
}

回答by Joe Cheng

One possibility is that you've forgot to setup the environment variable for MySQL in your OS.

一种可能性是您忘记在操作系统中为 MySQL 设置环境变量。