我如何打印出结果?

ncowboy 2004-09-06 06:38:47
<%@ include file="inc/global.jsp"%>
<%
Connection conn = o.getConnection();
int rs = o.executeUpdate(conn,"select count(*) from bookedexp_info ");
if(rs!=0)
{
out.println("1");
}
else
out.println("0");
%>
~
我要的是那个结果集的内容.
(很抱歉,我是搞.net的.不熟悉java中数据集的用法.)
...全文
73 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ncowboy 2004-09-08
HTTP Status 500 - Internal Server Error

--------------------------------------------------------------------------------

type Exception report

message Internal Server Error

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

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 1 in the jsp file: /test.jsp

Generated servlet error:
[javac] Compiling 1 source file

/opt/jakarta-tomcat-4.1.30/work/Apache/202.115.171.85/_/test_jsp.java:100: int cannot be dereferenced
if (rs.next()) {
^



An error occurred at line: 1 in the jsp file: /test.jsp

Generated servlet error:
/opt/jakarta-tomcat-4.1.30/work/Apache/202.115.171.85/_/test_jsp.java:101: int cannot be dereferenced
out.println(rs.getInt(1));
^
2 errors


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.connector.warp.WarpRequestHandler.handle(Unknown Source)
at org.apache.catalina.connector.warp.WarpConnection.run(Unknown Source)
at java.lang.Thread.run(Thread.java:534)



--------------------------------------------------------------------------------

Apache Tomcat/4.1.30
回复
pleonheart 2004-09-06
这个才对,呵呵
Connection conn = o.getConnection();
ResultSet rs = o.executeUpdate(conn,"select count(*) from bookedexp_info ");
if (rs.next()) {
out.println(rs.getInt(1));
} else {
out.println("0");
}
回复
pleonheart 2004-09-06
Connection conn = o.getConnection();
ResultSet rs = o.executeUpdate(conn,"select count(*) from bookedexp_info ");
if (rs.next()) {
out.println("1");
} else {
out.println("0");
}
回复
power17 2004-09-06
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
String DRV="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=web";
String user="sa";
String pwd="";
String sql="select count(*) from login";
Class.forName(DRV);
Connection conn=DriverManager.getConnection(url,user,pwd);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(sql);
try{
if(rs.next()){
int k=rs.getInt(1);
out.println(k);
}
}catch(Exception e){}
%>
</body>
</html>

写的不规范,见谅! ^_^
回复
Acylas 2004-09-06
ResultSet rst = o.executeQuery(conn,"select count(*) from bookedexp_info ");
out.println(rst.getInt("1"));
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-06 06:38
社区公告
暂无公告