google-code-export / nutz

Automatically exported from code.google.com/p/nutz
Apache License 2.0
1 stars 1 forks source link

dao.query 出现 Number of input values does not match number of question marks 异常问题 #260

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
问题产生的条件:
如果一个变量中存在@特殊字符的话 执行dao.query 
方法就会出错

发生问题的调用代码:
Condition condition1 = Cnd.where("isprecordid", "=", 
icpWzxx.getIspWzid()).and("websitename", "=", icpWzxx.getWzmc().trim());

List<Wzicprecord> wzicprecord_zzy = dao.query(Wzicprecord.class, condition1, 
null);

icpWzxx.getWzmc().trim() 的值是:688kkk@163.com

问题的详细说明:
 NUTZ对@符号进行了特殊使用。 是否考虑 变量里的@符号进行转义下?

异常堆栈:
org.nutz.dao.DaoException: !Nuz SQL Error: 'SELECT * FROM wzicprecord  WHERE 
isprecordid=3057234 AND websitename='688kkk.com''
        at org.nutz.dao.sql.SqlImpl.execute(SqlImpl.java:113)
        at org.nutz.dao.impl.NutDao$2.invoke(NutDao.java:200)
        at org.nutz.dao.ConnectionHolder.invoke(ConnectionHolder.java:45)
        at org.nutz.dao.impl.NutDao.run(NutDao.java:218)
        at org.nutz.dao.impl.NutDao.execute(NutDao.java:187)
        at org.nutz.dao.impl.NutDao.query(NutDao.java:711)
        at org.nutz.dao.impl.NutDao.query(NutDao.java:704)
        at zzy.record.service.BASJAtom.run(BASJAtom.java:463)
        at org.nutz.trans.Trans.exec(Trans.java:121)
        at org.nutz.trans.Trans.exec(Trans.java:79)
        at zzy.record.action.BatchAction.operateBatch(BatchAction.java:224)
        at zzy.record.dao.impl.BeianInvoker.Download(BeianInvoker.java:799)
        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:585)
        at zzy.record.dao.impl.BeianInvoker.invoke(BeianInvoker.java:84)
        at zzy.record.control.BrokerEngine.serviceSync(BrokerEngine.java:73)
        at zzy.record.control.DBDownload.excute(DBDownload.java:123)
        at zzy.record.control.DBDownload.run(DBDownload.java:54)
Caused by: java.sql.SQLException: Number of input values does not match number 
of question marks
        at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:348)
        at com.informix.jdbc.IfxPreparedStatement.checkParameterIndex(IfxPreparedStatement.java:2557)
        at com.informix.jdbc.IfxPreparedStatement.setNull(IfxPreparedStatement.java:382)
        at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:104)
        at org.nutz.dao.sql.FieldAdapter$AsNull.set(FieldAdapter.java:104)
        at org.nutz.dao.sql.DefaultStatementAdapter.processWithEntity(DefaultStatementAdapter.java:55)
        at org.nutz.dao.sql.DefaultStatementAdapter.process(DefaultStatementAdapter.java:20)
        at org.nutz.dao.sql.SqlImpl.execute(SqlImpl.java:66)
        ... 19 more

相关日志:

Original issue reported on code.google.com by Toni.xu...@gmail.com on 27 Jul 2010 at 2:41

GoogleCodeExporter commented 9 years ago
在 Cnd 中,将 '@' 以及 '$' 做了转义

fixed in r1435

+JUnit:
org.nutz.dao.test.normal.QueryTest
   > query_by_special_char
   > query_by_special_char2

Original comment by zozoh...@gmail.com on 27 Jul 2010 at 4:47