Android Question RDCJ2 Get date MSQL

luisro

Member
Licensed User
hi, i make the following query:

Select * from Table;

I have a blob, string and date.

in JRDC2 throw me this:

B4X:
(RuntimeException) java.lang.RuntimeException: Cannot serialize object: 2017-09-03

in in the app this:

B4X:
ResponseError. Reason: java.lang.RuntimeException: Cannot serialize object: 2017-09-03, Response: <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: 2017-09-03</pre></p>
<hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/>
</body>
</html>
Error: <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: 2017-09-03</pre></p>
<hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/>
</body>
</html>

look in all the forum but I do not find something clear regarding getting simple DATE

B4X:
Sub cargar
ProgressDialogHide
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "select"
reqManager.ExecuteQuery(cmd, 0, "select")
a = cmd.Name
End Sub

B4X:
Case "select"
            Dim result As DBResult = reqManager.HandleJob(job)
            For Each records() As Object In result.Rows
                Dim a8 As String
                a8 = records(result.Columns.get("fecha"))
                DateTime.DateFormat = "dd-MM-yyyy"
                Label13.Text = DateTime.Date(a8)
                clv1.Add(p,p.Height,"")
            Next

also edit this code config.properties:

B4X:
JdbcUrl=jdbc:mysql://localhost/dbventaskiana?zeroDateTimeBehavior=convertToNull
 
Last edited:

azzam223

Active Member
Licensed User
Longtime User
the problem is in date column you must change it type To date instead of datetime
 
Upvote 0

luisro

Member
Licensed User
Hi, sorry but I did not understand where I have to change the type? do you tell me in the database to change from Date to DateTime?
 
Upvote 0

luisro

Member
Licensed User
solved.

in config.properties, instead of:

sql.select=Select * from Table;

Use:

sql.select= SELECT `dat1`,`dat2`, DATE_FORMAT((date),'%d %m %Y') as 'date' FROM `Table`;

formatting the query directly to the date.

thanks for your help.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…