前言

使用MyBatis进行SQL查询,报出SQL异常,原因为SQL语句最后结束加了分号(? )(?)

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

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

### The error may exist in com/df/dao/RunOverviewMapper.java (best guess)
### The error may involve com.df.dao.RunOverviewMapper.selectRunOverview-Inline
### The error occurred while setting parameters
### SQL: select * from ( select tmp_page.*, rownum row_id from ( SELECT tmp2.*, (SELECT COUNT (*)FROM DSGC_LOG_INSTANCE loi2 WHERE loi2.serv_no = tmp2.serv_no AND loi2.inst_status = '1' and loi2.START_TIME between to_date('2019-05-07','yyyy-mm-dd')AND to_date('2019-05-07 23:59:59','yyyy-mm-dd hh24:mi:ss')+1) AS suc_num, (SELECT COUNT (*)FROM DSGC_LOG_INSTANCE loi2 WHERE loi2.serv_no = tmp2.serv_no AND loi2.inst_status = '0' and loi2.START_TIME between to_date('2019-05-07','yyyy-mm-dd')AND to_date('2019-05-07 23:59:59','yyyy-mm-dd hh24:mi:ss')+1) AS fail_num FROM(SELECT tmp.*, os1.serv_name,os1.serv_no FROM (SELECT serv_id,NVL(ROUND ((SUM (timediff)/1000) / DECODE (SUM (run_times),0,1,SUM (run_times)),2),0) AS AVE_TIME,NVL(MAX (timediff),0) AS max_resp_time,NVL(MIN (timediff),0) AS min_resp_time,MAX (creation_date) create_date,COUNT (run_times) total_num FROM(SELECT os.serv_id,os.serv_no,os.serv_name,run_times,EXTRACT (SECOND FROM(end_time - start_time) ) * 1000 AS timediff,os.creation_date FROM DSGC_SERVICES os LEFT JOIN DSGC_LOG_INSTANCE loi1 ON os.serv_no = loi1.serv_no where os.serv_status = '1'AND loi1.START_TIME >= to_date('2019-05-07','yyyy-mm-dd') AND loi1.START_TIME <=to_date('2019-05-07 23:59:59','yyyy-mm-dd hh24:mi:ss')+1)GROUP BY serv_id) tmp,DSGC_SERVICES os1 WHERE tmp.serv_id = os1.serv_id) tmp2 ORDER BY tmp2.serv_id desc; ) tmp_page where rownum <= ? ) where row_id > ?
### Cause: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

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

at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:91)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy92.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy146.selectRunOverview(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

解决

删除,别加了

祝你幸福

送你一首歌《Way Back Home》 Way Back Home​​

附图:甘肃庆阳

### Cause: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符_无效字符_02


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