Remote database connection problem using hibernate
I am trying to connect to a remote database (hosted on Netfirms www.netfirms.ca if anyone is interested) using hibernate. My mapping file looks like this:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://mysql.netfirms.ca:3306/d60549476</property>
<property name="hibernate.connection.username">u70612250</property>
<property name="hibernate.connection.password">******</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!-- List of XML mapping files -->
<mapping resource="customer.hbm.xml"/>
<mapping resource="customerSummary.hbm.xml"/>
<mapping resource="charity.hbm.xml"/>
<mapping resource="charitySummary.hbm.xml"/>
</session-factory>
</hibernate-configuration>
When I run my application, I get the following printout:
16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
....
94 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
....
485 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
532 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
532 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
547 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
547 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://mysql.netfirms.ca:3306/d60549476
547 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=u70612250, password=****}
168719 [main] WARN org.hibernate.cfg.SettingsFactory - Could not obtain connection metadata
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.NoRouteToHostException
MESSAGE: No route to host: connect
STACKTRACE:
java.net.NoRouteToHostException: No route to host: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
I have ensured that my database is configured for remote access. I'm wondering what the reason is. Obviously, I cannot establish a connection to the host, but I'm not sure why. Assuming the hostname, username and password are correct, am I missing something?
Appendix: I tried to connect using the same driver using Squirrel and got the same exact error.
source to share
It turned out that there were several problems with the connection:
- Although the site said to use mysql.netfirms.ca in the control panel, their general instructions were correct and I had to use mysql.netfirms.com like someone mentioned earlier.
- Netfirms had some problems with their site and apparently I was the only one who noticed that connections to remote machines were not available. They sent an apology earlier and now I can connect normally.
Thanks everyone for your help.
source to share
The Exception says there is no host path. This means that you most likely won't even be able to ping your db server.
reading http://support.netfirms.com/article.php?id=694 you have to put another host in your jdbc url
Jdbc: mysql: // mysql.netfirms com : 3306 / d60549476
source to share