title: How to correctly set the current time stamp into this Java CRUD method that insert a value into a MySql table?
body: <p>I have the following table into a MySql database:</p>
  
  <pre><code>CREATE TABLE log(
      timestamp TIMESTAMP NOT NULL,
      action ENUM('addPerson', 'getPerson', 'getPeople', 'updatePerson', 'deletePerson', 'deleteAll') NOT NULL,
      PRIMARY KEY (timestamp)
  );
  </code></pre>
  
  <p>Now I am implementing a JAVA <strong>insert</strong> CRUD method into a DAO but I am finding some problem setting the <strong>timestamp</strong> value (initialized with the current date time) into the related prepared statment.</p>
  
  <p>So I am doing something like this:</p>
  
  <pre><code>public void addEntry(String message) throws SQLException {
      // The Connection object is a singleton and the used connection is the same for all the CRUD methods:
      Connection conn = Database.getInstance().getConnection();
  
      PreparedStatement p = conn.prepareStatement("insert into log (timestamp, action) values (?,?)");
  
      p.setTimestamp(1, new Timestamp(time));
  }
  </code></pre>
  
  <p>but it gime men error on the creation of the <strong>Timestamp</strong> object because it need a <strong>long</strong> value. So I think that this is not what I would !!!</p>
  
  <p>How can I set it to the current timestamp (the current date-time)?</p>
  
  <p>Tnx</p>