views:

1918

answers:

3

I'm trying to connect to a remote database (hosted on Netfirms www.netfirms.ca if anyone is curious) using hibernate. My mapping file is as follows:

<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 start 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 ensured that my database is configured to allow remote access. I'm wondering what causes this. Obviously, I'm unable to establish a connection with the host, but I'm not sure why. Assuming the host name, user, and password are correct, am I missing something?

Addendum: I tried connecting using the same driver with Squirrel, and got the same exact error.

A: 

I guess the first step will be to check (since you didn't say that you already tried), if you can connect to the database using some SQL tool. Like SQuirrel for example.

Strelok
I get the same error when trying to connect using Squirrel.
Elie
So, what does it mean?
Adeel Ansari
that's my question
Elie
A: 

The Exception says, that there is no route to the host. That means you most likely can not even ping your db server.

reading http://support.netfirms.com/article.php?id=694 you should put another host in your jdbc url

jdbc:mysql://mysql.netfirms.com:3306/d60549476

squiddle
actually, I tried it with both. Under the admin panel, it says to use .ca. If you look at the history on the question, you'll see the original error when I used .com. If I use .ca, I get the current error.
Elie
+1  A: 

It turns out that there were several issues with the connection:

  1. Although the site said to use mysql.netfirms.ca on the Control Panel, their generic instructions were correct and I was supposed to use mysql.netfirms.com as someone else mentioned earlier.
  2. Netfirms was having some issues with their site, and apparently I was the only one to notice, that connections from remote machines was not available. They sent an apology earlier, and now I can connect just fine.

Thanks to everyone for your help.

Elie
Glad, its working now.
Adeel Ansari