/**
* ResultSet을 List로 반환
* @param rs ResultSet
* @return List
*/
public List getRsToList(ResultSet rs){
List lst = null;
try{
int rows = rs.getRow();
if(rows > -1){
ResultSetMetaData mrs = rs.getMetaData();
int Col_TYPE = 0;
String Col_NAME = "";
String inputVar = null;
HashMap rowHash = new HashMap();
lst = new ArrayList();
// 컬럼수
int colcnt = mrs.getColumnCount();
while(rs.next()){
rowHash = new HashMap();
for(int i=1; i<=colcnt; i++){
Col_NAME = mrs.getColumnName(i).toUpperCase();
inputVar = rs.getString(i);
rowHash.put(Col_NAME, inputVar);
}
lst.add(rowHash);
}
}
} catch(SQLException sqle){
sqle.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
return lst;
}
* ResultSet을 List로 반환
* @param rs ResultSet
* @return List
*/
public List getRsToList(ResultSet rs){
List lst = null;
try{
int rows = rs.getRow();
if(rows > -1){
ResultSetMetaData mrs = rs.getMetaData();
int Col_TYPE = 0;
String Col_NAME = "";
String inputVar = null;
HashMap rowHash = new HashMap();
lst = new ArrayList();
// 컬럼수
int colcnt = mrs.getColumnCount();
while(rs.next()){
rowHash = new HashMap();
for(int i=1; i<=colcnt; i++){
Col_NAME = mrs.getColumnName(i).toUpperCase();
inputVar = rs.getString(i);
rowHash.put(Col_NAME, inputVar);
}
lst.add(rowHash);
}
}
} catch(SQLException sqle){
sqle.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
return lst;
}
'JAVA/JSP' 카테고리의 다른 글
StringBuffer 초기화하여 재사용하기. (0) | 2010.11.22 |
---|---|
java charset 관련 변환 유틸. (0) | 2010.10.21 |
파일 업로드 multipart/form-data (0) | 2010.10.21 |