impossible to connect to external mysql server
Asked by Monizze IT:

Hello,

impossible to connect my bamboo server to mysql server.

The mysql server is on another server. The ping and the mysql client connection from the bamboo server is working properly. The driver of mysql is installed and added to the lib dir pof bamboo through a symbolic link.![Screenshot_2019-03-05 Choose how you wish Bamboo to connect to your database - Atlassian Bamboo.png](/t5/image/serverpage/image-id/47738iC97CB92A36818931/image-size/large?v=v2&px=999 "Screenshot_2019-03-05 Choose how you wish Bamboo to connect to your database - Atlassian Bamboo.png")

logs :

2019-03-05 13:56:16,989 INFO \[performSetupDatabaseConnectionBackgroundThread\] \[SetupDatabaseConnectionAction\] Validating database configuration...  
2019-03-05 13:56:16,989 INFO \[performSetupDatabaseConnectionBackgroundThread\] \[SetupDatabaseConnectionAction\] Validating connection to url: \[jdbc:mysql://X.X.X.X:3306/bamboo?autoReconnect=true\&useUnicode=true\&characterEncoding=utf8\]  
2019-03-05 13:56:18,992 WARN \[http-nio-8085-exec-14\] \[TokenHelper\] Could not find token mapped to token name: token  
2019-03-05 13:56:21,000 ERROR \[performSetupDatabaseConnectionBackgroundThread\] \[DefaultAtlassianBootstrapManager\] Could not successfully test your database:  
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)  
at com.mysql.jdbc.Util.getInstance(Util.java:386)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)  
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2390)  
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)  
at com.mysql.jdbc.ConnectionImpl.\<init\>(ConnectionImpl.java:839)  
at com.mysql.jdbc.JDBC4Connection.\<init\>(JDBC4Connection.java:49)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)  
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:421)  
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:350)  
at java.sql.DriverManager.getConnection(DriverManager.java:664)  
at java.sql.DriverManager.getConnection(DriverManager.java:247)  
at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:347)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.createConnection(SetupDatabaseConnectionAction.java:143)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.validateDatabase(SetupDatabaseConnectionAction.java:122)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.validateFields(SetupDatabaseConnectionAction.java:71)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.execute(SetupDatabaseConnectionAction.java:82)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:899)  
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1544)  
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)  
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:98)  
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:90)  
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620)  
at ognl.ASTMethod.getValueBody(ASTMethod.java:91)  
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)  
at ognl.SimpleNode.getValue(SimpleNode.java:258)  
at ognl.Ognl.getValue(Ognl.java:470)  
at ognl.Ognl.getValue(Ognl.java:434)  
at com.opensymphony.xwork2.ognl.OgnlUtil$3.execute(OgnlUtil.java:401)  
at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecuteMethod(OgnlUtil.java:453)  
at com.opensymphony.xwork2.ognl.OgnlUtil.callMethod(OgnlUtil.java:399)  
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:438)  
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:293)  
at org.apache.struts2.interceptor.BackgroundProcess$1.run(BackgroundProcess.java:55)  
at java.lang.Thread.run(Thread.java:748)  
Caused by: java.lang.NullPointerException  
at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3281)  
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1940)  
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1866)  
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1252)  
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2488)  
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2329)  
... 39 more  
2019-03-05 13:56:21,001 ERROR \[performSetupDatabaseConnectionBackgroundThread\] \[SetupDatabaseConnectionAction\] Unable to connect to database: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.  
com.atlassian.config.bootstrap.BootstrapException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.  
at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:359)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.createConnection(SetupDatabaseConnectionAction.java:143)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.validateDatabase(SetupDatabaseConnectionAction.java:122)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.validateFields(SetupDatabaseConnectionAction.java:71)  
at com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction.execute(SetupDatabaseConnectionAction.java:82)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:899)  
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1544)  
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)  
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:98)  
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:90)  
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620)  
at ognl.ASTMethod.getValueBody(ASTMethod.java:91)  
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)  
at ognl.SimpleNode.getValue(SimpleNode.java:258)  
at ognl.Ognl.getValue(Ognl.java:470)  
at ognl.Ognl.getValue(Ognl.java:434)  
at com.opensymphony.xwork2.ognl.OgnlUtil$3.execute(OgnlUtil.java:401)  
at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecuteMethod(OgnlUtil.java:453)  
at com.opensymphony.xwork2.ognl.OgnlUtil.callMethod(OgnlUtil.java:399)  
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:438)  
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:293)  
at org.apache.struts2.interceptor.BackgroundProcess$1.run(BackgroundProcess.java:55)  
at java.lang.Thread.run(Thread.java:748)  
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)  
at com.mysql.jdbc.Util.getInstance(Util.java:386)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)  
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)  
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2390)  
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)  
at com.mysql.jdbc.ConnectionImpl.\<init\>(ConnectionImpl.java:839)  
at com.mysql.jdbc.JDBC4Connection.\<init\>(JDBC4Connection.java:49)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)  
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:421)  
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:350)  
at java.sql.DriverManager.getConnection(DriverManager.java:664)  
at java.sql.DriverManager.getConnection(DriverManager.java:247)  
at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:347)  
... 26 more  
Caused by: java.lang.NullPointerException  
at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3281)  
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1940)  
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1866)  
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1252)  
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2488)  
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2329)  
... 39 more  
2019-03-05 13:56:21,001 INFO \[performSetupDatabaseConnectionBackgroundThread\] \[SetupDatabaseConnectionAction\] Database configuration is invalid: {}  
2019-03-05 13:56:21,645 INFO \[http-nio-8085-exec-17\] \[AccessLogFilter\] 10.100.200.222 POST <http://10.0.0.44:8085/setup/performSetupDatabaseConnection.action> 366100kb  
2019-03-05 13:56:21,813 INFO \[http-nio-8085-exec-18\] \[AccessLogFilter\] 10.100.200.222 GET <http://10.0.0.44:8085/setup/performSetupDatabaseConnection.action> 366100kb  
2019-03-05 13:56:21,893 WARN \[http-nio-8085-exec-18\] \[TextProviderHelper\] The first TextProvider in the ValueStack (com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction) could not locate the message resource with key 'help.prefix'  
2019-03-05 13:56:21,893 WARN \[http-nio-8085-exec-18\] \[TextProviderHelper\] The default value expression 'help.prefix' was evaluated and did not match a property. The literal value 'help.prefix' will be used.  
2019-03-05 13:56:21,894 WARN \[http-nio-8085-exec-18\] \[TextProviderHelper\] The first TextProvider in the ValueStack (com.atlassian.bamboo.ww2.actions.setup.SetupDatabaseConnectionAction) could not locate the message resource with key 'db.mysql'  
2019-03-05 13:56:21,894 WARN \[http-nio-8085-exec-18\] \[TextProviderHelper\] The default value expression 'db.mysql' was evaluated and did not match a property. The literal value 'db.mysql' will be used.


