Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 useBean 连接数据库问提
neil99





发贴: 19
积分: 0
于 2006-03-30 09:48 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="content-language" content="gb2312" />
</head>
<body>
<%@ page language="java" %>
<jsp:useBean id="sqlb" scope="page" class="packages.util.DataBase" />

<%@ page import="java.sql.*;" %>
<%

try{
String str2="select * from ta";
out.println(str2);

ResultSet rs=sqlb.executeSearch(str2);

if(rs.next()) //这里开始不打印结果?
out.println('2');
rs.beforeFirst();
while(rs.next())
out.println(rs.getInt("id")+"\t"+rs.getString("name"));


rs.close();
sqlb.closeStmt();
sqlb.closeConn();
}catch(Exception e){}

%>

结束
</body>
</html>

为什么读不出数据库的内容呢?也没显示错误啊
直接跳到显示 "结束"
packages.util.DataBase 在程序中测试是好的啊



作者 Re:useBean 连接数据库问提 [Re:neil99]
hoden_w





发贴: 19
积分: 0
于 2006-03-30 17:29 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
看不懂楼主想要干什么?
if(rs.next()) {//这里开始不打印结果?是不是数据库里面没有东西??
out.println('2');
}
rs.beforeFirst();
while(rs.next()){
out.println(rs.getInt("id")+"\t"+rs.getString("name"));
}

rs.close();
sqlb.closeStmt();
sqlb.closeConn();



ATE.FoRgETTeN.GeTNaME.nEIL iPoD*|nEIL<i.e>
作者 Re:useBean 连接数据库问提 [Re:neil99]
neil99





发贴: 19
积分: 0
于 2006-03-30 19:36 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
不是了
if(rs.next()) {
out.println('2');
}

这里我没有删除掉.没有的.

rs.beforeFirst();
while(rs.next()){
out.println(rs.getInt("id")+"\t"+rs.getString("name"));
}
才是打印数据库内容
就是显示不出来




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923