org.hibernate.exception.SQLGrammarException
出现这个错误的原因 很可能是 数据库表名或者字段名 与mysql数据库的关键字或保留字重名,常见的关键字或保留字 有如下一些:
ADD
|
ALL
|
ALTER
|
ANALYZE
|
AND
|
AS
|
ASC
|
ASENSITIVE
|
BEFORE
|
BETWEEN
|
BIGINT
|
BINARY
|
BLOB
|
BOTH
|
BY
|
CALL
|
CASCADE
|
CASE
|
CHANGE
|
CHAR
|
CHARACTER
|
CHECK
|
COLLATE
|
COLUMN
|
CONDITION
|
CONNECTION
|
CONSTRAINT
|
CONTINUE
|
CONVERT
|
CREATE
|
CROSS
|
CURRENT_DATE
|
CURRENT_TIME
|
CURRENT_TIMESTAMP
|
CURRENT_USER
|
CURSOR
|
DATABASE
|
DATABASES
|
DAY_HOUR
|
DAY_MICROSECOND
|
DAY_MINUTE
|
DAY_SECOND
|
DEC
|
DECIMAL
|
DECLARE
|
DEFAULT
|
DELAYED
|
DELETE
|
DESC
|
DESCRIBE
|
DETERMINISTIC
|
DISTINCT
|
DISTINCTROW
|
DIV
|
DOUBLE
|
DROP
|
DUAL
|
EACH
|
ELSE
|
ELSEIF
|
ENCLOSED
|
ESCAPED
|
EXISTS
|
EXIT
|
EXPLAIN
|
FALSE
|
FETCH
|
FLOAT
|
FLOAT4
|
FLOAT8
|
FOR
|
FORCE
|
FOREIGN
|
FROM
|
FULLTEXT
|
GOTO
|
GRANT
|
GROUP
|
HAVING
|
HIGH_PRIORITY
|
HOUR_MICROSECOND
|
HOUR_MINUTE
|
HOUR_SECOND
|
IF
|
IGNORE
|
IN
|
INDEX
|
INFILE
|
INNER
|
INOUT
|
INSENSITIVE
|
INSERT
|
INT
|
INT1
|
INT2
|
INT3
|
INT4
|
INT8
|
INTEGER
|
INTERVAL
|
INTO
|
IS
|
ITERATE
|
JOIN
|
KEY
|
KEYS
|
KILL
|
LABEL
|
LEADING
|
LEAVE
|
LEFT
|
LIKE
|
LIMIT
|
LINEAR
|
LINES
|
LOAD
|
LOCALTIME
|
LOCALTIMESTAMP
|
LOCK
|
LONG
|
LONGBLOB
|
LONGTEXT
|
LOOP
|
LOW_PRIORITY
|
MATCH
|
MEDIUMBLOB
|
MEDIUMINT
|
MEDIUMTEXT
|
MIDDLEINT
|
MINUTE_MICROSECOND
|
MINUTE_SECOND
|
MOD
|
MODIFIES
|
NATURAL
|
NOT
|
NO_WRITE_TO_BINLOG
|
NULL
|
NUMERIC
|
ON
|
OPTIMIZE
|
OPTION
|
OPTIONALLY
|
OR
|
ORDER
|
OUT
|
OUTER
|
OUTFILE
|
PRECISION
|
PRIMARY
|
PROCEDURE
|
PURGE
|
RAID0
|
RANGE
|
READ
|
READS
|
REAL
|
REFERENCES
|
REGEXP
|
RELEASE
|
RENAME
|
REPEAT
|
REPLACE
|
REQUIRE
|
RESTRICT
|
RETURN
|
REVOKE
|
RIGHT
|
RLIKE
|
SCHEMA
|
SCHEMAS
|
SECOND_MICROSECOND
|
SELECT
|
SENSITIVE
|
SEPARATOR
|
SET
|
SHOW
|
SMALLINT
|
SPATIAL
|
SPECIFIC
|
SQL
|
SQLEXCEPTION
|
SQLSTATE
|
SQLWARNING
|
SQL_BIG_RESULT
|
SQL_CALC_FOUND_ROWS
|
SQL_SMALL_RESULT
|
SSL
|
STARTING
|
STRAIGHT_JOIN
|
TABLE
|
TERMINATED
|
THEN
|
TINYBLOB
|
TINYINT
|
TINYTEXT
|
TO
|
TRAILING
|
TRIGGER
|
TRUE
|
UNDO
|
UNION
|
UNIQUE
|
UNLOCK
|
UNSIGNED
|
UPDATE
|
USAGE
|
USE
|
USING
|
UTC_DATE
|
UTC_TIME
|
UTC_TIMESTAMP
|
VALUES
|
VARBINARY
|
VARCHAR
|
VARCHARACTER
|
VARYING
|
WHEN
|
WHERE
|
WHILE
|
WITH
|
WRITE
|
X509
|
XOR
|
YEAR_MONTH
|
ZEROFILL
|
MySQL允许部分关键字用做未引起来的识别符,因为许多人以前曾使用过它们。下面列出了一些例子:
ACTION
BIT
DATE
ENUM
NO
TEXT
TIME
TIMESTAMP
以后在数据库的设计中一定要注意字段名别用关键字和保留字,否则在这样的问题上面浪费时间就太得不偿失了。
分享到:
相关推荐
警告: SQL Error: 156, ...org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.util.JDBCExceptionReporter logExceptions 严重: 关键字 'user' 附近有语法错误。 的解决方案。
**问题描述**:执行Hibernate操作时,如插入数据,遇到`org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update`异常。 **原因分析**:这通常是由于数据库表不存在或表结构不匹配引起...
nested exception is org.hibernate.exception.SQLGrammarException: could not execute query 这个错误是由于SQL语句有错误,导致查询失败。解决方法是检查SQL语句的正确性,确保语句正确无误。 4. 严重: Error ...
3. **Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update** Hibernate在执行数据库批处理更新时出现SQL语法错误,可能是由于数据库表不存在或结构不符...
nested exception is org.hibernate.exception.SQLGrammarException: could not execute query` 这个异常表明执行SQL查询时出现了语法错误。检查并修正相关的SQL语句,确保其符合SQL语法规范,并且与数据库表结构...
nested exception is org.hibernate.exception.SQLGrammarException: could not execute query ``` **问题描述:** 这通常是因为Hibernate执行SQL查询时遇到了语法错误或者数据表结构不匹配等问题。 **解决方法:...
### 错误四:`org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update` **错误现象**: 在执行数据库批量操作时,Hibernate抛出`SQLGrammarException`,表明SQL语法错误或数据库不支持...
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update 或者org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not insert: ...
### 错误二:org.hibernate.exception.SQLGrammarException: could not get next sequence value 此错误与Hibernate框架相关,当尝试获取数据库中的下一个序列值时出现语法错误。这通常是因为配置不当或数据库查询...
在这个场景中,异常的根因是嵌套的“org.hibernate.exception.SQLGrammarException: could not execute query”,这是Hibernate在处理SQL语句时抛出的异常,通常与SQL语法错误或表结构不匹配有关。当从SQL Server...