2011-03-22 2 views
1

최대 절전 모드를 배우기 시작했습니다.최대 절전 모드 : MySql vs '사용자

<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> 

예외는 다음과 같습니다 :

 
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' 

사람이 그것을 처리하는 방법을 알고 있나요 여기 내 최대 절전 모드 구성 파일은?

답변

1

문제는 hibernate.cfg.xml에있었습니다. 올바른 것 :

<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>