gpt4 book ai didi

sql-server - Grails SQLServerException Microsoft数据库 'limit'附近的语法不正确

转载 作者:行者123 更新时间:2023-12-02 14:49:50 29 4
gpt4 key购买 nike

我正在Grails 3.1.1项目中使用Microsoft数据库,现在我仅使用脚手架来管理数据。每当我尝试呈现 Controller 的索引页时,我都会遇到错误Incorrect syntax near 'limit'.
这是完整的错误日志:

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not extract ResultSet; uncategorized SQLException for SQL [n/a]; SQL state [S0001]; error code [102]; Incorrect syntax near 'limit'.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'limit'.
at inkinventory.IsInkInventoryController.index(IsInkInventoryController.groovy:13) ~[main/:na]
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.1.jar:3.1.1]
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93) ~[grails-core-3.1.1.jar:3.1.1]
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.groovy:53) ~[spring-security-core-3.0.3.jar:na]
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62) ~[spring-security-core-3.0.3.jar:na]
at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.groovy:58) ~[spring-security-core-3.0.3.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_73]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_73]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_73]
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'limit'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155) ~[sqljdbc-4.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:285) ~[sqljdbc-4.jar:na]
at grails.orm.PagedResultList.<init>(PagedResultList.java:43) ~[grails-datastore-gorm-hibernate4-5.0.1.RELEASE.jar:na]
... 9 common frames omitted

它所指向的代码行就是错误:
def index(Integer max) {
params.max = Math.min(max ?: 10, 100)
respond IsInkInventory.list(params), model:[isInkInventoryCount: IsInkInventory.count()]
}

这是通过数据库配置:
dataSources:
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
sqlDB:
pooled: true
jmxExport: true
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
username: {un}
password: {pw}

最佳答案

我删除了h2数据库连接,这似乎已解决了该问题。我认为由于两个数据连接之间的两种语法不同,因此不确定如何生成查询

关于sql-server - Grails SQLServerException Microsoft数据库 'limit'附近的语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35920047/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com