This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Irliyanti Rahmadhani Lubis
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic