File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

truncation errors storing a Date in MySQL table

 
mat buckland
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a 'timestamp' field in a mysql table.

when I attempt to insert a Date into the table. Like this:


I get the error: Data truncation: Incorrect datetime value: 'Thu Oct 01 11:08:57 BST 2009'

I've tried changing the timestamp field to DATETIME, TIMESTAMP and DATE but to no avail.

What am I doing wrong?

thanks
 
Jan Cumps
Bartender
Posts: 2577
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a java.sql.PreparedStatement and set the time with setDateTime();

If you would print your sql statement before executing it, you would see why it fails. The value of currenTime is not what you expect.

Regards, Jan
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic