This question already has answers here:
Solving a "communications link failure" with JDBC and MySQL [duplicate]
(25 answers)
Closed 4 years ago.
I have mysql database running on server that i access using <ip>/phpmyadmin.
I want to create data source in intelij and i am trying to connect there.
Host: <ip>/phpmyadmin
Database: <database_name>
User:root
password: *****
Url: jdbc:mysql://<ip>/phpmyadmin:3306/<database_name>
However using this i recieve error from intelij:
> Connection to jdbc:mysql://<ip>/phpmyadmin:3306/<database_name>
> failed. [08S01] 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.
Why is this happening? Going to <ip>/phpmyadmin in broswer nicely delegates me to phpmyadmin, so why is intelij complaining? The url should be correct, the mysql database is running on port 3306 on server.
How can i fix this?
thanks for help!
Remove phpadmin path from your host and try to connect again. If it doesn't work, check on which port MySQL is running by
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
Related
This question already has answers here:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
(51 answers)
Closed 3 years ago.
I was trying to access my java web app , which i have containerised with docker containers and i also have containerised my mysql database in a different container , both container are running on the default docker network , and i also tried to ping those containers from each other and i got positive results from it , but when i try to access it on my localhost (as i have mapped the ports of the tomcat server to the host ) machine it shows
Error
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.
I have read a little bit about this error , its related to some sort of connectivity issue with database but through pingcommand , i checked the connection.
What could be the reason of this error?
1) If it is bound to 127.0.0.1 and you can't connect using "localhost", make sure it's not resolving to the IPv6 localhost address instead of IPv4. (or just use the IP address)
2) Check the port that MySQL is listening on (Default 3306).
3) Make sure you're using the right JDBC connector for your JDK.
Check this below code in your application.yml or application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/<<DB_NAME>>
spring.datasource.username=root (In my case)
This question already has answers here:
JDBC connection failed, error: TCP/IP connection to host failed
(9 answers)
Closed 5 years ago.
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:191)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:242)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2369)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:551)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1963)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459)
I'm facing this exception after I tried to connect with my driver through the new database profile.
The information I have was correct and the TCP port was enabled and the firewall was turned off.
I'm using Microsoft SQL server 2008 JDBC driver and I've added the jars.
A "connection refused" is rarely caused by the connecting client, i.e. the JDBC client within your Eclipse setup. A good check is to open a shell (e.g. cmd.exe on Windows) and do a
telnet [server name used in JDBC configuration] 1433
On newer Windows installations you need to install the telnet client because it's not part of the standard installation anymore (Settings -> Software -> Add/Remove Features).
If that leads to a similar error message you can focus your trouble shooting to the network part of your system, since the JDBC side is completely uninvolved. If you can connect, make sure that the server name resolves to the same IP when using the command prompt as it's resolved within Java (I once had this effect which took quite a time to find that out). Especially with localhost as server name one might resolve to 127.0.0.1 while the other resolvs to ::1.
This question already has answers here:
Connect Java to a MySQL database
(14 answers)
Closed 7 years ago.
I recently set up an OpenShift project with the MySQL 5.5 cartridge.
Now I'm trying to reach this server. The DB name is 'wensput'.
The URL I'm trying to reach the MySQL is:
DB_URL = "jdbc:mysql://77.78.110.71:3306/Wensput";
AND
DB_URL = "jdbc:mysql://IP/wensput";
WHERE IP = the IP my machine uses to connect to phpAdmin, also the 'Server' (something like: 127.9.203.293:3306
I tried them both with capatilazing and such but nothing seems to work.
Now was my question, do I have the url right?
Or do I need to use like, the rhcloud.com/phpmyadmin url? What am I doing wrong?
EDIT: ****
I first get a java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception, but: there are no complains about 'CLASSPATH' whatsoever.
Looks like you don't have the JDBC driver installed or are not importing it correctly. Take a look at this tutorial for detailed instructions:
Connect Java to a MySQL database
This question already has answers here:
Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server
(29 answers)
Closed 9 years ago.
Using JDBC, I am currently trying to connect to a server hosted on the same network using MAMP.
Using this string: private static final String DB_CONNECTION = "jdbc:mysql://192.168.169.101:8889/";
I received this error: message from server: "Host '192.168.169.98' is not allowed to connect to this MySQL server"
I am wondering if this is a firewall error?
Comment out 'skip-networking' in your my.cnf file.
If skip-networking is commented out, then it's a user level permission which needs to be set in the mysql.user or mysql.database tables.
MySQL wants you to GRANT permission for users to connect to the server by IP address and credentials. I think it's a good idea to set up credentials for that particular database and user and GRANT only the permissions necessary to accomplish the task.
Don't use the root admin credentials for anything except administration.
http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
This question already has answers here:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
(51 answers)
Closed 6 years ago.
I Have developed an application to capture data, retrieve information,delete and also update info. The application is developed in java swing and hibernate and uses MySQL version 5.5 as a database. I tested it on my local server or local host and its working fine. So now i took it a step further trying to access the database on the remote server. Please note that also the MySQL version i use on my local server is the same as the MySQL in the remote server.
I get the following error:
Internal Exception: 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.
Error Code: 0
The problem is that your MySqlConnector/Driver can't establish a Connection to the remote server.
Check your jdbc URL and also the check if the wrong ports are used.
Maybe the Mysql DB is not reachable from outside, than you can use a port forwarding with ssh, for example :
port forwarding:
ssh -L3306:127.0.0.1:3306 user#remoteServer
than change your jdbc url to:
jdbc:mysql://localhost:3306/database
Explanation:
-L port:host:hostport
Specifies that the given port on the local (client) host is to be
forwarded to the given host and port on the remote side.
...
Whenever a
connection is made to this port, the connection is forwarded over
the secure channel, and a connection is made to host port
hostport from the remote machine.
Source: http://www.openbsd.org/cgi-bin/man.cgi?query=ssh&sektion=1
That means you request with your MySQL JDBC Driver(jdbc url) on the local 3306 port
will be forwarded to the remote server on his local 3306 port,
where the Mysql Database is listing.