showarticle.java
来自「E家园 是 利用java做的 很好 的 是 初学者的宝贝」· Java 代码 · 共 55 行
JAVA
55 行
package dao;
import java.util.ArrayList;
import java.util.List;
import biz.GetConnection;
import java.sql.ResultSet;
import java.sql.SQLException;
import entity.ARITCLE;
public class ShowArticle
{
private ResultSet rs=null;
public List Show()
{
List<ARITCLE> list=new ArrayList<ARITCLE>();
GetConnection conn=new GetConnection();
conn.getconn();
rs=conn.getResulset("select *from ARITCLE");
try {
while(rs.next())
{
ARITCLE arit=new ARITCLE();
arit.setArticleId(rs.getInt("articleId"));
arit.setContent(rs.getString("content"));
arit.setTitle(rs.getString("title"));
arit.setType(rs.getString("type"));
arit.setTypeId(rs.getInt("typeId"));
arit.setUserId(rs.getInt("userId"));
arit.setWriteDate(rs.getDate("writeDate"));
arit.setWriter(rs.getString("writer"));
list.add(arit);
}
} catch (SQLException e) {
System.out.println("在查询数据库信息失败");
e.printStackTrace();
}
finally
{
conn.Close();
}
return list;
}
public static void main(String args[])
{
ShowArticle show=new ShowArticle();
List list=show.Show();
for(int i=0;i<list.size();i++)
{
ARITCLE arit=(ARITCLE)list.get(i);
System.out.println("======="+arit.getTitle());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?