mybatis分页查询时ORA-00907: 缺失右括号

下一行code 2014-08-01 10:16:42
mybatis语句:

SELECT * FROM
(SELECT
id as id,
appserialnumber as appserialnumber,
who as who,
createtime as createtime,
operatedtype as operatedtype,
operate as operate,
operatedobject as operatedobject,
description as description,
result as result,
ROWNUM AS row_num
FROM server_log ROWNUM < (#{startRecord}+#{total})) t_temp
WHERE t_temp.row_num >= #{startRecord}


然后控制台打印语句:
10:06:51,114 DEBUG Connection:27 - ooo Connection Opened
10:06:51,442 DEBUG PreparedStatement:27 - ==> Executing: select count(*) from server_log
10:06:51,442 DEBUG PreparedStatement:27 - ==> Executing: select count(*) from server_log
10:06:51,442 DEBUG PreparedStatement:27 - ==> Parameters:
10:06:51,442 DEBUG PreparedStatement:27 - ==> Parameters:
10:06:51,630 DEBUG Connection:27 - ooo Connection Opened
10:06:51,646 DEBUG PreparedStatement:27 - ==> Executing: SELECT * FROM (SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log ROWNUM < (?+?)) t_temp WHERE t_temp.row_num >= ?
10:06:51,646 DEBUG PreparedStatement:27 - ==> Executing: SELECT * FROM (SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log ROWNUM < (?+?)) t_temp WHERE t_temp.row_num >= ?
10:06:51,646 DEBUG PreparedStatement:27 - ==> Parameters: 0(Integer), 10(Integer), 0(Integer)
10:06:51,646 DEBUG PreparedStatement:27 - ==> Parameters: 0(Integer), 10(Integer), 0(Integer)
2014-8-1 10:06:51 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet SearchServlet threw exception
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLException: ORA-00907: 缺失右括号

### The error may involve com.itrus.mylog.domain.ServerLog.selectAllServerLog-Inline
### The error occurred while setting parameters
### Cause: java.sql.SQLException: ORA-00907: 缺失右括号

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:69)
at com.itrus.mylog.dao.impl.SearchDAOImpl.searchPagination(SearchDAOImpl.java:37)
at com.itrus.mylog.service.impl.SearchServiceImpl.searchPagination(SearchServiceImpl.java:24)
at com.itrus.mylog.servlet.SearchServlet.search(SearchServlet.java:53)
at com.itrus.mylog.servlet.SearchServlet.service(SearchServlet.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: ORA-00907: 缺失右括号

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:796)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1116)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:45)
at $Proxy1.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:39)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:216)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:95)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:75)
... 18 more

求指点,是语句哪里写错了么?
...全文
659 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
下一行code 2014-08-01
  • 打赏
  • 举报
回复
引用 4 楼 u012463264 的回复:
(SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log where ROWNUM < (#{startRecord}+#{total}))
恩,原来你在下面又重新回复了一次,添加where就对了!!谢谢!
下一行code 2014-08-01
  • 打赏
  • 举报
回复
引用 6 楼 cbxjj 的回复:
1L and 改成where就行了
正解!!!!恩,就是这样,改为where就正确了!!谢谢!!
下一行code 2014-08-01
  • 打赏
  • 举报
回复
引用 1 楼 u012463264 的回复:
(SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log and ROWNUM < (#{startRecord}+#{total}))
照着你说的改了,但是还是报缺失右括号! 控制台输出: 10:26:42,536 DEBUG Connection:27 - ooo Connection Opened 10:26:42,853 DEBUG PreparedStatement:27 - ==> Executing: select count(*) from server_log 10:26:42,853 DEBUG PreparedStatement:27 - ==> Executing: select count(*) from server_log 10:26:42,854 DEBUG PreparedStatement:27 - ==> Parameters: 10:26:42,854 DEBUG PreparedStatement:27 - ==> Parameters: 10:26:43,050 DEBUG Connection:27 - ooo Connection Opened 10:26:43,060 DEBUG PreparedStatement:27 - ==> Executing: SELECT * FROM (SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log and ROWNUM < (?+?)) t_temp WHERE t_temp.row_num >= ? 10:26:43,060 DEBUG PreparedStatement:27 - ==> Executing: SELECT * FROM (SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log and ROWNUM < (?+?)) t_temp WHERE t_temp.row_num >= ? 10:26:43,061 DEBUG PreparedStatement:27 - ==> Parameters: 0(Integer), 10(Integer), 0(Integer) 10:26:43,061 DEBUG PreparedStatement:27 - ==> Parameters: 0(Integer), 10(Integer), 0(Integer) 2014-8-1 10:26:43 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet SearchServlet threw exception org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLException: ORA-00907: 缺失右括号
剑神一笑 2014-08-01
  • 打赏
  • 举报
回复
1L and 改成where就行了
小灯光环 2014-08-01
  • 打赏
  • 举报
回复
你的select子查询少个右括号,不是错误很明显吗。
别闹腰不好 2014-08-01
  • 打赏
  • 举报
回复
(SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log where ROWNUM < (#{startRecord}+#{total}))
shixitong 2014-08-01
  • 打赏
  • 举报
回复
FROM server_log ROWNUM < (#{startRecord}+#{total}) 这句是不是有问题? 少where?
剑神一笑 2014-08-01
  • 打赏
  • 举报
回复
不知道是不是(#{startRecord}+#{total}) 这里引起的 你试试sum(#{startRecord},#{total})测试下 或者把这句干掉试试 最好的是这个加法算法不要在xml里面做 , 后台加好再传进来
别闹腰不好 2014-08-01
  • 打赏
  • 举报
回复
(SELECT id as id, appserialnumber as appserialnumber, who as who, createtime as createtime, operatedtype as operatedtype, operate as operate, operatedobject as operatedobject, description as description, result as result, ROWNUM AS row_num FROM server_log and ROWNUM < (#{startRecord}+#{total}))

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