title: inserting datetimes into database using java
body: <p>I am wanting to insert a datetime into a MySql data base using Java and a prepared statement:</p>
  
  <pre><code>Calendar cal = Calendar.getInstance();
  PreparedStatement stmnt = db.PreparedStatement("INSERT INTO Run " +
                         "(Time) VALUE (?) ");
      stmnt.setDate(1, new java.sql.Date(cal.getTime()));
      stmnt.executeQuery();  
  </code></pre>
  
  <p>NOTE: there is currently an error - cannot find symbol (java.sql.Date) line 4 here</p>
  
  <p>db is an instance of a sort of wrapper class that exposes what I need from java.sql - its just getting a prepared statement from my connection object here.</p>
  
  <p>Time (the column) is a date time in my database, and I can only see setDate and setTime method but I want to store both - also my code does not work anyway ;-)</p>
  
  <p>If anyone could give me some pointers on inserting a combined date time (current time would be a great help as that's my first goal) into a MySql DB using a prepared statement I would be very grateful.</p>
  
  <p>Thanks</p>