NutzCN Logo
问答 dao.sqls().create java.sql.SQLException: ORA-01008: 并非所有变量都已绑定
发布于 583天前 作者 qq_5c3d1d85 721 次浏览 复制 上一个帖子 下一个帖子
标签:

Sql sql = dao.sqls().create("pool.a");
sql.params().set("ABC", "654654");
dao.execute(sql);

/*pool.a*/
delete from table_test where (DFAELL= @ABC and ZFLAG=1) OR ZFLAG=2

并非所有变量都已绑定

  • 请问这种是什么原因啊,其他地方用到了均没问题
15 回复

这个我遇到过,当时忙让同事把大小写改了下就解决了,一直没去跟代码,求解决

Caused by: org.nutz.dao.DaoException: !Nutz SQL Error: 'delete from table_test where DFAELL= '
PreparedStatement:
'delete from table_test where DFAELL= ?'
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:85) ~[nutz-1.51-SNAPSHOT.jar:na]
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:242) ~[nutz-1.51-SNAPSHOT.jar:na]
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:61) ~[nutz-1.51-SNAPSHOT.jar:na]
... 24 common frames omitted
Caused by: java.sql.SQLException: ORA-01008: 并非所有变量都已绑定

at oracle.jdbc.driver.T4

CTTIoer.processError(T4CTTIoer.java:445) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2489) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2451) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2487) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2451) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2487) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.execute(StatementProxyImpl.java:137) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.pool.DruidPooledStatement.execute(DruidPooledStatement.java:421) ~[druid-1.0.13.jar:1.0.13]
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runStatement(NutDaoExecutor.java:303) ~[nutz-1.51-SNAPSHOT.jar:na]
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:67) ~[nutz-1.51-SNAPSHOT.jar:na]
... 26 common frames omitted

@wendal Caused by: org.nutz.dao.DaoException: !Nutz SQL Error: 'delete from table_test where DFAELL= '
PreparedStatement:
'delete from table_test where DFAELL= ?'
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:85) ~[nutz-1.51-SNAPSHOT.jar:na]
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:242) ~[nutz-1.51-SNAPSHOT.jar:na]
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:61) ~[nutz-1.51-SNAPSHOT.jar:na]
... 24 common frames omitted
Caused by: java.sql.SQLException: ORA-01008: 并非所有变量都已绑定
at oracle.jdbc.driver.T4
CTTIoer.processError(T4CTTIoer.java:445) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0]
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2489) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2451) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2487) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2451) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:2487) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.execute(StatementProxyImpl.java:137) ~[druid-1.0.13.jar:1.0.13]
at com.alibaba.druid.pool.DruidPooledStatement.execute(DruidPooledStatement.java:421) ~[druid-1.0.13.jar:1.0.13]
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runStatement(NutDaoExecutor.java:303) ~[nutz-1.51-SNAPSHOT.jar:na]
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:67) ~[nutz-1.51-SNAPSHOT.jar:na]
... 26 common frames omitted

后来将where中的条件全部删掉,只剩下这一个,产生的日志,仍然出现此问题

@kerbores 最开始用的小写变量,出现问题,后来又改成了大写

其他"正常"的是怎么写的?

@wendal 将另一个功能中的几行代码,拷贝到此功能中执行,也抛出了这个异常……会不会和dao有关系啊
我的dao实例获得方式是
@Inject
protected Dao dao;

@wendal 成功运行的代码编写方式,和上面的代码格式(方式)一模一样,将’正常‘的程序代码,贴到此功能中,也报了错

nutz 版本号1.b.52

是不是这个sql后面还有一个sql?? 把sql文件里面的其他所有sql声明

@wendal 没有其他sql,此段sql前后,都有/**/ ,且log中打印出来的也仅仅此一段说起来

前后都删了

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
com.alibaba.druid.pool.DruidDataSource
apache-tomcat-8.0.18
IntelliJ IDEA 14.0.3
nutz 1.b.52

直接运行测试程序成功执行,debug抛错……实在无语。
分析:1. 既然SQLException: ORA-01008: 并非所有变量都已绑定 是数据库抛出的,说明dao没有问题,
2. debug时,看到变量”Sql sql “也是有sql语句的,说明sql脚本中的sql语句也成功读取了。
可能原因:sql.params().set("ABC", "654654"); 时 ,没有将变量写入ABC中,没有仔细研究nutz代码,完成项目功能先

添加回复
请先登陆
回到顶部