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

