| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 483 人关注过本帖
标题:简单的查询页面问题
只看楼主 加入收藏
weilai
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-5-8
收藏
 问题点数:0 回复次数:1 
简单的查询页面问题

help1.jsp
<%@ page contentType="text/html; charset=gb2312" import="java.sql.*"%>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel=stylesheet href='../treeimg/style.css' type=text/css>
</head>
<body bgcolor="#2F97FF">
<jsp:include page="../inc/top.jsp" flush="true"/>
<form name="form1" method="post" action="help2.jsp">
按作者名搜索:
<input type="text" name="username">
<input type="submit" name="Submit" value="提交">
<input type="reset" name="reset" value="重写">
</form>
</body>
</html>
help2.jsp
<%@ page contentType="text/html; charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="clsIDquery" scope="session" class="org.code.optSql.jdbc"/>
<jsp:useBean id="tools" class="org.code.tool.tools" scope="page" />
<%
//数据库变量声明;
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String sql=null;
%>
<%!String username,postUser;%>

<%
//数据库连接
conn=clsIDquery.getConn();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

String username=request.getParameter("username");

sql= "update Content set iBoardID=iBoardID+1 Where postUserName="+username;
rs=stmt.executeQuery(sql);
while(rs.next())
{


String postUser=rs.getString("postUserName");
}
%>
<html>

<body>

<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1">
<tr bordercolor="#009ACE" bgcolor="#009ACE">

<td width="10%" bgcolor="#9CCFFF">发表作者</td>

</tr>


<td width="10%" bgcolor="#F7FBFF"><%=postUser%></td><!-- ########## -->

</table>

</body>
</html>
<%
//关闭连接
rs.close();
stmt.close();
conn.close();
%>
可页面总是出错
type: Exception report

message

description: The server encountered an internal error () that prevented it from fulfilling this request.

exception:

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.help.help2_jsp._jspService(help2_jsp.java:128)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause :

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
org.apache.jsp.help.help2_jsp._jspService(help2_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

大家帮帮忙,多谢了

搜索更多相关主题的帖子: 查询 页面 
2006-05-08 18:38
gameovercn
Rank: 1
等 级:新手上路
帖 子:62
专家分:0
注 册:2005-10-25
收藏
得分:0 
这样好象不行吧,举个例子

rs=stmt.executeQuery("select xm,xb from emp where .......");
while(rs.next()){
String xm=rs.getString(1);
String xb=rs.getString(2);
}

另外update要用stmt.executeUpdate()

中国!!!你别玩了!!! 我昨天做梦了,我成了个框架师,哈哈
2006-05-10 16:05
快速回复:简单的查询页面问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034602 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved