MySQL Could not create connection to database serve error

0 votes

I am trying to connect to MySQL server with Java. I am getting the following error:

Exception in component tDBInput_1 (job_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(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)

at com.mysql.jdbc.Util.getInstance(Util.java:384)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2588)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2321)

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:832)

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

I used the same Java code in a different machine, it worked. So I think there is no problem with the code.

Feb 7, 2019 in Database by Prateek
29,968 views

3 answers to this question.

0 votes

This error occurs when you are trying to connect to MySQL database but the MySQL service is not running/available. If you have not installed, first install MySQL server using this command:

$ sudo apt-get update
$ sudo apt-get install mysql-server

And then to start MySQL service, run any one of the following commands:

$ sudo service mysql start

or

$ sudo /etc/init.d/mysql start

And then run your code, it should work

answered Feb 7, 2019 by Omkar
• 69,220 points
Where should we execute this command?
Hi,

You need to execute in your server command line. Open the terminal and run the command.
0 votes

When I am trying to connect netbeans with MySQL then it's showing this error:

cannot establish a connection to jdbc MySQL. Could not create connection to database server. 

How to fix it.

answered Apr 14, 2019 by anonymous

edited Apr 15, 2019 by Kalgi

Is your MySQL database working fine? Check by executing the following command

mysqladmin -u root -p ping 
어디에 집어 넣어야하나요?

안녕하세요.

위의 쿼리를 실행하기 위해 MySQL 서버를 설치해야합니다

0 votes

Pls check that you have MySQL server running(if your running mysql command line client).

IF you are running Mysql command line client then delete it and download from: https://dev.mysql.com/downloads/windows/installer/8.0.html

Also watch this video and follow the steps: https://www.youtube.com/watch?v=u96rVINbAUI

I think mysql workbench and mysql server is needed mandatory!!!

It worked from me!!!

answered Jul 3, 2020 by anonymous

Related Questions In Database

0 votes
1 answer

ERROR 1006 (HY000): Can't create database 'test' (errno: 2) in mysql

Hi@akhtar, You have to change the permissions or ...READ MORE

answered Apr 14, 2020 in Database by MD
• 95,460 points
8,221 views
0 votes
1 answer

Error Code: 2020. Lost connection to MySQL server during query

Hello @kartik, I got the same issue when ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
2,717 views
0 votes
1 answer

How to connect to MySQL Database?

using MySql.Data; using MySql.Data.MySqlClient; namespace Data { ...READ MORE

answered Oct 12, 2018 in Database by Frankie
• 9,830 points
1,154 views
0 votes
1 answer

What are the steps performed by Migration Wizard while migrating a database to MySQL?

The following are the steps  performed by ...READ MORE

answered Dec 10, 2018 in Database by Sahiti
• 6,370 points
940 views
0 votes
1 answer

How to connect Java to MySql Database?

Make sure you have the MySQL jdbc ...READ MORE

answered Sep 30, 2019 in Java by Shyam
1,462 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,250 points
1,286 views
0 votes
1 answer

Find values in a comma separated string in a MySQL query

You can add commas to the left and ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,370 points
12,924 views
0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,370 points
2,332 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP