JSP 连上数据库后数据不正确

来源:百度知道 编辑:UC知道 时间:2024/06/01 03:45:52
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import="java.sql.*, com.clq.*"%>

<%!
private void tree(List articles, Connection conn, int id) {
String sql = "select * from article where id ";
Statement stmt = null;
ResultSet rs = null;
try{
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);

while(rs.next()) {
Article a = new Article();
a.setId(rs.getInt("id"));
a.setPid(rs.getInt("pid"));
a.setRootid(rs.getInt("rootid"));
a.setTitle(rs.getString("title"));
a.setIsleaf(rs.getInt("isleaf") ==0 ? false : true);
a.setPdate(rs.getTimestamp("pdate"));

articles.add(a);
//if(a.isIsleaf()){
// tree(articles,conn,a.getId());
}

} catch (SQLExceptio

李兴华老师的BBS项目里面的吧?

既然是显示的次数出现问题,那么你应该检查你的循环是否正确?可以利用最简单的控制台输出来查找该问题!

虽然没有直接解决你的问题,但是相信思路更有利于你的!

希望我的回答对你有所帮助!!

什么输入三遍啊!