Italian Connessione FireBird

daniweb78

Member
Salve a tutti.
Sto provando a collegare la mia app ad un database presente in un pc nella stessa rete.
La mia configurazione è questa nello starter:
-----------------------------------
Sub Process_Globals
Public mysql As JdbcSQL
Private driver As String = "org.firebirdsql.jdbc.FBDriver"
Private jdbcUrl As String = "jdbc:firebirdsql://192.168.1.226:3050/C:\DRSOFTFB\NISI\DBS\ARC\NISI.FDB"
Private Username As String = "SYSDBA"
Private Password As String = "masterkey"
End Sub

Sub Service_Create
'need to disable it as reading from large JdbcResultSet will cause network requests to be sent on the main thread.
DisableStrictMode
End Sub

Sub Service_Start (StartingIntent As Intent)

End Sub

Sub DisableStrictMode
Dim jo As JavaObject
jo.InitializeStatic("android.os.Build.VERSION")
If jo.GetField("SDK_INT") > 9 Then
Dim policy As JavaObject
policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
policy = policy.RunMethodJO("permitAll", Null).RunMethodJO("build", Null)
Dim sm As JavaObject
sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
End If
End Sub

Sub Connect As ResumableSub
mysql.Initialize2(driver, jdbcUrl, Username, Password)
Wait For MySQL_Ready (Success As Boolean)
If Success = False Then
Log("Check unfiltered logs for JDBC errors.")
End If
Return Success
End Sub

Sub CloseConnection
mysql.Close
End Sub

Sub ListAnimals As ResumableSub
Wait For (Connect) Complete (Success As Boolean)
If Success Then
Try
Dim sf As Object = mysql.ExecQuery("SELECT CODICE, DESCRIZIONE FROM ART ")
Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Do While Crsr.NextRow
Log($"codice: ${Crsr.GetInt("codice")}, Name: ${Crsr.GetString("DESCRIZIONE")}"$)
Loop
Crsr.Close
End If
Catch
Success = False
Log(LastException)
End Try
CloseConnection
End If
Return Success
End Sub

Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub

------------
quando provo a collegarmi nel db ho questo errore :

Logger connesso a: samsung GT-I9295
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 36 (Starter)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.keywords.Common.CallSubDebug(Common.java:1050)
at b4a.example3.main$ResumableSub_Activity_Click.resume(main.java:413)
at b4a.example3.main._activity_click(main.java:387)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
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 java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5197)
at android.view.View$PerformClick.run(View.java:20926)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew(Debug.java:282)
... 26 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 27 more
Caused by: java.lang.RuntimeException: Class not found: org.firebirdsql.jdbc.FBDriver
Are you missing an #AdditionalJar attribute setting?
at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:54)
at b4a.example3.starter$ResumableSub_Connect.resume(starter.java:370)
at b4a.example3.starter._connect(starter.java:346)
at b4a.example3.starter$ResumableSub_ListAnimals.resume(starter.java:168)
at b4a.example3.starter._listanimals(starter.java:140)
... 30 more
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 36 (Starter)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.keywords.Common.CallSubDebug(Common.java:1050)
at b4a.example3.main$ResumableSub_Activity_Click.resume(main.java:413)
at b4a.example3.main._activity_click(main.java:387)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
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 java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5197)
at android.view.View$PerformClick.run(View.java:20926)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew(Debug.java:282)
... 26 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 27 more
Caused by: java.lang.RuntimeException: Class not found: org.firebirdsql.jdbc.FBDriver
Are you missing an #AdditionalJar attribute setting?
at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:54)
at b4a.example3.starter$ResumableSub_Connect.resume(starter.java:370)
at b4a.example3.starter._connect(starter.java:346)
at b4a.example3.starter$ResumableSub_ListAnimals.resume(starter.java:168)
at b4a.example3.starter._listanimals(starter.java:140)
... 30 more
----------------

qualcuno mi puo aiutare.... ??
 

amorosik

Expert
Licensed User
Private jdbcUrl As String = "jdbc:firebirdsql://192.168.1.226:3050/C:/DRSOFTFB/NISI/DBS/ARC/NISI.FDB"

e prima dentro il Project Attributes

#AdditionalJar: jaybird-full-4.0.0.java8.jar
'#AdditionalJar: jaybird-full-4.0.2.java11.jar

vedi tu quale delle due funziona
 

daniweb78

Member
Private jdbcUrl As String = "jdbc:firebirdsql://192.168.1.226:3050/C:/DRSOFTFB/NISI/DBS/ARC/NISI.FDB"

e prima dentro il Project Attributes

#AdditionalJar: jaybird-full-4.0.0.java8.jar
'#AdditionalJar: jaybird-full-4.0.2.java11.jar

vedi tu quale delle due funziona
non trovo nessuna delle due.. hai modo di mandarmele ?
io ho queste:
jaybird-full-4.0.3.java8.jar
jaybird-full-4.0.0.java11.jar

ma non funziona
 

daniweb78

Member
con jaybird-full-4.0.3.java8.jar ho questo errore :

Compilazione del codice Java prodotto. (0.00s)
Conversione byte code - ottimizzazione dex. Error
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2 errors; aborting
 

amorosik

Expert
Licensed User
Ah, non avevo capito fosse connessione diretta da app Android a db su pc
Pensavo stessi parlando di programma B4j, per il quale ho inviato consiglio precedente
Connessione diretta da app a db non l'ho mai usata, non saprei come aiutarti
Sorry
Ti consiglierei comunque di usare il sistema JRdc2 che assicura migliore protezione dei dati da disconnessioni o simile
 

Star-Dust

Expert
Licensed User
Longtime User
Prova questo, qualcuno sembra sia riuscito con il mio codice


 

amorosik

Expert
Licensed User
Si, provato, seguendo l'esempio di Star-Dust funziona correttamente anche direttamente da app Android a db server Firebird

B4X:
#Region  Project Attributes
    #ApplicationLabel: SQL
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'MySQL Connector/J Driver
#AdditionalJar: mysql-connector-java-5.1.47-bin.jar

'MSSQL Connector/J Driver
#AdditionalJar: jtds-1.3.1.jar

'FIREBIRD Connector/J Driver
#AdditionalJar:  Jaybird_2_2_12.aar

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim MYSQL As SD_SQL
    Private MSLocation As String = "address"
    Private MSUsername As String = "User"
    Private MSPassword As String = "Password"
   
    Dim MSSQL As SD_SQL
    Private MyLocation As String = "address"
    Private MyUsername As String = "User"
    Private MyPassword As String = "Password"

    Dim FBSQL As SD_SQL
    Private FBUsername As String = "SYSDBA"
    Private FBPassword As String = "masterkey"
    Private driver As String = "org.firebirdsql.jdbc.FBDriver"
    Private jdbcUrl As String = "jdbc:firebirdsql://192.168.1.1:3050/C:/FIREBIRD_DATA/CIUCCIA_MARIUCCIA.FDB"
    Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private ListViewMs As ListView
    Private ListViewMy As ListView
    Private ListViewFirebird As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
   
'    Log("---------- NorthWind Database (MSSQL) ----------")
'    MSSQL.Initialize(Me,"MSSQL","net.sourceforge.jtds.jdbc.Driver", $"jdbc:jtds:sqlserver://${MSLocation}/test"$, MSUsername, MSPassword)

'    Sleep(100)

'    Log("---------- NorthWind Database (MySQL) ----------")
'    MYSQL.Initialize(Me,"MYSQL", "com.mysql.jdbc.Driver", $"jdbc:mysql://${MyLocation}/register_Northwind_MySQL?useSSL=false"$,  MyUsername, MyPassword)

'    Sleep(100)

    Log("---------- Firebird Database (MySQL) ----------")
    FBSQL.Initialize(Me,"FBSQL", driver,jdbcUrl, FBUsername, FBPassword)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

