我剛開始使用Hibernate而當我終於嘗試推出的網絡應用程序,我得到以下錯誤:無法連接到MySQL - 主機不允許
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"
這實在是令人沮喪的。爲什麼我不是本地主機?什麼是192.168.1.7?我可以授予像類似問題的答案一樣的權限,但爲什麼我不是本地主機?
我明白這裏的問題,hbm2ddl設置設置爲創建,所以它想創建給定的表,但沒有從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>
好了,其他屬性也設置爲正確的值? –
檢查上面的問題的編輯,我不認爲錯誤是在那裏,但請檢查出來! –