⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 questionlist.java

📁 它是利用jsp+javabean来编写的
💻 JAVA
字号:
/*
 * QuestionList.java
 *
 * Created on 2006年8月10日, 下午3:49
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ACTION;
import java.sql.*;
import PUBLIC.TestSql;
/**
 *
 * @author fish
 */
public class QuestionList extends TestSql{
    ResultSet rs;
    String Result="无法显示该内容";
    public QuestionList() {
    }
    public String getList(){
        StringBuffer buffer=new StringBuffer(); //建立缓存空间
        int tempID; //临时ID变量
        String QuestionContents;
        Time QuestionTime;
        try {
            String condition="SELECT * FROM TestQuestion ORDER BY QuestionID DESC";  //查找数据库[TestQuestion]表中的所有问题
            rs=sql.executeQuery(condition);
            buffer.append("<Table width='750'>");   //建立HTML表格
            while(rs.next())
            {
                tempID=rs.getInt("QuestionID");
                QuestionContents=rs.getString("QuestionContents");
                QuestionTime=rs.getTime("QuestionTime");
                buffer.append("<Tr>");
                buffer.append("<Td width='100'>编号:"+tempID+"</Td>");
                buffer.append("<Td width='450'>问题:<a href='View.jsp?"+tempID+"'>"+QuestionContents.substring(0,10)+"</a></Td>");
                buffer.append("<Td width='200'>发布时间:"+QuestionTime+"</Td>");
                buffer.append("</Tr>");
            }
            buffer.append("</Table>");
            Result=new String(buffer);  //将缓存中的内容转化为字符串并赋值给result
        } catch (SQLException ex) {
            Result="列表显示失败!";
            ex.printStackTrace();
        }
        return Result;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -