2011-03-22 4 views
1

J'ai commencé à apprendre à hiberner. Voici mon fichier hibernate-configuration:Hibernate: MySql vs '' utilisateur

<hibernate-configuration> 
<session-factory> 

    <!-- connection settings --> 
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="connection.url">jdbc:mysql://localhost:3306/hibernatelearning</property> 
    <property name="connection.name">root</property> 
    <property name="connection.password"></property> 


    <!-- JDBC connection pool --> 
    <property name="connection.pool_size">1</property> 

    <!-- dialect --> 
    <property name="dialect">org.hibernate.dialect.HSQLDialect</property> 

    <property name="show_sql">true</property> 

    <property name="current_session_context_class">thread</property> 


    <mapping resource="./Event.hbm.xml"/> 

</session-factory> 
</hibernate-configuration> 

L'exception est:

 
INFO: connection properties: {name=root, password=****} 
22.03.2011 15:45:14 org.hibernate.cfg.SettingsFactory buildSettings 
WARNING: Could not obtain connection to query metadata 
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database 'hibernatelearning' 

Est-ce que quelqu'un sait comment faire face?

Répondre

1

Le problème était dans hibernate.cfg.xml. La bonne:

<session-factory> 

    <!-- connection settings --> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernatelearning</property> 
    <property name="hibernate.connection.username">root</property> 
    <property name="hibernate.connection.password"></property> 
    <property name="hibernate.hbm2ddl.auto">create-drop</property> 


    <!-- JDBC connection pool --> 
    <property name="connection.pool_size">1</property> 

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

    <property name="show_sql">true</property> 

    <property name="current_session_context_class">thread</property> 


    <mapping resource="./Event.hbm.xml"/> 

</session-factory>