I have taken a bit of the jRDC2 code from the b4J library and implemented it in my SQL handler.
The code is the stuff that converts a sql ResultSet to a DBResult Type
The DBResult Type is
The code is below.
This all works fine in B4J but when I try and use it in B4A I get an exception at line 3
The exception is:
java.lang.RuntimeException: Method: getMetaData not found in: android.database.sqlite.SQLiteCursor
The caught exception (Try/Catch) is (RuntimeException) java.lang.RuntimeException: Method: getMetaData not found in: android.database.sqlite.SQLiteCursor
The full log is at the end of this post.
Can anybody help me understand what is going wrong?
Thanks
Full Exception Log:
The code is the stuff that converts a sql ResultSet to a DBResult Type
The DBResult Type is
B4X:
Type DBResult ( _
Columns As Map, _
Rows As List, _
Cursor As Int, _
NoRows As Int)
The code is below.
This all works fine in B4J but when I try and use it in B4A I get an exception at line 3
B4X:
Dim rsmd As JavaObject = jrs.RunMethod("getMetaData", Null)
The exception is:
java.lang.RuntimeException: Method: getMetaData not found in: android.database.sqlite.SQLiteCursor
The caught exception (Try/Catch) is (RuntimeException) java.lang.RuntimeException: Method: getMetaData not found in: android.database.sqlite.SQLiteCursor
The full log is at the end of this post.
Can anybody help me understand what is going wrong?
Thanks
B4X:
Private Sub rs2DBResult(rs As ResultSet) As DBResult
Dim limit As Double = 10000
Dim jrs As JavaObject = rs
Dim rsmd As JavaObject = jrs.RunMethod("getMetaData", Null)
Dim cols As Int = rs.ColumnCount
Dim res As DBResult
res.Initialize
res.columns.Initialize
' res.Tag = Null 'without this the Tag properly will not be serializable.
For i = 0 To cols - 1
res.columns.Put(i,rs.GetColumnName(i).ToLowerCase)
Next
res.Rows.Initialize
Do While rs.NextRow And limit > 0
Dim row(cols) As Object
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("getObject", Array(i + 1))
End If
Next
res.Rows.Add(row)
Loop
res.Cursor = 0
res.NoRows = res.Columns.Size
Return res
End Sub
Full Exception Log:
Rich (BB code):
java.lang.RuntimeException: Method: getMetaData not found in: android.database.sqlite.SQLiteCursor
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:366)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at b4a.example.sqle._rs2dbresult(sqle.java:480)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7709)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Last edited: