title: java setDate on mySQL
body: <p>I have two sql date that from a function parameter:</p>
  
  <pre><code>public void aaa (java.sql.Date sqlDate1, java.sql.Date sqlDate2)
  </code></pre>
  
  <p>inside the function is:</p>
  
  <pre><code>String sql = "SELECT ROOM_TYPE_ID , COUNT(ROOM_ID) AS Available_Room_Quantity FROM ROOM " +
               "WHERE Room_ID NOT IN (SELECT ROOM_ID FROM ROOM_RECORD WHERE START_DATE&lt;=? AND END_DATE&gt;=? ) "+
               "GROUP BY ROOM_TYPE_ID";
  
  statement = conn.prepareStatement(sql);
  statement.setDate(1, sqlDate1);
  statement.setDate(2, sqlDate2);
  ResultSet rs = statement.executeQuery(sql);
  
  while(rs.next())
  {
  
      String first = rs.getString("Available_Room_Quantity");
      String last = rs.getString("ROOM_TYPE_ID");
  
      System.out.print("ROOM_TYPE_ID: " + first);
      System.out.print(" Available_Room_Quantity" + last + "\n");
  }
  rs.close();
  </code></pre>
  
  <p>it have error when runnning time, both startdate and enddate declare as date in mysql.</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in
  your SQL syntax; check the manual that corresponds to your MySQL server version
  for the right syntax to use near '? AND END_DATE&gt;=? ) GROUP BY ROOM_TYPE_ID' at
  line 1
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
  at com.mysql.jdbc.Util.getInstance(Util.java:383)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1062)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)
  at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
  at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2783)
  at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1569)
  </code></pre>