question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Failed to connect to mysql by jdbc

See original GitHub issue

Describe the question I used the cluster mode to deploy DS. When I execute bash script/create-dolphinscheduler.sh to init the database, errors came out:

wangmingzhi@xxx:~/apache-dolphinscheduler-1.3.6-bin2$ bash script/create-dolphinscheduler.sh     
 _ _   |_  _ _|_. ___ _ |    _ 
| | |\/|_)(_| | |_\  |_)||_|_\ 
     /               |         
                        3.2.0 
10:20:45.942 [main] INFO ru.yandex.clickhouse.ClickHouseDriver - Driver registered
10:20:46.106 [main] ERROR com.alibaba.druid.pool.DruidDataSource - init datasource error, url: jdbc:mysql://202.168.126.69:3306/dolphinscheduler?characterEncoding=UTF-8&allowMultiQueries=true
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the 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:425)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:342)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2197)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2230)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2025)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:778)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        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:425)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1578)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1644)
        at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:918)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1300)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1296)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:109)
        at org.apache.dolphinscheduler.dao.upgrade.UpgradeDao.getCurrentDbType(UpgradeDao.java:79)
        at org.apache.dolphinscheduler.dao.upgrade.UpgradeDao.<clinit>(UpgradeDao.java:48)
        at org.apache.dolphinscheduler.dao.upgrade.DolphinSchedulerManager.initUpgradeDao(DolphinSchedulerManager.java:37)
        at org.apache.dolphinscheduler.dao.upgrade.DolphinSchedulerManager.<init>(DolphinSchedulerManager.java:57)
        at org.apache.dolphinscheduler.dao.upgrade.shell.CreateDolphinScheduler.main(CreateDolphinScheduler.java:36)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:301)
        ... 23 common frames omitted

Now I deploy everything on the single machine to test cluster deployment. If everything is ok, then I will add more machines in. Mysql’s username and password is correct. I don’t know why this happened

Which version of DolphinScheduler: -[1.3.6-release]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wangmingzhiJohncommented, Jul 1, 2021

I changed the bind-address to 0.0.0.0 and it worked!

0reactions
tinykingcommented, Jul 1, 2021

I changed the bind-address to 0.0.0.0 and it worked!

@wangmingzhiJohn bind-address is mean only support it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fail to connect to mysql database using Java - Stack Overflow
I got an exception connecting to MySQL through Java. I downloaded the MySQL Java connector and added it to the classpath . I'm...
Read more >
Unable to connect to Mysql via JDBC but works fine with Mysql
Case 1 - JDBC connects as root@127.0.0.1 but privilege is not granted: ... It is possible that your mysql CLI is connecting via...
Read more >
Chapter 15 Troubleshooting Connector/J Applications
15.1: When I try to connect to the database with MySQL Connector/J, I get the following exception: SQLException: Server configuration denies access to...
Read more >
Unable to connect to mysql through JDBC connector through ...
I faced this problem when trying to connect through java to my mysql database which runs on another server in my LAN. when...
Read more >
error while connecting to MYSQL database using JDBC ...
Hi I m trying to connect MYSQL DB with JDBC adapter , i m getting the following error : Message processing failed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found