我刚刚开始使用Hibernate,当我最终尝试启动Web应用程序时,出现了以下错误:
2012-nov-14 12:54:23 org.hibernate.tool.hbm2ddl.SchemaExport execute
ERROR: HHH000231: Schema export unsuccessful
java.sql.SQLException: null, message from server: "Host '192.168.1.7' is not allowed to
connect to this MySQL server"
这真的很令人沮丧。为什么我不是localhost?192.168.1.7是什么?我可以像类似问题的答案建议的那样授予权限,但为什么我不是localhost?
我理解这里的问题,hbm2ddl设置被设置为create,因此它想要创建给定的表,但没有从MySQL服务器获取权限。
我正在Eclipse中开发一个struts2/hibernate应用程序,并且我使用Tomcat和当然MYSQL。
提前致谢!
编辑:(hibernate.cfg.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class"> com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/clothes</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.pool_size">1</property>
<property name="dialect"> org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<!-- Needs to be disabled in production! -->
<property name="hbm2ddl.auto">create</property>
<mapping class="johanstenberg.clothes.serverobjects.AdEntity"/>
<mapping class="johanstenberg.clothes.serverobjects.AuthenticationEntity"/>
<mapping class="johanstenberg.clothes.serverobjects.UserEntity"/>
<mapping class="johanstenberg.clothes.serverobjects.VerificationKeyEntity"/>
</session-factory>
</hibernate-configuration>
connection.url
告诉你客户端尝试通过哪个接口连接到MySQL服务器。 - Olaf Dietsche