jdbc操作数据库并自动获取字段类型
//获取改功能编码的关联功能
public void getLinkdb(String gnbianma){
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
/**
select * from SY_FUNC fc where fc.func_code ='SY_FUNC' --功能定义
select * from SY_FORM_LINK FLK where FLK.main_func_code='SY_FUNC' --关联功能
**/
String strSql =" select * from SY_FORM_LINK FLK where FLK.main_func_code in "
+" ( select FLK.Main_Func_Code from SY_FORM_LINK FLK where FLK.main_func_code=? ) ";
List<HashMap<String, Object>> stepLists = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> map =null;
try {
conn = DbUtil.getConnection();
pstmt = conn.prepareStatement(strSql);
pstmt.setString(1, gnbianma);
rs = pstmt.executeQuery();
ResultSetMetaData rsmd;
while (rs.next()){
map = new HashMap<String, Object>();
rsmd = (ResultSetMetaData) rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
map.put(rsmd.getColumnName(i), rs.getObject(i));
}
stepLists.add(map);
}
rs.close();
}catch (SQLException e) {
e.printStackTrace();
}finally {
DbUtil.close(pstmt);
DbUtil.close(conn);
}
System.out.println(stepLists.size());
}
补充:综合编程 , 其他综合 ,