Setting year column from PreparedStatement give truncation exception
"Neil Aggarwal" <[email protected]> Mon, 12 Feb 2007 13:20:33 -0600
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Organization | JAMM Consulting, Inc. |
| Message-ID | <001a01c74eda$ddee2f80$0501a8c0@neilhp> |
Hello:
In my MySQL database, I have a column set as a YEAR type.
When I try to set the value from a prepared statement,
I get a truncation exception.
What is the proper way to set a year colum from a prepared
statement?
Here is my code:
public static final DateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy");
...
PreparedStatement ps = connection.prepareStatemnt(...);
ps.setDate(MY_YEAR_INDEX,new
java.sql.Date(YEAR_FORMAT.parse("2007").getTime());
When I do ps.executeUpdate, I get this exception:
java.sql.SQLException: Data truncated for column 'myYear' at row 1
Any ideas?
Thanks,
Neil
--
Neil Aggarwal, (214)986-3533, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/[email protected]