'Connected to MySQL Server
Sub MYSQL_Ready (Success As Boolean)
    ListViewMy.SingleLineLayout.Label.TextColor=Colors.Black
    ListViewMy.SingleLineLayout.Label.Textsize=13
    ListViewMy.Clear
    If Success Then
        Dim RS As SD_ResultSet = MYSQL.ExecQuery("SHOW TABLES")
        Do While RS.NextRow
            ListViewMy.AddSingleLine(RS.GetString2(0))
        Loop
        RS.Close
    End If
End Sub

'Connected to MS SQL Server
Sub MSSQL_Ready (Success As Boolean)
    ListViewMs.SingleLineLayout.Label.TextColor=Colors.Black
    ListViewMs.SingleLineLayout.Label.Textsize=13
    ListViewMs.Clear
    If Success Then
        Dim RS As SD_ResultSet = MSSQL.ExecQuery("SELECT * FROM SYS.TABLES")
        Do While RS.NextRow
            ListViewMs.AddSingleLine(RS.GetString2(0))
        Loop
    End If
End Sub


'Connected to FIREBIRD Server
Sub FBSQL_Ready (Success As Boolean)
    ListViewFirebird.SingleLineLayout.Label.TextColor=Colors.Black
    ListViewFirebird.SingleLineLayout.Label.Textsize=13
    ListViewFirebird.Clear
    Dim count As Long
    If Success Then
        Dim RS As SD_ResultSet = FBSQL.ExecQuery("SELECT CODICE_INTERNO, DESCRIZIONE from ARTICOLI")
        Do While RS.NextRow
            count=count+1
            If count>100 Then Exit
            Log("Count = " & count & "   " & RS.GetString2(0) & "   " & RS.GetString2(1))
            ListViewFirebird.AddSingleLine(RS.GetString2(0)& "   " & RS.GetString2(1))
        Loop
    End If
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Si, provato, seguendo l'esempio di Star-Dust funziona correttamente anche direttamente da app Android a db server Firebird

B4X:
#Region  Project Attributes
    #ApplicationLabel: SQL
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'MySQL Connector/J Driver
#AdditionalJar: mysql-connector-java-5.1.47-bin.jar

'MSSQL Connector/J Driver
#AdditionalJar: jtds-1.3.1.jar

'FIREBIRD Connector/J Driver
#AdditionalJar:  Jaybird_2_2_12.aar

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim MYSQL As SD_SQL
    Private MSLocation As String = "address"
    Private MSUsername As String = "User"
    Private MSPassword As String = "Password"
 
    Dim MSSQL As SD_SQL
    Private MyLocation As String = "address"
    Private MyUsername As String = "User"
    Private MyPassword As String = "Password"

    Dim FBSQL As SD_SQL
    Private FBUsername As String = "SYSDBA"
    Private FBPassword As String = "masterkey"
    Private driver As String = "org.firebirdsql.jdbc.FBDriver"
    Private jdbcUrl As String = "jdbc:firebirdsql://192.168.1.1:3050/C:/FIREBIRD_DATA/CIUCCIA_MARIUCCIA.FDB"
    Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private ListViewMs As ListView
    Private ListViewMy As ListView
    Private ListViewFirebird As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
 
'    Log("---------- NorthWind Database (MSSQL) ----------")
'    MSSQL.Initialize(Me,"MSSQL","net.sourceforge.jtds.jdbc.Driver", $"jdbc:jtds:sqlserver://${MSLocation}/test"$, MSUsername, MSPassword)

'    Sleep(100)

'    Log("---------- NorthWind Database (MySQL) ----------")
'    MYSQL.Initialize(Me,"MYSQL", "com.mysql.jdbc.Driver", $"jdbc:mysql://${MyLocation}/register_Northwind_MySQL?useSSL=false"$,  MyUsername, MyPassword)

