Storing Date in MySQL database

Hello, I'm trying to store a datetime field in my SQL database.

I did a little forum reading and decided to use a prepared statement.

Code Snippet:

java.util.Date givenJ=new java.util.Date();

java.sql.Date given=new java.sql.Date(givenJ.getTime());

PreparedStatement pst;

pst=sqlConnection.prepareStatement("INSERT into taxilogdb (timegiven,location) values (?,?)");

pst.setDate(1,given);

pst.setString(2,location);

pst.executeUpdate();

The statement will run and compile, but when I try to retreive the data from the database , the date is correct, but the time always is 12:00:00. (Jun 22, 2007 12:00:00 AM). How can I remedy this issue? Any help would be greatly appreciated. Thanks!

Message was edited by:

Jensenrya

I suppose I should add that I want I'm trying to do... I would like to store the time info as well. The column in the MySQL database is defined as datetime. Thanks

[1062 byte] By [Jensenryaa] at [2007-11-27 8:35:08]
# 1
Use TimeStamp rather than java.sql.Date since java.sql.Date has the time part removed.
sabre150a at 2007-7-12 20:31:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Thank you. That worked.
Jensenryaa at 2007-7-12 20:31:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...