Mybatis——oracle——sql语句结尾不加;

Posted zhangziyangdeboke

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mybatis——oracle——sql语句结尾不加;相关的知识,希望对你有一定的参考价值。

HTTPステータス 500 - Internal Server Error


Type Exception Report

メッセージ Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:

説明 The server encountered an unexpected condition that prevented it from fulfilling the request.

例外

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

### The error may exist in mybatis/login/comment.xml
### The error may involve com.ssm.backstage.backmanage_login.dao.CommentDao.select_comment-Inline
### The error occurred while setting parameters
### SQL: SELECT * FROM COMMENT_TABLE    WHERE 1=1     ORDER BY TO_NUMBER(COMMENT_ID) DESC;
### Cause: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

原因

org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

### The error may exist in mybatis/login/comment.xml
### The error may involve com.ssm.backstage.backmanage_login.dao.CommentDao.select_comment-Inline
### The error occurred while setting parameters
### SQL: SELECT * FROM COMMENT_TABLE    WHERE 1=1     ORDER BY TO_NUMBER(COMMENT_ID) DESC;
### Cause: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

    org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:91)
    org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:74)
    org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399)
    com.sun.proxy.$Proxy17.selectList(Unknown Source)
    org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:205)
    org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
    org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
    org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
    com.sun.proxy.$Proxy18.select_comment(Unknown Source)
    com.ssm.backstage.backmanage_login.service.CommentService.select_comment(CommentService.java:34)
    com.ssm.backstage.backmanage_login.handler.CommentHandler.select_comment(CommentHandler.java:43)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:111)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:806)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:729)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

原因

java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

    oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
    oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
    oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
    oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
    oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
    oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
    oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
    oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
    oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
    oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3488)
    oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
    com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931)
    com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
    com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
    com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:118)
    com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
    org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:62)
    org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
    org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
    org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
    org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
    org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
    org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
    com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:351)
    com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:329)
    com.github.pagehelper.PageHelper.intercept(PageHelper.java:150)
    org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
    com.sun.proxy.$Proxy39.query(Unknown Source)
    org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
    org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)
    com.sun.proxy.$Proxy17.selectList(Unknown Source)
    org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:205)
    org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
    org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
    org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
    com.sun.proxy.$Proxy18.select_comment(Unknown Source)
    com.ssm.backstage.backmanage_login.service.CommentService.select_comment(CommentService.java:34)
    com.ssm.backstage.backmanage_login.handler.CommentHandler.select_comment(CommentHandler.java:43)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:111)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:806)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:729)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

注意 原因のすべてのスタックトレースは、のログに記録されています


Apache Tomcat/8.5.39

以上是关于Mybatis——oracle——sql语句结尾不加;的主要内容,如果未能解决你的问题,请参考以下文章

mybatis中mapper.xml分页查询oracle的sql语句,按字段查询

Mybatis 批量更新 ORA-00911: 无效字符的错误

Oracle -Mybatis动态SQL查询分页的实现

mybatis里的xml中的写添加的sql语句,怎么使用oracle数据库的序列

oracle if 语句

MyBatis 支持多个数据库