• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How To Solved : "org.hibernate.exception.SQLGrammarException: could not execute query"

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Guys,
I'm making Native SQL in Hibernate, but I have some problem when I'm trying to execute my SQL. Here is my SQL:


and the error is:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

org.hibernate.exception.SQLGrammarException: could not execute query



I'm trying to solved them, but it still not working.

Thanks in advance.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Irliyanti Rahmadhani Lubis,

First of all, a warm welcome to CodeRanch!

Irliyanti Rahmadhani Lubis wrote:org.hibernate.exception.SQLGrammarException: could not execute query

I'm trying to solved them, but it still not working.


What happens when you execute that query directly on the database using a SQL Client program like Squirrel or the client which comes with your database?

Kind regards,
Roel
 
Irliyanti Rahmadhani Lubis
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roel De Nijs wrote:Hi Irliyanti Rahmadhani Lubis,

First of all, a warm welcome to CodeRanch!

Irliyanti Rahmadhani Lubis wrote:org.hibernate.exception.SQLGrammarException: could not execute query

I'm trying to solved them, but it still not working.


What happens when you execute that query directly on the database using a SQL Client program like Squirrel or the client which comes with your database?

Kind regards,
Roel




Thank you for the answer, Roel.
I change my SQL to :


and the SQL is success when I try in TOAD for Oracle. But, when I try to implementation in Java, there's no effect. I don't know where the problem
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm definitely not a Hibernate expert, and certainly not when it comes down to writing native queries But I think a good starting point would be the native SQL Queries chapter from Hibernate. And I would start with a very easy query (e.g. select just one field from a table). Once you' ve got this working, you can add more complexities. If it fails at a certain point, you know immediately what's causing the error and it will be easier to look for a solution and fix your issue.

Just my two cents.
 
Irliyanti Rahmadhani Lubis
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roel De Nijs wrote:I'm definitely not a Hibernate expert, and certainly not when it comes down to writing native queries But I think a good starting point would be the native SQL Queries chapter from Hibernate. And I would start with a very easy query (e.g. select just one field from a table). Once you' ve got this working, you can add more complexities. If it fails at a certain point, you know immediately what's causing the error and it will be easier to look for a solution and fix your issue.

Just my two cents.



Thank you, Roel, for your reference.
I'm the beginner in Java and Hibernate so I don't khow how to solved that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic