Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connection conn = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try{
- DriverManager.registerDriver(new com.mysql.jdbc.Driver());
- conn = DriverManager.getConnection("jdbc:mysql://localhost/DB명", "ID", "PWD");
- pstmt = conn.prepareStatement("SQL");
- rs = pstmt.executeQuery();
- while(rs.next()){
- writer.println(rs.getInt("col1") + ", " + rs.getString("col2") + "<br>");
- }
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try{ if(rs != null){ rs.close();} }catch(Exception e){}
- try{ if(pstmt != null){ pstmt.close();} }catch(Exception e){}
- try{ if(conn != null){ conn.close();} }catch(Exception e){}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement