Reputation: 67
I'm trying to connect my database to my project (in PhpStorm), so that I have autocomplete.
Steps that I do to get the error :
MySQL DataSource
TEST CONNECTION
buttonI've filled correctly every field (host, database, user, password) in the Database feature
s00vl9944624.fr.net.intra
animationqrc
animationqrc
jdbc:mysql://s00vl9944624.fr.net.intra:3306/animationqrc
The error is :
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection timed out: connect
The problem is that, when I use myself a Java class that only tries to connect to the server and print rows from a table, it works.
import java.sql.*;
class MysqlCon{
public static void main(String args[]){
try{
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://s00vl9944624.fr.net.intra:3306/pilconquete?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC","*user*","*pass*");
//here sonoo is the database name, root is the username and root is the password
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from Admin_list");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
"C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\jre64\bin\java" MysqlCon
Thu Sep 20 16:14:02 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
3 497764 Xavier *******
Even when I add PhpStorm default parameter (that you can see in the log below), except classpath.
"C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\jre64\bin\java" -Djava.net.preferIPv4Stack=true -Djava.rmi.server.hostname=127.0.0.1 -Duser.timezone=UTC -Dfile.encoding=UTF-8 MysqlCon
When I add the classpath parameter, Java doesn't find my class.
I'm using Win7 x64, PhpStorm 2018.2.3 (was also failing in 2017.3.3). I'm at work, so network restrictions might apply, firewall. And I don't have admin rights on my laptop.
Thanks for your help
EDIT:
From PhpStorm log :
2018-09-20 15:54:25,481 [ 81612] INFO - ution.rmi.RemoteProcessSupport - "C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\jre64\bin\java" -Djava.net.preferIPv4Stack=true -Djava.rmi.server.hostname=127.0.0.1 -Duser.timezone=UTC -Dfile.encoding=UTF-8 -classpath "C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\lib\util.jar;C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\lib\trove4j.jar;C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\lib\groovy-all-2.4.15.jar;C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\plugins\DatabaseTools\lib\jdbc-console.jar;C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\plugins\DatabaseTools\lib\dekaf-single-2.0.0.372.jar;C:\Users\b96297\.PhpStorm\config\jdbc-drivers\MySQL Connector\J\5.1.46\mysql-connector-java-5.1.46.jar;C:\Users\b96297\Downloads\mysql-connector-java-8.0.12.jar" com.intellij.database.remote.RemoteJdbcServer com.mysql.cj.jdbc.Driver
2018-09-20 15:54:25,701 [ 81832] WARN - ution.rmi.RemoteProcessSupport - Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2018-09-20 15:54:26,310 [ 82441] INFO - ution.rmi.RemoteProcessSupport - Port/ID: 30227/RemoteDriverImpl3260ec8e
2018-09-20 15:54:46,310 [ 102441] WARN - ution.rmi.RemoteProcessSupport - java.rmi.NotBoundException: _DEAD_HAND_
2018-09-20 15:54:46,310 [ 102441] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:209)
2018-09-20 15:54:46,310 [ 102441] WARN - ution.rmi.RemoteProcessSupport - at com.intellij.execution.rmi.RemoteServer.start(RemoteServer.java:96)
2018-09-20 15:54:46,310 [ 102441] WARN - ution.rmi.RemoteProcessSupport - at com.intellij.database.remote.RemoteJdbcServerBase.setupAndStart(RemoteJdbcServerBase.java:20)
2018-09-20 15:54:46,310 [ 102441] WARN - ution.rmi.RemoteProcessSupport - at com.intellij.database.remote.RemoteJdbcServer.main(RemoteJdbcServer.java:14)
2018-09-20 15:54:47,334 [ 103465] WARN - ution.rmi.RemoteProcessSupport - The cook failed to start due to java.net.ConnectException: Connection timed out: connect
2018-09-20 15:54:47,335 [ 103466] INFO - ution.rmi.RemoteProcessSupport - Process finished with exit code 1
2018-09-20 15:54:47,339 [ 103470] WARN - lij.database.util.ErrorHandler - java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection timed out: connect
java.lang.RuntimeException: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection timed out: connect
Upvotes: 2
Views: 2958
Reputation: 67
After discussing with @MarkRotteveel and Dmitry Tronin | Support Engineer at JetBrains, I've learned and discovered a few things:
Upvotes: 1
Reputation: 108962
To summarize my comments, it seems that PhpStorm uses separate Java processes to isolate database access from the rest of the application. It looks like communication between these two processes (using RMI, Remote Method Invocation) is not possible.
This is possibly a firewall issue. Given you're using Windows, check the Windows Firewall settings under allowed apps config for the OpenJDK Platform Binary for your PhpStorm install (see its details, path should be C:\Users\b96297\AppData\Local\JetBrains\PhpStorm 2018.2.3\jre64\bin\java
in your case), and enable Private access (in some cases, you may need to try Public as well). This will allow the Java processes to communicate using RMI.
If you can't find the OpenJDK Platform Binary in the firewall configuration, add the java.exe
from the jre64\bin
folder of the PhpStorm install and configure it.
Upvotes: 2