String sqlStr="select * from test";
DataSource ds = getDataSource(request);
Connection conn=ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sqlStr);
//取得数据表中的字段数目,类型等返回结果
ResultSetMetaData rsmd=rs.getMetaData();
//是以ResultSetMetaData对象保存
int columnCount = rsmd.getColumnCount(); //列的总数
ArrayList list=new ArrayList();
while(rs.next())
{
Map m=new HashMap();
for(int i=1;i<columnCount;i++)
{
m.put(rsmd.getColumnName(i), rs.getObject(i));
}
list.add(m);
}
DataSource ds = getDataSource(request);
Connection conn=ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sqlStr);
//取得数据表中的字段数目,类型等返回结果
ResultSetMetaData rsmd=rs.getMetaData();
//是以ResultSetMetaData对象保存
int columnCount = rsmd.getColumnCount(); //列的总数
ArrayList list=new ArrayList();
while(rs.next())
{
Map m=new HashMap();
for(int i=1;i<columnCount;i++)
{
m.put(rsmd.getColumnName(i), rs.getObject(i));
}
list.add(m);
}