正在尝试使用表格输出。 当程序运行时输出查询到到list集合的内容,但却总是无法输出。代码如下请指教。或者谁能用JSF+SQL2000做一个dataTable标签的输出发送至[email protected],只要正确立即给分。
DB类:
package biaogetest;import java.sql.*;
import java.util.*;
public class DBManage {
      private Connection conn;
      private Statement stmt;
      private ResultSet rs;
    public Connection myConnection() {
        try {
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;databaseName=kaka;","sa","sa");        } catch (Exception ex) {
            ex.printStackTrace(); //以下省略不写
        }
        return conn;
    }    public Statement myStatement() {        try {
            conn=this.myConnection();
            stmt = conn.createStatement();
        } catch (SQLException ex) {
        }
        return stmt;
    }    public ResultSet myResultSet(String sql) {
        try {
            stmt=this.myStatement();
             rs = stmt.executeQuery(sql);
        } catch (SQLException ex) {
        }
        return rs;
    }    public void closeAll() {
        try {
            if (stmt != null) {
                stmt.close();
            }
            if (rs != null) {
                rs.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException ex) {        }
    }
    
}
受管BEAN
package biaogetest;import java.util.List;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.sql.SQLException;public class ubean {
    public ubean() {
    }
    String uname;
    String pwd;
    public String getPwd() {
        return pwd;
    }    public String getUname() {
        return uname;
    }    public void setPwd(String pwd) {
        this.pwd = pwd;
    }    public void setUname(String uname) {
        this.uname = uname;
    }    public List getall()
   {
       DBManage db=new DBManage();
       List list=new ArrayList();
       try {
           ResultSet rs = db.myResultSet("select * from uload");
           while (rs.next()) {
               ubean ub = new ubean();
               ub.setUname(rs.getString(1));
               ub.setPwd(rs.getString(2));
               list.add(ub);
           }
       } catch (SQLException ex) {
       }
       return list;
   }}
JSP:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<title>
index
</title>
</head>
<body bgcolor="#ffffff">
<f:view>
 <h:form>
  
<h:dataTable value="#{bean.getall}"> <h:column>
 <h:outputText value="#{bean.uname}"/> 
 </h:column>
 
 </h:dataTable>
 </h:form>
 </f:view>
  
 
</body>
</html>