title: accepting date type command line argument in java
body: <p>There is this practice CRUD application I'm trying to write. It's an app to store contacts with birth date &amp; stuff. Since I'm using command line to accept input, &amp; storing this in HSQLDB database, I'm not sure how to accept a <code>Date</code> type argument. I tried parsing it to long from Sting, But it keeps throwing an <code>SQLDataException</code>.</p>
  
  <p>here r the lines of code that i use for this variable</p>
  
  <pre><code>//this in the class with main
  
      private Date dob;
  
      public Date getDob() {
      return dob;
          }
  
  
  
      public void setDob(Date dob) {
              this.dob = dob;
          }
  
      System.out.println("Enter date of birth of "+n+" in the format dd/mm/yyyy
      String date = sc2.nextLine();
      long d = Date.parse(date);
      uv.setDob(d);
  
  //class with all the business logic
  
  public void addContact(String cb, String name, long dob, String email, String phno, String tag) {
  sql = "insert into "+ cb + "(name,dob,email,phone,tag) values (?,?,?,?,?)";
   try {
      con = JDBCHelper.getConnection();
      ps1 = con.prepareStatement(sql);
      ps1.setString(1, name);
      ps1.setLong(2, dob);
      ps1.setString(3, email);
      ps1.setString(4,phno);
      ps1.setString(5, tag);
   }   
   catch(SQLException e) {
      e.printStackTrace();
   }
  
  }
  </code></pre>
  
  <p>exception it gives me on entering the date is</p>
  
  <pre><code>java.sql.SQLSyntaxErrorException: incompatible data type in conversion
          at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.Util.throwError(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.setParameter(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.setLongParameter(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.setLong(Unknown Source)
  Caused by: org.hsqldb.HsqlException: incompatible data type in conversion
      at org.hsqldb.error.Error.error(Unknown Source)
      at org.hsqldb.error.Error.error(Unknown Source)
      at org.hsqldb.types.DateTimeType.convertJavaToSQL(Unknown Source)
  </code></pre>