rwblinn Well-Known Member Licensed User Longtime User May 26, 2016 #1 Hi, whilst working on a B4J HowTo jRDC2 with MySQL running on a Raspberry Pi, experienced following error: In the MySQL database, defined the table 'notes': Code: Copy CREATE TABLE notes (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,description VARCHAR(50),content VARCHAR(255), created TIMESTAMP DEFAULT NOW()); When running query SELECT * FROM NOTES via Code: Copy Dim cmd As DBCommand cmd.Initialize 'Defined as sql.select=select * from notes in the jRDC2 file config.properties cmd.Name = "select" reqManager.ExecuteQuery(cmd, 0, Null) The result is an error related to the timestamp field named 'created' Code: Copy <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/> <title>Error 500 </title> </head> <body> <h2>HTTP ERROR: 500</h2> <p>Problem accessing /rdc. Reason: <pre> java.lang.RuntimeException: Cannot serialize object: 2016-05-26 11:32:18.0</pre></p> <hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/> </body> </html> HTTP Job Done: DBRequest, false Error: java.lang.RuntimeException: Cannot serialize object: 2016-05-26 11:32:18.0 No issues when running SELECT description,content FROM notes; Find test project attached. Attachments RDCClient-UI.zip RDCClient-UI.zip 3.1 KB · Views: 459
Hi, whilst working on a B4J HowTo jRDC2 with MySQL running on a Raspberry Pi, experienced following error: In the MySQL database, defined the table 'notes': Code: Copy CREATE TABLE notes (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,description VARCHAR(50),content VARCHAR(255), created TIMESTAMP DEFAULT NOW()); When running query SELECT * FROM NOTES via Code: Copy Dim cmd As DBCommand cmd.Initialize 'Defined as sql.select=select * from notes in the jRDC2 file config.properties cmd.Name = "select" reqManager.ExecuteQuery(cmd, 0, Null) The result is an error related to the timestamp field named 'created' Code: Copy <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/> <title>Error 500 </title> </head> <body> <h2>HTTP ERROR: 500</h2> <p>Problem accessing /rdc. Reason: <pre> java.lang.RuntimeException: Cannot serialize object: 2016-05-26 11:32:18.0</pre></p> <hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/> </body> </html> HTTP Job Done: DBRequest, false Error: java.lang.RuntimeException: Cannot serialize object: 2016-05-26 11:32:18.0 No issues when running SELECT description,content FROM notes; Find test project attached.
Erel B4X founder Staff member Licensed User Longtime User May 26, 2016 #2 You need to convert the timestamp value to a string or number in the query. For example: Code: Copy SELECT DATE_FORMAT(FROM_UNIXTIME(created),'%e %b %Y') AS 'date_formatted' FROM notes http://stackoverflow.com/questions/9251561/convert-timestamp-to-date-in-mysql-query Upvote 0
You need to convert the timestamp value to a string or number in the query. For example: Code: Copy SELECT DATE_FORMAT(FROM_UNIXTIME(created),'%e %b %Y') AS 'date_formatted' FROM notes http://stackoverflow.com/questions/9251561/convert-timestamp-to-date-in-mysql-query
rwblinn Well-Known Member Licensed User Longtime User May 26, 2016 #3 Thanks for the hint. This worked - defined in jRDC config.properties: Code: Copy sql.select=SELECT id,description,content, DATE_FORMAT(created,'%e %b %Y') AS 'Created' FROM notes Upvote 0
Thanks for the hint. This worked - defined in jRDC config.properties: Code: Copy sql.select=SELECT id,description,content, DATE_FORMAT(created,'%e %b %Y') AS 'Created' FROM notes