Hi all,
I have a "datetime" field MySQL table (called PERIOD).
I am using SmartGWT EE's builtin SQL backend.
The DS handling the table has set autoDeriveSchema=true,
so it automatically creates a DATETIME field in the DS.
I can read out the value of this field from record using
Record.getAttributeAsDate(), and it returns a valid java.util.Date object
with the proper content.
When I assign a Date to this field (by passing it in to ListGrid.startEditingNew as a default value), the date is displayed properly.
When I try to save the record, the validation succeeds, but the SQL server throws an MysqlDataTruncation exception.
The generated SQL command is this:
INSERT INTO fundamental_data_records (DATA_ID, VALUE, PERIOD) VALUES ('167', '34', 'Wed Apr 01 00:00:00 GMT+01:00 2009')
The exception is this:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: 'Wed Apr 01 00:00:00 GMT+01:00 2009' for column 'PERIOD' at row 1
What am I doing wrong?
* * *
If I create an SQL dump from this table, the values of the existing fields are returned in the following format: "yyyy-mm-dd hh:mm:ss" (this is not a syntactically correct date format string, just an indication of the format), which happens to be the correct textaul representation of dates for my locale.
Could this be a locale problem? (MySQL sends and expects dates in the local locale, but the SmartGWT server sends the date in some standard format, which the MySQL server refuses?)
* * *
By the way, I do not really need the time part of the field, only the date is important, so I can transfer to a time-less date type (at any level) is necessary.
Do you have any advice?
Thank you for your help!
I have a "datetime" field MySQL table (called PERIOD).
I am using SmartGWT EE's builtin SQL backend.
The DS handling the table has set autoDeriveSchema=true,
so it automatically creates a DATETIME field in the DS.
I can read out the value of this field from record using
Record.getAttributeAsDate(), and it returns a valid java.util.Date object
with the proper content.
When I assign a Date to this field (by passing it in to ListGrid.startEditingNew as a default value), the date is displayed properly.
When I try to save the record, the validation succeeds, but the SQL server throws an MysqlDataTruncation exception.
The generated SQL command is this:
INSERT INTO fundamental_data_records (DATA_ID, VALUE, PERIOD) VALUES ('167', '34', 'Wed Apr 01 00:00:00 GMT+01:00 2009')
The exception is this:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: 'Wed Apr 01 00:00:00 GMT+01:00 2009' for column 'PERIOD' at row 1
What am I doing wrong?
* * *
If I create an SQL dump from this table, the values of the existing fields are returned in the following format: "yyyy-mm-dd hh:mm:ss" (this is not a syntactically correct date format string, just an indication of the format), which happens to be the correct textaul representation of dates for my locale.
Could this be a locale problem? (MySQL sends and expects dates in the local locale, but the SmartGWT server sends the date in some standard format, which the MySQL server refuses?)
* * *
By the way, I do not really need the time part of the field, only the date is important, so I can transfer to a time-less date type (at any level) is necessary.
Do you have any advice?
Thank you for your help!
Comment