I’m trying to connect PHPStorm to the database on the server of my website, hosted on a Linux box at BlueHost.
In order to do this, I clicked the Data Sources tab on the right side of the screen, the + icon, and then DB Data Source a Data Source Properties dialog popped up. I entered a name for the source, set Data Source Level to Project. Then downloaded the MySQL Connector/J-5.1.18 JDBC Driver Files. This filled the JDBC Driver Class with about 6-7 classes, including com.mysql.jdbc.Driver.
The problem I believe I’m having is at the Database URL. it’s asking for a jdbc:// url, which I’m not familiar with. I used the example format jdbc:mysql://[host][,failoverhost…][:port]/[database] and my username and password.
For host, I’ve tried localhost, and the name of the mysql server box###.bluehost.com. port 3306, and the name of the database was pretty straightforward.
I received this error when trying to test the connection…
Connection to Data Source failed
java.sql.SQLException: 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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2332)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
in RemoteDriverImpl.connect(RemoteDriverImpl.java:27)
in LocalDataSource.getConnection(LocalDataSource.java:105)
The major difference between this question and other questions here is that this is not to connect to a wamp or mamp stack, but a remote database.
BlueHost required that I add my IP Address range to the allowed access hosts list. I am on a shared hosting account, so BlueHost seems to allow remote connections on shared hosting accounts.
I did this by clicking “Remote MySQL” next to PHPMyAdmin in the cPanel for my hosting account. The cPanel automatically detected my IP range and suggested I add it. Once I did, everything else fell into place.
Thanks to LazyOne for pointing me in the right direction.