'    Sleep(100)

    Log("---------- Firebird Database (MySQL) ----------")
    FBSQL.Initialize(Me,"FBSQL", driver,jdbcUrl, FBUsername, FBPassword)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

'Connected to MySQL Server
Sub MYSQL_Ready (Success As Boolean)
    ListViewMy.SingleLineLayout.Label.TextColor=Colors.Black
    ListViewMy.SingleLineLayout.Label.Textsize=13
    ListViewMy.Clear
    If Success Then
        Dim RS As SD_ResultSet = MYSQL.ExecQuery("SHOW TABLES")
        Do While RS.NextRow
            ListViewMy.AddSingleLine(RS.GetString2(0))
        Loop
        RS.Close
    End If
End Sub

'Connected to MS SQL Server
Sub MSSQL_Ready (Success As Boolean)
    ListViewMs.SingleLineLayout.Label.TextColor=Colors.Black
    ListViewMs.SingleLineLayout.Label.Textsize=13
    ListViewMs.Clear
    If Success Then
        Dim RS As SD_ResultSet = MSSQL.ExecQuery("SELECT * FROM SYS.TABLES")
        Do While RS.NextRow
            ListViewMs.AddSingleLine(RS.GetString2(0))
        Loop
    End If
End Sub


'Connected to FIREBIRD Server
Sub FBSQL_Ready (Success As Boolean)
    ListViewFirebird.SingleLineLayout.Label.TextColor=Colors.Black
    ListViewFirebird.SingleLineLayout.Label.Textsize=13
    ListViewFirebird.Clear
    Dim count As Long
    If Success Then
        Dim RS As SD_ResultSet = FBSQL.ExecQuery("SELECT CODICE_INTERNO, DESCRIZIONE from ARTICOLI")
        Do While RS.NextRow
            count=count+1
            If count>100 Then Exit
            Log("Count = " & count & "   " & RS.GetString2(0) & "   " & RS.GetString2(1))
            ListViewFirebird.AddSingleLine(RS.GetString2(0)& "   " & RS.GetString2(1))
        Loop
    End If
End Sub
Io ho fatto solo la libreria, non sapevo funzionasse con FireBird che fra l'altro nemmeno conoscevo. Però qualcuno ha provato con i Driver e sembra funzioni. io non ho colpe ne meriti
 

amorosik

Expert
Licensed User
Io ho fatto solo la libreria, non sapevo funzionasse con FireBird che fra l'altro nemmeno conoscevo. Però qualcuno ha provato con i Driver e sembra funzioni. io non ho colpe ne meriti

C'e' poco da fare lo sborone
E' sicuramente un caso fortuito
Adesso il codice e' pubblicato, puoi tranquillamente perdere i sorgenti 😁😆🤣
 

Star-Dust

Expert
Licensed User
Longtime User
C'e' poco da fare lo sborone
E' sicuramente un caso fortuito
Adesso il codice e' pubblicato, puoi tranquillamente perdere i sorgenti 😁😆🤣
E' fortuito si. Manco sapevo che c'era un DataBase con questo nome :p :p :p
 

Star-Dust

Expert
Licensed User
Longtime User

Star-Dust

Expert
Licensed User
Longtime User

Star-Dust

Expert
Licensed User
Longtime User
Pure questa del codice copiato?
Ehhhh ma le mettiamo tutte in fila, mica si dimentica niente qua
A ognuno il suo merito, i meriti non si rubano. Il codice è del grande Peter sviluppato per B4J, io ho solo adattato al B4A e ho fatto un involucro (wrap), ma il lavoro sporco lo ha fatto lui.
 

daniweb78

Member
Salve a tutti ragazzi ho provato a collegarmi al db ma restituisce questi errori :
Logger connesso a: samsung GT-I9295
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
---------- Firebird Database (MySQL) ----------
connected
** Activity (main) Resume **
Error occurred on line: 74 (SD_ResultSet)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at b4a.example.sd_resultset._getstring2(sd_resultset.java:60)
at b4a.example.main._fbsql_ready(main.java:479)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
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 java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: org.firebirdsql.jdbc.FBSQLException: Invalid column index.
at org.firebirdsql.jdbc.AbstractResultSet.getField(AbstractResultSet.java:678)
at org.firebirdsql.jdbc.AbstractResultSet.getField(AbstractResultSet.java:656)
at org.firebirdsql.jdbc.AbstractResultSet.getString(AbstractResultSet.java:596)
... 22 more

qualcuno mi può aiutare ?

ecco il codice:
#Region Project Attributes
#ApplicationLabel: SQL
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

'FIREBIRD Connector/J Driver
#AdditionalJar: Jaybird_2_2_12.aar

#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region

Sub Process_Globals
Dim FBSQL As SD_SQL
Private FBUsername As String = "SYSDBA"
Private FBPassword As String = "masterkey"
Private driver As String = "org.firebirdsql.jdbc.FBDriver"
Private jdbcUrl As String = "jdbc:firebirdsql://192.168.1.116:3050/C:/DRSOFTFB/NISI/DBS/ARC/NISI.FDB"
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
Private ListViewFirebird As ListView
Private Collega As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
Log("---------- Firebird Database (MySQL) ----------")
FBSQL.Initialize(Me,"FBSQL", driver,jdbcUrl, FBUsername, FBPassword)
ListViewFirebird.Initialize(True)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

'Connected to FIREBIRD Server
Sub FBSQL_Ready (Success As Boolean)
ListViewFirebird.SingleLineLayout.Label.TextColor=Colors.Black
ListViewFirebird.SingleLineLayout.Label.Textsize=13
ListViewFirebird.Clear
Dim count As Long
If Success Then
Dim RS As SD_ResultSet = FBSQL.ExecQuery("SELECT CODICE FROM ART")
Do While RS.NextRow
count=count+1
If count>100 Then Exit
Log("Count = " & count & " " & RS.GetString2(0) & " " & RS.GetString2(1))
ListViewFirebird.AddSingleLine(RS.GetString2(0)& " " & RS.GetString2(1))
Loop
End If
End Sub

Sub Collega_Click
FBSQL_Ready(True)
End Sub
 

daniweb78

Member
è cambiato qualcosa adesso ho questo errore:

Logger connesso a: samsung GT-I9295
--------- beginning of system
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
---------- Firebird Database (MySQL) ----------
connected
** Activity (main) Resume **
Error occurred on line: 74 (SD_ResultSet)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at b4a.example.sd_resultset._getstring2(sd_resultset.java:60)
at b4a.example.main._fbsql_ready(main.java:465)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
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 java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: org.firebirdsql.jdbc.FBSQLException: Invalid column index.
at org.firebirdsql.jdbc.AbstractResultSet.getField(AbstractResultSet.java:678)
at org.firebirdsql.jdbc.AbstractResultSet.getField(AbstractResultSet.java:656)
at org.firebirdsql.jdbc.AbstractResultSet.getString(AbstractResultSet.java:596)
... 22 more
 

amorosik

Expert
Licensed User
Dim RS As SD_ResultSet = FBSQL.ExecQuery("SELECT CODICE FROM ART")
Do While RS.NextRow
count=count+1
If count>100 Then Exit
Log("Count = " & count & " " & RS.GetString2(0) & " " & RS.GetString2(1))
ListViewFirebird.AddSingleLine(RS.GetString2(0)& " " & RS.GetString2(1))
Loop

Le righe istruzioni mettile nei post come 'codice' si capisce meglio
Inoltre non indichi a che riga avviene il problema, vedo un 74 ma non e' univoca l'indicazione, perche' nell'ide vengono numerate anche gli spazi vuoti
Nella select estrai un solo valore
Nelle GetString2 cerchi di leggere anche un secondo campo RS.GetString2(1)
Puo' essere questo il problema?
 
Top