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 in Database by Prateek
2,533 views

2 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 by Omkar
• 67,660 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 by anonymous

edited Apr 15 by Kalgi

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

mysqladmin -u root -p ping 

Related Questions In Database

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
107 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 darklord
• 6,170 points
98 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 in Database by Reshma
80 views
0 votes
1 answer

How to connect to MySQL Database?

Firstly you must download the MySQLConnection NET ...READ MORE

answered Oct 11 in Database by Omaiz
• 560 points
36 views
0 votes
1 answer

Accessing connection from different class in Java / MySQL?

You should just instantiate DoComms with every ...READ MORE

answered Nov 14, 2018 in Database by nirvana
• 3,060 points
44 views
0 votes
1 answer

How to connect Java to MySql Database?

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

answered Sep 30 in Java by Shyam
79 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,130 points
58 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 darklord
• 6,170 points
2,649 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 darklord
• 6,170 points
368 views
0 votes
2 answers