2007-12-18
创建全能的表格管理程序
String sql = "SELECT * FROM \""+tableName+"\" LIMIT 0 OFFSET 0";
List list = new ArrayList();
Connection conn = null;
try {
conn = getConn();
Statement st = null;
try{
st = conn.createStatement();
ResultSet rs = null;
try{
rs = st.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
int cnt = rsmd.getColumnCount();
for (int i = 1; i <= cnt; i++) {
String type = rsmd.getColumnTypeName(i);
if(type.equals("varchar") || type.equals("int4") || type.equals("bool") || type.equals("timestamp")){
HashMap hashMap = new HashMap();
hashMap.put("name", rsmd.getColumnName(i));
hashMap.put("type", rsmd.getColumnTypeName(i));
list.add(hashMap);
}
}
}finally{
if(rs!=null)rs.close();
}
}finally{
if(st!=null)st.close();
}
} catch (NamingException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
} catch (SQLException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}finally{
if(conn!=null)
try {
conn.close();
} catch (SQLException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
}
return list;
发表评论
- 浏览: 11608 次
- 性别:

- 来自: 黑洞

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
打破时间的束缚(转)
我对以下方面有一些疑虑:1、如何降低协作的成本、加快沟通的速度?2、是否每个人的 ...
-- by outrace -
打破时间的束缚(转)
weiqingfei 写道ouspec 写道这样做会使协作成为问题,比如大家需要 ...
-- by zerker -
打破时间的束缚(转)
ouspec 写道这样做会使协作成为问题,比如大家需要同时来做一件事情的,同时在 ...
-- by weiqingfei -
打破时间的束缚(转)
这样做会使协作成为问题,比如大家需要同时来做一件事情的,同时在线沟通是很重要的。 ...
-- by ouspec -
打破时间的束缚(转)
他们这样做是对的,工作业绩是以成果论的,这是所有工作的共同特点。 只不过表现形式 ...
-- by flyingbug






评论排行榜