How to connect to the server BDD in Hibernate?

1

Good, my problem is that I need to connect to the database that I have on a server. The server I have from "Hostinger", it's free but for the capacity it gives it's only for a few things like a BDD.

The thing is that I'm programming with that bdd in eclipse (java language) and I'm using hibernate for views, code and so on. For now I'm doing well because I have the bdd in local but now that I upload it I want to connect to see if it goes.

I use this code for the connection in Hibernate:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">
    com.mysql.jdbc.Driver</property>

    <property name="hibernate.connection.password">
     root</property>                              //contraseña

    <property name="hibernate.connection.url">
     jdbc:mysql://localhost/comunidad</property>  //nombre bdd

    <property name="hibernate.connection.username">  //usuario
     root</property>

    <property name="hibernate.dialect">
    org.hibernate.dialect.MySQL5Dialect</property>

    <mapping class="es.sdos.bean.Paciente"/>
    <mapping class="es.sdos.bean.Usuario"/>
    <mapping class="es.sdos.bean.Actividad"/>
</session-factory>

There I am specifying the version of msql, usu, pass, name bdd, that data is from the local bdd.

Now these are the data that the bdd of the server gives me: It would look like this with that data:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">
    com.mysql.jdbc.Driver</property>

    <property name="hibernate.connection.password">
     u137181788_altair</property>             //cambie la contraseña(altair)

    <property name="hibernate.connection.url">
     jdbc:mysql://mysql.hostinger.es/u137181788_bdd</property>  //nombre bdd

    <property name="hibernate.connection.username">  //usuario
     u137181788_root</property>

    <property name="hibernate.dialect">
    org.hibernate.dialect.MySQL5Dialect</property>

    <mapping class="es.sdos.bean.Paciente"/>
    <mapping class="es.sdos.bean.Usuario"/>
    <mapping class="es.sdos.bean.Actividad"/>
</session-factory>

Just change the name of the bdd from "community" to "bdd" and the password from "root" to "altair". Try the code that is postponed and without the: "u137181788_" root

failures:

    
asked by KnightLight 14.06.2017 в 22:01
source

1 answer

1

The problem seems to be in the name of the host. The exception is telling you that you are not able to find mysql.hostinger.es .

In the support forum from Hostinger indicate that the databases have restricted external connections, they can only be accessed from a server in your domain. If you try to reach the host from a browser, or by ping, the connection fails, that domain is not registered in public DNS, probably only exists in your internal DNS.

If you are trying to access from your development environment, that is the problem. It should work if you have your application deployed on your servers.

    
answered by 15.06.2017 в 09:22