public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
String url = "jdbc:oracle:thin:@localhost:1521/xepdb1";
String sql = "SELECT * FROM NOTICE";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url, "test", "1111");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql);
while(rs.next()) { //가져왔는지 확인해야한다
//꺼내는 순서는 상관없다
int id = rs.getInt("ID");
String title = rs.getString("TITLE");
String writerId = rs.getString("WRITER_ID");
Date regDate = rs.getDate("REGDATE");
String content = rs.getString("FILES");
int hit = rs.getInt("HiT");
System.out.printf(" id :%d, title:%s, wrterid:%s, "
+ "regDate:%s, content:%s, hit:%d\n",
id, title, writerId, regDate, content, hit);
}
rs.close();
st.close();
con.close();
}