Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'user' 附近有语法错误

原因:user是T-SQL语句中的关键字(详细见下面的扩展表)
Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'user' 附近有语法错误_第1张图片
解决办法:给user加上中括号[ ],即[user]。编译成功!
Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'user' 附近有语法错误_第2张图片
但发果不经意用到一些关键字,尤其是像user、 work 等等,所以在碰到上面的 错误提示信息后,就要联想到这些,不妨试着添加 [ ],问题就迎刃而解了。
如果担心出现这类问题 可以提前将需查询的所有表名都添加 [ ]。

下面这此词都是T-SQL语句中的关键字,在写SQL语句,存储过程,触发器或字段命名等时要避免使用这些词。

ADD EXIT PRIMARY
ALL FETCH PRINT
ALTER FILE PRIVILEGES
AND FILLFACTOR PROC
ANY FLOPPY PROCEDURE
AS FOR PROCESSEXIT
ASC FOREIGN PUBLIC
AUTHORIZATION FREETEXT RAISERROR
AVG FREETEXTTABLE READ
BACKUP FROM READTEXT
BEGIN FULL RECONFIGURE
BETWEEN GOTO REFERENCES
BREAK GRANT REPEATABLE
BROWSE GROUP REPLICATION
BULK HAVING RESTORE
BY HOLDLOCK RESTRICT
CASCADE IDENTITY RETURN
CASE IDENTITY_INSERT REVOKE
CHECK IDENTITYCOL RIGHT
CHECKPOINT IF ROLLBACK
CLOSE IN ROWCOUNT
CLUSTERED INDEX ROWGUIDCOL
COALESCE INNER RULE
COLUMN INSERT SAVE
COMMIT INTERSECT SCHEMA
COMMITTED INTO SELECT
COMPUTE IS SERIALIZABLE
CONFIRM ISOLATION SESSION_USER
CONSTRAINT JOIN SET
CONTAINS KEY SETUSER
CONTAINSTABLE KILL SHUTDOWN
CONTINUE LEFT SOME
CONTROLROW LEVEL STATISTICS
CONVERT LIKE SUM
COUNT LINENO SYSTEM_USER
CREATE LOAD TABLE
CROSS MAX TAPE
CURRENT MIN TEMP
CURRENT_DATE MIRROREXIT TEMPORARY
CURRENT_TIME NATIONAL TEXTSIZE
CURRENT_TIMESTAMP NOCHECK THEN
CURRENT_USER NONCLUSTERED TO
CURSOR NOT TOP
DATABASE NULL TRAN
DBCC NULLIF TRANSACTION
DEALLOCATE OF TRIGGER
DECLARE OFF TRUNCATE
DEFAULT OFFSETS TSEQUAL
DELETE ON UNCOMMITTED
DENY ONCE UNION
DESC ONLY UNIQUE
DISK OPEN UPDATE
DISTINCT OPENDATASOURCE UPDATETEXT
DISTRIBUTED OPENQUERY USE
DOUBLE OPENROWSET USER
DROP OPTION VALUES
DUMMY OR VARYING
DUMP ORDER VIEW
ELSE OUTER WAITFOR
END OVER WHEN
ERRLVL PERCENT WHERE
ERROREXIT PERM WHILE
ESCAPE PERMANENT WITH
EXCEPT PIPE WORK
EXEC PLAN WRITETEXT
EXECUTE PRECISION
EXISTS PREPARE

你可能感兴趣的:(MyBatis)