我正在尝试从Java Web服务访问MySQL数据库。我正在使用NetBeans IDE,并且遵循教程 Using Hibernate in a Web Application
现在,当我尝试测试HQL查询时:来自我得到的电话:
org.hibernate.exception.SQLGrammarException: could not execute query
blablabla
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from limit 100' at line 1
bla, bla, bla
翻译的SQL也错了:
select from
我使用Hibernate Reverse Engineering创建了calls.java类。
这是Hibernate.cfg.xml
文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/datacheck</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.connection.password">####</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
</session-factory>
</hibernate-configuration>
我似乎无法找到错误,我搜索了整个互联网:p