Answers:
author: Alexis Robert
body: Hi [@Monizze IT](/t5/user/viewprofilepage/user-id/1008085) ,

can you find an error in the logs that might give more details on why you're getting an issue conecting to MySQL ?

Thanks,

--Alexis

comments: author: Monizze IT
body: Thanks, I have added the logs from catalina.out


author: Akhtaruzzaman SM
body: Thanks. No clear idea to me. AKTAR


author: V V S N Sudheer Vissa
body: Please Update Database Driver which is compatible with current DB version. Test Drivers until supports current DB version.

and useSSL=true / useSSL=false should be added to DB host URL.


author: Foong
body: According to this [KB](https://confluence.atlassian.com/jirakb/installing-or-upgrading-jira-fails-with-nullpointerexception-when-using-mysql-driver-v5-1-16-241567359.html), it is a bug in MySQL.

Try removing "\&characterEncoding=utf8" from the Database URL.

comments: author: Monizze IT
body: Thanks, but it change nothing, I added this because it failes at first, but even after retring it, still continue to fail.

So I only kept "?autoReconnect=true"

the mysql driver version is 5.1.25


author: Foong
body: The latest stack trace still showing the same error?

```
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3281)

```

What is the MySQL server version?


author: Monizze IT
body: yes, still the same error  
Mysql version is 8.0.15


author: Monizze IT
body: I try to upgrade to mysql connector version to the last one ... and miracle it's working!

thanks for the help


author: Foong
body: Take note that MySQL server version 8 is not supported yet.

Feature request to support MySQL server version 8 <https://jira.atlassian.com/browse/BAM-19869>


author: Monizze IT
body: Well, the issue doesn't help. IS there anything broken? Why the interface didn't say anything?


author: Foong
body: Bamboo does not limit the usage of MySQL server 8 yet and there isn't any known issue with using MySQL 8.

MySQL 8 isn't stated as supported cause it is not tested to be working fine with Bamboo yet.


author: Zen Pwning
body: Upgrading the mysql connector worked for me


author: Zen Pwning
body: My Error is:

```
2020-07-12 04:39:54,869 http-nio-8080-exec-11 ERROR anonymous 279x8x1 dg46am 124.123.168.188 /secure/SetupDatabase!connectionCheck.jspa [c.a.config.bootstrap.DefaultAtlassianBootstrapManager] Could not successfully test your database:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.Util.getInstance(Util.java:383)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:958)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2326)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2079)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
... 3 filtered
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:347)
at com.atlassian.jira.config.database.JdbcDatasource.getConnection(JdbcDatasource.java:211)
at com.atlassian.jira.config.database.DatabaseConfig.testConnection(DatabaseConfig.java:88)
at com.atlassian.jira.web.action.setup.SetupDatabase.testConnection(SetupDatabase.java:225)
at com.atlassian.jira.web.action.setup.SetupDatabase.doValidation(SetupDatabase.java:189)
at com.atlassian.jira.web.action.setup.SetupDatabase.doConnectionCheck(SetupDatabase.java:121)
... 3 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:70)
at webwork.util.InjectionUtils.invoke(InjectionUtils.java:56)
... 2 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
... 45 filtered
at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
... 1 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
... 28 filtered
at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
... 24 filtered
at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
... 23 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2999)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1885)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1814)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1207)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2249)
... 164 more
```


Tags: mysql