Skip to content
Advertisement

HTTP status 500 error, Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement

I keep getting SQLGrammarException error, I could not find any syntax error from my code. Here is my controller, entity, DAO and JSP file code. Maybe my form tag in addProduct.jsp is wrong, but I could not find the solution.

HomeController.java

JavaScript

ProductDAOImpl.java

JavaScript

Top.java

JavaScript

addProduct.jsp

JavaScript

Advertisement

Answer

Analysis

It looks like some names used in the database context (a table name, a column name, etc.) collide with the reserved words of the database server that you currently use.

Here is a related question: java – org.hibernate.exception.SQLGrammarException: could not execute statement – Stack Overflow.

Solution

Please, check the documentation for the reserved words of the database server.

Please, change the names that collide with the reserved words of the database server.

Draft examples

Microsoft SQL server

Reserved Keywords (Transact-SQL) – SQL Server | Microsoft Docs:

  • DESC.
  • TOP.

Therefore, it is required to rename the Top table and the desc column. For example:

JavaScript

MySQL 8.0

MySQL :: MySQL 8.0 Reference Manual :: 9.3 Keywords and Reserved Words:

  • DESC.

Therefore, it is required to rename the desc column. For example:

JavaScript
Advertisement