import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
String sql = "select * from board where id=?";
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCnt = rsmd.getColumnCount(); //컬럼의 수
if(rs.next()){
for(int i=1 ; i<=columnCnt ; i++){
// 컬럼명 //데이터
System.out.println(rsmd.getColumnName(i)+","+rs.getString(rsmd.getColumnName(i)));
}
}
댓글 없음:
댓글 쓰기