I have a JDBC current date and time insert into Mysql Database.
It submits the current date and a fixed time into the Mysql date type field as 2012/05/25 00:00:00
. The date part works very fine but the time doesn't shows any value.
I'm inserting the value with the following code:
java.util.Date myDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(myDate.getTime());
PreparedStatement PStmt = con.prepareStatement(Sql query);
PStmt.setDate(1,sqlDate);
java.sql.Date sqlDate = new java.sql.Date(myDate.getTime());
PreparedStatement PStmt = con.prepareStatement(Sql query);
PStmt.setDate(1,sqlDate); – Narayan May 25 '12 at 10:26