Reputation: 1178
I'm trying to access a MySQL database from a Java webservice. I'm using the NetBeans IDE and am following the tutorial Using Hibernate in a Web Application
Now when I try to test the HQL query: from calls I get:
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
And the translated SQL is also wrong:
select from
I created the calls.java class using Hibernate Reverse Engineering.
This is the Hibernate.cfg.xml
file:
<?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>
I can't seem to find the error, and I searched the whole Internet :p
A similar thread is HQL Editor not appending table name in query.
Upvotes: 0
Views: 1798