Allora ho creato 2 app per fare la connessione, una usa solo la libreria MYSQL un altra usa la libreria ado, ma come vuole il buon dio, ogni tanto mi sfasa il cervello.
Java
Sub Process_Globals
End Sub
Sub Globals
' http://www.b4x.com/forum/additional-libraries-classes-official-updates/22291-mysql-library-jdbc.html#post129399
Dim Button1 As Button
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim db As MYSQL
Dim L As List
db.setDatabase("server","schema","user","password")
L = db.Query("Select * from t_000_schede")
If L.IsInitialized=False Then
Msgbox("Records Not Found","Warning")
Return
Else
For i = 0 To L.Size
ListView1.AddSingleLine(L.Get(i))
Next
End If
End Sub
Questa con ado
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
Dim AdoConn As AdoConnection
Dim AdoRec As AdoRecordset
Dim Result As Int
Dim ResultS As String
Dim Button1 As Button
Dim EditText1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
End Sub
Sub AdoConnectionError (Message As String, State As String, ErrorCode As Int)
Log("AdoConnectionError : " & CRLF & "Error message : " & Message & CRLF & "State : " & State & CRLF & "Error code : " & ErrorCode)
End Sub
Sub AdoRecordsetError (Message As String, State As String, ErrorCode As Int)
Log("AdoRecordsetError : " & CRLF & "Error message : " & Message & CRLF & "State : " & State & CRLF & "Error code : " & ErrorCode)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
AdoConn.ConnectionString("server","port"," UTF-8","schema","user","password")
AdoConn.ConnectionTimeout=1
AdoConn.LoginTimeout=1
AdoConn.SocketTimeout=1
AdoConn.InitializeEvent
AdoConn.Open
AdoRec.InitializeEvent
AdoRec.Connection=AdoConn
AdoRec.SqlStatement=EditText1.Text
AdoRec.Open
If AdoRec.isClosed Then
Msgbox("isClose","")
Else
Msgbox("mmmmm","")
End If
If AdoRec.RecordCount>0 Then
Do While Not(AdoRec.EOF)
Log(AdoRec.Field("a01"))
AdoRec.MoveNext
Loop
End If
Msgbox("Record " & AdoRec.MaxRecords,"")
AdoRec.Close
End Sub
Ricordo anche che nel manifesto deve essere messo questo... testo originale
This is my second library very similiar to MSSQL.
There are only three functions.
1) setDatabase("Server IPNUMBER (not name)","databasename","username","password")
2) Query("select * from tablename") --> return rows as a LIST
3) TableList --> return table names rows as a LIST.
You can also write create, update or delete queries.
You must copy MYSQL.jar, MYSQL.xml files to your addititonal library folder.
You should download jdbc driver from Mysql site:
Download jdbc driver
After you must copy mysql-connector-java-5.1.22-bin.jar file to your additional library folder.
You must add Manifest
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.ACCESS_NETWORK_S TATE")
Maybe you need to allow access to MySQL;
mysql> grant all privileges on *.* to root@'%' with grant option;
you can change username root to another one.
Fine testo originale Link
http://www.b4x.com/forum/additional...ates/22291-mysql-library-jdbc.html#post129399
Il risultato e sempre lo stesso nessun record, anzi sembra che non ci sia connessione, ma se faccio lo stesso con pocket desktop, quindi senza webservice tutto funziona (realStudio) in quanto il server mysql e aperto anche da accessi fuori localhost.
Chi vuole provare questi 2 codici e dirmi se funzionano, nel frattempo aspetto la risposta da register per vedere se non è una loro limitazione, anche se il messaggio di connessione avvenuta è "mmmmmmm" quindi ok.
Thank
Mi hanno risposto per questo cambiamento ma non trovo differenza
Once I changed the above line, it worked fine and displayed the data in the listview as it should. You might want to check the info you have in this line or permissions???? db.setDatabase("server ipnumber (not name)","databasename","username","password")