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

QQ登录

只需一步,快速开始

查看: 2157|回复: 1

[结贴] 标准查询SQL报错

[复制链接]

185

主题

777

帖子

1644

积分

金牌会员

Rank: 6Rank: 6

积分
1644
QQ
发表于 2013-9-22 14:59:27 | 显示全部楼层 |阅读模式
版本: 小版本号:
数据库: 服务器操作系统: 应用服务器:
客户端操作系统: 浏览器:
本帖最后由 ly201026 于 2013-9-22 15:04 编辑

在写标准查询SQL时sta = conn.prepareStatement(sql);这一处报错。
  1. Integer number = null;
  2.                 Connection conn = null;
  3.                 PreparedStatement sta = null;
  4.                 ResultSet rs = null;
  5.                 String sql = "select top 1 fUpLimitNum from TC_StorageMain where GoodsID = '"+goodsID+"'";
  6.                
  7.                 try {
  8.                         conn = ModelUtils.getConnection("/TCERP/InStorage/data");
  9.                         sta = conn.prepareStatement(sql);
  10.                         rs = sta.executeQuery();
  11.                         number = rs.getInt(0);
  12.                 } catch (NamingException e) {
  13.                         e.printStackTrace();
  14.                 } catch (SQLException e) {
  15.                         e.printStackTrace();
  16.                 }
  17.                 return number;
复制代码
后台错误如下:
  1. java.sql.SQLException: Use of the executeQuery(String) method is not supported on this type of statement.
  2.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.notSupported(JtdsPreparedStatement.java:198)
  3.         at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:835)
  4.         at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
  5.         at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
  6.         at InStorage.queryUpLimit(InStorage.java:96)
  7.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  8.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  9.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  10.         at java.lang.reflect.Method.invoke(Method.java:592)
  11.         at com.justep.system.action.Engine.invokeActions(Native Method)
  12.         at com.justep.system.action.Engine.invokeActions(Unknown Source)
  13.         at com.justep.business.server.BusinessServer.doAction(Unknown Source)
  14.         at com.justep.business.server.BusinessServer.doExcute(Unknown Source)
  15.         at com.justep.business.server.BusinessServer.excute(Unknown Source)
  16.         at com.justep.business.server.BusinessServerServlet.execService(Unknown Source)
  17.         at com.justep.business.server.BusinessServerServlet.service(Unknown Source)
  18.         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  19.         at com.justep.x.bs.BusinessServerServlet.service(Unknown Source)
  20.         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  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:102)
  27.         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  28.         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  29.         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
  30.         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  31.         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  32.         at java.lang.Thread.run(Thread.java:595)
复制代码
天天就知道打酱油打酱油,有点出息行么。QQ:497923435

185

主题

777

帖子

1644

积分

金牌会员

Rank: 6Rank: 6

积分
1644
QQ
 楼主| 发表于 2013-9-22 15:01:56 | 显示全部楼层
找到错误了。
天天就知道打酱油打酱油,有点出息行么。QQ:497923435
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-20 11:35 , Processed in 0.065095 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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