起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3304|回复: 1

[结贴] 数据库异常:Invalid parameter index 1.

[复制链接]

7

主题

15

帖子

41

积分

新手上路

Rank: 1

积分
41
QQ
发表于 2016-8-12 11:31:58 | 显示全部楼层 |阅读模式
我在select控件下增加一个点击事件,代码如下:

  1.         Model.prototype.select9Change = function(event){
  2.                 var value=$(this.getElementByXid("select9")).find("option:selected").text();
  3.                 var params = {"owner" : value};
  4.         justep.Baas.sendRequest({
  5.                                 "url" : "/KS/gan",
  6.                                 "action" : "selectByOwner",
  7.                                 "async" : false,
  8.                                 "params" : params,
  9.                                 "success" :function(ret)
  10.                                 {
  11.                                 console.log(ret);
  12.                                 }
  13.                         });
  14.                 console.log(value);
  15.         };
复制代码

在selectByOwner的动作里,写的sql语句在数据库中单独执行是可以的,但是写到自己的action中就出现如下错误,有人能帮忙看看嘛,谢谢。

  1. 八月 12, 2016 11:21:38 上午 org.apache.catalina.core.StandardWrapperValve invoke
  2. 严重: Servlet.service() for servlet WeX5_Baas_Servlet threw exception
  3. java.sql.SQLException: Invalid parameter index 1.
  4.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:255)
  5.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:326)
  6.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObjectBase(JtdsPreparedStatement.java:312)
  7.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObject(JtdsPreparedStatement.java:584)
  8.         at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
  9.         at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
  10.         at com.justep.baas.data.DataUtils.queryData(Unknown Source)
  11.         at KS.Api.selectByOwner(Api.java:39)
  12.         at KS.Gan__do.selectByOwner(Gan__do.java:139)
  13.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  14.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  15.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  16.         at java.lang.reflect.Method.invoke(Method.java:497)
  17.         at com.justep.baas.action.Engine.execAction(Unknown Source)
  18.         at com.justep.baas.action.Engine.execAction(Unknown Source)
  19.         at com.justep.baas.servlet.BaasServlet.execService(Unknown Source)
  20.         at com.justep.baas.servlet.BaasServlet.service(Unknown Source)
  21.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  22.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  23.         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  24.         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  25.         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  26.         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  27.         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  28.         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
  29.         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
  30.         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
  31.         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  32.         at java.lang.Thread.run(Thread.java:745)

  33. 2016-08-12 11:21:38 SQL执行失败,SQL:SELECT * FROM gan where 执行者='test';
  34. java.sql.SQLException: Invalid parameter index 1.
  35.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:255)
  36.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:326)
  37.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObjectBase(JtdsPreparedStatement.java:312)
  38.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObject(JtdsPreparedStatement.java:584)
  39.         at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
  40.         at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
  41.         at com.justep.baas.data.DataUtils.queryData(Unknown Source)
  42.         at KS.Api.selectByOwner(Api.java:39)
  43.         at KS.Gan__do.selectByOwner(Gan__do.java:139)
  44.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  45.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  46.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  47.         at java.lang.reflect.Method.invoke(Method.java:497)
  48.         at com.justep.baas.action.Engine.execAction(Unknown Source)
  49.         at com.justep.baas.action.Engine.execAction(Unknown Source)
  50.         at com.justep.baas.servlet.BaasServlet.execService(Unknown Source)
  51.         at com.justep.baas.servlet.BaasServlet.service(Unknown Source)
  52.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  53.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  54.         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  55.         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  56.         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  57.         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  58.         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  59.         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
  60.         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
  61.         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
  62.         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  63.         at java.lang.Thread.run(Thread.java:745)
  64. 2016-08-12 11:21:38 Action[KS/gan/selectByOwner]执行失败,SQL执行失败,SQL:SELECT * FROM gan where 执行者='test';
  65. java.lang.reflect.InvocationTargetException
  66.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  67.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  68.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  69.         at java.lang.reflect.Method.invoke(Method.java:497)
  70.         at com.justep.baas.action.Engine.execAction(Unknown Source)
  71.         at com.justep.baas.action.Engine.execAction(Unknown Source)
  72.         at com.justep.baas.servlet.BaasServlet.execService(Unknown Source)
  73.         at com.justep.baas.servlet.BaasServlet.service(Unknown Source)
  74.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  75.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  76.         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  77.         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  78.         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  79.         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  80.         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  81.         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
  82.         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
  83.         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
  84.         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  85.         at java.lang.Thread.run(Thread.java:745)
  86. Caused by: com.justep.baas.data.sql.SQLException: SQL执行失败,SQL:SELECT * FROM gan where 执行者='test';
  87.         at com.justep.baas.data.DataUtils.queryData(Unknown Source)
  88.         at KS.Api.selectByOwner(Api.java:39)
  89.         at KS.Gan__do.selectByOwner(Gan__do.java:139)
  90.         ... 20 more
  91. Caused by: java.sql.SQLException: Invalid parameter index 1.
  92.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:255)
  93.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:326)
  94.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObjectBase(JtdsPreparedStatement.java:312)
  95.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObject(JtdsPreparedStatement.java:584)
  96.         at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
  97.         at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:169)
  98.         ... 23 more
复制代码

7

主题

15

帖子

41

积分

新手上路

Rank: 1

积分
41
QQ
 楼主| 发表于 2016-8-12 12:27:43 | 显示全部楼层
已解决,自己手贱,table = DataUtils.queryData(conn, sql, sqlParams, null, null, null);其中第三个参数应该是null
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-11-23 05:21 , Processed in 0.050978 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表