0

I want to connect a project in Java with hibernate and mySQL databases. I rent a server to Ovh (kimsufi configure on ubuntu server and i configure mysql);

I can connect to phpmyadmin from distant computer 39...*/phpmyadmin , create databases tables ect...

But with hibernate I can't and I don't know why.

When i launch the application it raise an error :

WARN: SQL Error: 1130, SQLState: HY000 3 déc. 2013 13:09:45 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: null, message from server: "Host 'ALyon-654-1-427-15.w109-212.abo.wanadoo.fr' is not allowed to connect to this MySQL server" Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not open connection

Here is my hibernate cfg file :

<!-- <?xml version="1.0" encoding="UTF-8"?> -->
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >

<hibernate-configuration>  
<session-factory>  
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>  
    <property name="hibernate.connection.username">athos</property>  
    <property name="hibernate.connection.password">*******</property>  
    <property name="hibernate.connection.url">jdbc:mysql://37.*.*.*:3306</property>  
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>  
    <property name="show_sql">true</property>   
    <property name="connection.pool_size">1</property>  

    <mapping class="fr.javatp.model.Client"></mapping>  

</session-factory>  
</hibernate-configuration>  
3
  • Seems that the mysql database is configured to get access from localhost only. Commented Dec 3, 2013 at 12:21
  • Have you already checked connection configuration and user priveledges? Commented Dec 3, 2013 at 12:21
  • You need to add database name as well in the connection string:<property name="hibernate.connection.url">jdbc:mysql://37.*.*.*:3306/databasename</property> Commented Dec 3, 2013 at 12:22

2 Answers 2

1

The computer you're using to connect to the kimsufi server isn't allowed to connect as user athos to the mysql database. A detailed writeup can be found here. Essentially, you grant the appropriate rights with a GRANT command:

GRANT ALL ON yourdb.* TO athos@'1.2.3.4' IDENTIFIED BY 'my_password';

But that won't work with dynamic residential connections of course.

Alternatively, you could forward the traffic through an ssh tunnel between your machine and the kimsufi server, or even set up an OpenVPN server on the kimsufi server.

In my opinion, both these options are security-wise a LOT better than eg setting up phpMyAdmin.

Last but not least, add the database name to the JDBC URL:

jdbc:mysql://37.*.*.*:3306/yourdbnameshouldgohere
Sign up to request clarification or add additional context in comments.

Comments

0

The error message is pretty clear

"Host 'ALyon-654-1-427-15.w109-212.abo.wanadoo.fr' is not allowed to connect to this MySQL server".

It means that your host is not allowed to connect to the remote SQL database. You need to allow your host to do remote connection via phpMyadmin (if it is possible with OVH. I'n not sure about that!)

http://supportcenter.verio.com/KB/questions.php?questionid=494

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.