This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Thank you very much. After a couple of hours my code for insertion datetime to database table is working fine.
I have searched many forums but i didn't get satisfactory solution but now according to your instruction changing prepStatement.setDate to prepStatement.setString is works fine.But i don't understand why i can't use prepStatement.setDate to store datetime to database ?
If you are always inserting current date/time in the field, then I would suggest you to use timestamp as datatype for database field and set default to CURRENT_TIMSTAMP. This way you don't have to insert any date/time from java, MySQL will take care of inserting current date time.