Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package dsu.cs;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.Statement;
  7.  
  8. public class MemberList {
  9.  
  10. public static void main(String[] args) {
  11. Connection conn = null;
  12. Statement stmt = null;
  13. ResultSet rs = null;
  14. try {
  15. DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
  16. conn = DriverManager.getConnection(
  17. "jdbc:mysql://localhost/studydb?autoReconnect=true&useSSL=false",
  18. "study",
  19. "study");
  20. stmt=conn.createStatement();
  21. rs=stmt.executeQuery("SELECT MNO, MNAME, EMAIL, CRE_DATA from MEMBERS ORDER BY MNO ASC");
  22. while (rs.next())
  23. {
  24. System.out.print(rs.getInt("MNO"));
  25. }
  26. } catch (Exception e) {
  27. e.printStackTrace();
  28. } finally {
  29. try { if (null!=rs) rs.close(); } catch (Exception e) {}
  30. try { if (null!=stmt) stmt.close(); } catch (Exception e) {}
  31. try { if (null!=conn) conn.close(); } catch (Exception e) {}
  32. }
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement