B4J Question [WORKAROUNDed] How to get the DATA TYPE from MySQL using JRDC2

roerGarcia

Active Member
Licensed User
Longtime User
config.properties:
sql.showt = SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_KEY FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'oca'

returns

returned values:
ctas, id, [B@672264ee, NO, null, PRI,
ctas, ctaN5, [B@46958a75, NO, null, ,

How to get "Int" from [B@672264ee ?
 
Last edited:

roerGarcia

Active Member
Licensed User
Longtime User
According to the following list

SQL Data Types:
Constant Field    Value
LONGNVARCHAR    -16
NCHAR    -15
NVARCHAR    -9
ROWID    -8
BIT    -7
TINYINT    -6
BIGINT    -5
LONGVARBINARY    -4
VARBINARY    -3
BINARY    -2
LONGVARCHAR    -1
NULL    0
CHAR    1
NUMERIC    2
DECIMAL    3
INTEGER    4
SMALLINT    5
FLOAT    6
REAL    7
DOUBLE    8
VARCHAR    12
BOOLEAN    16
DATALINK    70
DATE    91
TIME    92
TIMESTAMP    93
OTHER    1111
JAVA_OBJECT    2000
DISTINCT    2001
STRUCT    2002
ARRAY    2003
BLOB    2004
CLOB    2005
REF    2006
SQLXML    2009
NCLOB    2011
REF_CURSOR    2012
TIME_WITH_TIMEZONE    2013
TIMESTAMP_WITH_TIMEZONE    2014

and according to the source code of the rcdhandler
RDCHandler:
        For i = 0 To cols - 1
            Dim ct As Int = rsmd.RunMethod("getColumnType", Array(i + 1))
            'check whether it is a blob field
            If ct = -2 Or ct = 2004 Or ct = -3 Or ct = -4 Then
                row(i) = rs.GetBlob2(i)
            Else if ct = 2 Or ct = 3 Then
                row(i) = rs.GetDouble2(i)
            Else If DateTimeMethods.ContainsKey(ct) Then
                Dim SQLTime As JavaObject = jrs.RunMethodJO(DateTimeMethods.Get(ct), Array(i + 1))
                If SQLTime.IsInitialized Then
                    row(i) = SQLTime.RunMethod("getTime", Null)
                Else
                    row(i) = Null
                End If
            Else
                row(i) = jrs.RunMethod("[B]getObject[/B]", Array(i + 1))
            End If   
        Next

getObject is used if it is neither double nor date; (separates -2, -3, -4, 2004 as blob; 2 and 3 as doubles; dates and rest are getObject). the values that are returned as LONGVARBINARY do not have a special handling, when in mySql you have unsigned Integer the rcdhandler returns an object.

changing the query from DATA_TYPE to COLUMN_TYPE partially solves the problem returning "int usigned" as a string literal.

So far my report.
 
Upvote 0
Top