sql语句正确,但是报错java.sql.SQLSyntaxErrorException ORA-00907: 缺失右括号

sql语句如下,在oracle中带入参数能正常执行,在java程序中则报错java.sql.SQLSyntaxErrorException ORA-00907: 缺失右括号

select re.*,

tbp.taskid,

tbp.processtype,

tbp.processstatus,

tbp.timeLimit,

tbp.createtime    posttime,

tbp.proContent    dealContent

from biz_t_tasktroubleprocesstbp

right join (select t.*

fromBiz_T_TaskTrouble t

where 1 = 1

and t.status in:status

 and t.proType in :InProTypes)re

on tbp.ttrid = re.ttrid

关键地方标红,参数通过sp.put("InProTypes", Arrays.asList(proTypes));传入

带入参数后为and t.proType in (‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘),因为参数原本右边自带一个右括号,

所以参数转换时就默认把它当做自己的右括号,因此生成java执行sql时,实际就少了一个括号。

改进写法,and and t.proType in (:InProTypes) ) re

正确运行,通过

时间: 2024-07-29 15:16:11

sql语句正确,但是报错java.sql.SQLSyntaxErrorException ORA-00907: 缺失右括号的相关文章

连接mysql报错java.sql.SQLException: The server time zone value '?й???????' is unrecognized...解决方法

报错内容: java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time

java连接sqlserver2008报错 java.sql.SQLException: 对象名 '表名' 无效.

注意:c3p0的数据库配置方式为: <named-config name="sqlsvr"> <property name="driverClass">net.sourceforge.jtds.jdbc.Driver</property> <property name="jdbcUrl">jdbc:jtds:sqlserver://localhost:1433/WaterNet_DaFeng<

Java之数据库表字段有关键字报错java.sql.SQLSyntaxErrorException

前两天在开发中遇到一个坑,本来我在快乐的做着增删改查,然后悲剧发生了,在查询数据库的过程中,报了java.sql.SQLSyntaxErrorException: 经过排查,是因为数据库表字段中存在关键字: 下面重点来了,我用的是mybatis-plus,我的解决方案如下: 在这个字段上增加@TableField(value="`key`")注解即可,用``将字段包起来,是英文半角状态下的数字1前面的那个符号. 再运行起来就没问题啦 one more thing: 1.如果你用的是jp

java中mysql查询报错java.sql.SQLException: Before start of result set

异常:java.sql.SQLException: Before start of result set 解决方法:使用rs.getString();前一定要加上rs.next(); sm = conn.createStatement(); ResultSet rs = null; String sql_max = "SELECT id FROM a WHERE name= '" + name + "' ORDER BY online_time DESC LIMIT 1&qu

关于 64位系统 java连接access 报错java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序

报错的原因是url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=E:/公司/2000.mdb"; 这样是不行滴,要改成 url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=E:/公司/2000.mdb"; 我去,网上找了好久好久,才找到...

[mybatis] sql语句无错误,但是执行多条sql语句时,抛出java.sql.SQLSyntaxErrorException

错误内容 org.springframework.jdbc.BadSqlGrammarException: ### Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to u

mybatis中xml的sql之test中文报错

在mybatis中sql,test中文报错( java.lang.NumberFormatException 这句话明确告诉了我们是数字格式异常).需加.tostring(). <if test="bookName == '毛选集'.tostring() "> and b.book_Name like #{bookName} </if>

解决Oracle+Mybatis批量插入报错:SQL 命令未正确结束

Mybatis批量插入需要foreach元素.foreach元素有以下主要属性: (1)item:集合中每一个元素进行迭代时的别名. (2)index:指定一个名字,用于表示在迭代过程中,每次迭代到的位置. (3)collection:根据传入的参数值确定. (4)open:表示该语句以什么开始. (5)separator:表示在每次进行迭代之间以什么符号作为分隔 符. (6)close:表示以什么结束. 首先,错误的xml配置文件如下: <insert id="save" da

oracle 两个sql带有order by的使用union/union all的时候报错 &#39;ORA-00933:sql命令未正确结束&#39; 处理办法

错误语句:select id,name from s1 order by stime union all select id,name from s2 order by stime 报错原因:oracle 搜索到order by后认为整个select语句就该结束了但是后面还有union all所以数据库无法解析,导致报错 处理办法:with a1 as (select id,name from s1 order by stime) , a2 as (select id,name from s2