Android Question Remote data connection with Firebird, how to passing date value

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I am trying to use RDC with Firebird, but got error from Firebird JDBC when trying to pass date type value type via execquery command.

My select SQL in config file is like this :
sql.select_tbl=Select * from table where field1=?

field1 is a date type field.
Trying to declared
Dim Dt as string = "1/1/13" or
Dim Dt as long = SetDate(2013,1,1)

got error from Firebird JDBC when passed to execquery.

As you know, Firebird treat date type in a
format mm/dd/yy.

Any hints?
 

incendio

Well-Known Member
Licensed User
Longtime User
Can you post the error message?

Here are the error messages :

Calling with Dim Dt As Long = DateUtils.SetDate(13, 1, 1)
====================================
LogCat connected to: 015d490650481a03
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main

** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **

org.firebirdsql.jdbc.field.TypeConversionException: Error converting to long.
Error: Server Error


Calling with
Dim Dt As String = "1/31/13" or String = "13/1/31" or String = "31/1/13"
===============================================
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **

java.sql.SQLException: An SQLException was provoked by the following failure: java.lang.IllegalArgumentException
Error: Server Error

Codes to call execquery
B4X:
Sub ExecQ(Tag As String)
    Dim cmd As DBCommand
    cmd.Initialize
   
    If(Tag = "Stock") Then
        Private Div,Cnd As String
        'Dim Dt As Long = DateUtils.SetDate(13, 1, 1)
        Dim Dt As String = "13/1/31"               
        Div = "6"
        Cnd = "Good"
        cmd.Name = "select_stock"   
        cmd.Parameters = Array As Object(Div,Dt,Cnd)
        reqManager.ExecuteQuery(cmd, 0, Tag)
    End If   
End Sub
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
You should use a string. However it should be formatted correctly: http://www.firebirdsql.org/en/firebird-date-literals/

Thanks for your replay.

I just saw source code at DBRequestMan, if not mistaken, it seem that this lib is not support date type, so I guest not only Firebird, other SQL database will be affected by this lack.

Btw, I have tried all formatted date as suggested on that link, none is work.
 
Last edited:
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
Yes, that true, date is not basic type in Java, but somehow, Firebird JDBC manage to intercept it and pass correct value to Firebird Server.

I think, this is almost the same situation as in webview case, have to modify DBRequestMan to accept date type and pass it to JDBC.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
Thanks for your replied.

Yeah, it could be like that, or in my case, since I am calling a stored procedure, casting is process within stored procedure.

Still testing in select,insert or update for Firebird, since Time or Timestamp also is not supported in DBRequestMan.
 
Upvote 0
Top