Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. package javaapplication2;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.PreparedStatement;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8.  
  9.  
  10.  
  11. //jdbc:derby://localhost:1527/LMS
  12.  
  13.  
  14. class abc {
  15.  
  16.  
  17. public abc() throws SQLException{
  18.  
  19.  
  20. //ConnectionURL, username and password should be specified in getConnection()
  21.  
  22.  
  23. //ConnectionURL, username and password should be specified in getConnection()
  24. try {String url = "jdbc:derby://localhost:1527/LMS";
  25. Connection conn = DriverManager.getConnection(url,"zain","12345");
  26. System.out.println("Connected! ");
  27.  
  28. String sql = "SELECT * FROM BOOK";`enter code here`
  29. Statement st = conn.createStatement();
  30. ResultSet rs=st.executeQuery(sql);
  31. String x;
  32. while(rs.next()){
  33.  
  34.  
  35. System.out.println(rs.getString("Password"));
  36. }
  37.  
  38.  
  39. }
  40.  
  41.  
  42. catch (SQLException ex) {
  43. System.out.println(ex);
  44. }
  45.  
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement