RSS订阅优然探索
你的位置:首页 » JAVA » 正文

JAVA ResultSet

选择字号: 超大 标准 发布时间:2013-4-1 12:44:20 | 作者:admin | 0个评论 | 人浏览

 package net.lisoft.service.log;

 
import java.sql.*;
import java.text.SimpleDateFormat;
import java.lang.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
import net.lisoft.db.DbServer;
 
public class LogList {
 
public static ResultSet getLoglist1() throws SQLException,
InstantiationException, IllegalAccessException,
ClassNotFoundException {
 
DbServer dServer = new DbServer();
ResultSet rs = dServer
.Execute("select top 10  * from TB_System_Log where status=0 order by id desc");
return rs;
}
 
public static List getLoglist2() throws SQLException,
InstantiationException, IllegalAccessException,
ClassNotFoundException {
 
DbServer dServer = new DbServer();
ResultSet rs = dServer
.Execute("select top 10  * from TB_System_Log where status=0 order by id desc");
return convertList(rs);
}
 
private static List convertList(ResultSet rs) throws SQLException {
 
List list = new ArrayList();
 
ResultSetMetaData md = rs.getMetaData();
 
int columnCount = md.getColumnCount(); // Map rowData;
 
while (rs.next()) { // rowData = new HashMap(columnCount);
 
Map rowData = new HashMap();
 
for (int i = 1; i <= columnCount; i++) {
 
rowData.put(md.getColumnName(i), rs.getObject(i));
 
}
//System.out.println(rowData.toString());
list.add(rowData);
 
}
return list;
 
}
}
 

标签:

猜你喜欢

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。