我尝试了这些教程,但我的应用程序没有工作: http://www.gwtproject.org/articles/using_gwt_with_hibernate.html
我使用GWT SDK 2.6.1 我从Hibernate下载了4.2.3版本
我想我在hibernate.cfg.xml文件中写了一切。这是cfg.xml文件中的前2个标记:
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost:3306</property>
我在eclipse中遇到这个错误(我不明白为什么我的jdbcDriver引起了ClassNotFoundException):
Caused by: java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:84)
... 55 more
编辑: 我还有项目的mysql-connector-java-5.1.29-bin.jar
答案 0 :(得分:0)
连接MySQL您的hibernate配置文件应具有以下属性:
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.url">jdbc:mysql://localhost/DB</property>
更新
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/feladatlapok</property>
<property name="connection.username">root</property>
<property name="connection.password"/>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="com/google/musicstore/domain/Record.hbm.xml"/>
<mapping resource="com/google/musicstore/domain/Account.hbm.xml"/>
<mapping resource="com/google/musicstore/domain/Elem.hbm.xml"/>
</session-factory>
</hibernate-configuration>