Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JDateChooser arrival = new JDateChooser();
- JDateChooser departure = new JDateChooser();
- ResultSet rs = null;
- Connection conn = null;
- Statement stmt = null;
- try {
- // new com.mysql.jdbc.Driver();
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- String connectionUrl = "jdbc:mysql://localhost:3306/testing?autoReconnect=true&useSSL=false";
- String connectionUser = "root";
- String connectionPassword = "admin";
- conn = DriverManager.getConnection(connectionUrl, connectionUser,
- connectionPassword);
- stmt = conn.createStatement();
- String query = "select * from testing.room as ro
- where ro.room_id not in
- (
- select re.room_no
- from testing.booking as re
- where (arrival_date >= "2016-05-24" and departure_date < "2016-05-29")
- or (departure_date >= "2016-05-24" and arrival_date < "2016-05-29")
- )";
- rs = (ResultSet) stmt.executeQuery("");
- while (rs.next()) {
- System.out.println(rs.getString(1) + " " + rs.getString(2)
- + " " + rs.getString(3)+ " " + rs.getString(4)+ " "+ rs.getString(5));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- where (arrival_date >= "2016-05-24" and departure_date < "2016-05-29")
- or (departure_date >= "2016-05-24" and arrival_date < "2016-05-29")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement