Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. JDateChooser arrival = new JDateChooser();
  2. JDateChooser departure = new JDateChooser();
  3.  
  4. ResultSet rs = null;
  5. Connection conn = null;
  6. Statement stmt = null;
  7. try {
  8. // new com.mysql.jdbc.Driver();
  9. Class.forName("com.mysql.jdbc.Driver").newInstance();
  10. String connectionUrl = "jdbc:mysql://localhost:3306/testing?autoReconnect=true&useSSL=false";
  11. String connectionUser = "root";
  12. String connectionPassword = "admin";
  13. conn = DriverManager.getConnection(connectionUrl, connectionUser,
  14. connectionPassword);
  15. stmt = conn.createStatement();
  16. String query = "select * from testing.room as ro
  17. where ro.room_id not in
  18. (
  19. select re.room_no
  20. from testing.booking as re
  21. where (arrival_date >= "2016-05-24" and departure_date < "2016-05-29")
  22. or (departure_date >= "2016-05-24" and arrival_date < "2016-05-29")
  23. )";
  24.  
  25. rs = (ResultSet) stmt.executeQuery("");
  26.  
  27. while (rs.next()) {
  28. System.out.println(rs.getString(1) + " " + rs.getString(2)
  29. + " " + rs.getString(3)+ " " + rs.getString(4)+ " "+ rs.getString(5));
  30. }
  31.  
  32. } catch (Exception e) {
  33. e.printStackTrace();
  34. }
  35.  
  36. where (arrival_date >= "2016-05-24" and departure_date < "2016-05-29")
  37. or (departure_date >= "2016-05-24" and arrival_date < "2016-05-29")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement