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
11,478 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,030 points
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 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 in Database by MD
• 57,300 points
739 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 in Database by Niroj
• 59,360 points
609 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,810 points
270 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,320 points
161 views
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

At first, put the dataset in the ...READ MORE

answered Jul 5, 2019 in Database by Reshma
426 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
273 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,210 points
130 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,320 points
7,353 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,320 points
1,047 views
0 votes
2 answers