I have set up a mysql data base with this credentials
server
mysql.hostinger.ro
database
u348082479_sql
user
u348082479_hs
pass
m63hunter
created a table that looks in php my admin like this
id nume
1 Gabi
2 Alexandra
Here is the code i am using toghether with MSMysql ver 1.06 and javaobject
I have an error : Null pointer exception in sub MySQL_QueryResult(data As List, meta As Map)
Is the code correct ?
Is the database availlable for reading ? Thank you for your advice
server
mysql.hostinger.ro
database
u348082479_sql
user
u348082479_hs
pass
m63hunter
created a table that looks in php my admin like this
id nume
1 Gabi
2 Alexandra
Here is the code i am using toghether with MSMysql ver 1.06 and javaobject
I have an error : Null pointer exception in sub MySQL_QueryResult(data As List, meta As Map)
Is the code correct ?
Is the database availlable for reading ? Thank you for your advice
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#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.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim db As MySQL
Private lv1 As ListView
Private lbl1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
'db.Initialize("sql","host.com","dbuser","dbpassword","database")
db.Initialize("MySQL","mysql.hostinger.ro","u348082479_hs","m63hunter","u348082479_hs")
End Sub
Sub Activity_Resume
Log("Activity_Resume()")
'db.ListTablesAsync
'db.queryasync("select * from ufo_trainer LIMIT 0,1 ;")
db.QueryASync("Select * FROM `newsfeed` LIMIT 0,1;","")'login is the task id
' Dim batch As List
' batch.Initialize
' For i=1 To 100
' batch.Add("INSERT INTO b4alog SET log_value='Test"&i&"', log_time="&DateTime.Now&";")
' Next
'db.ExecuteBatchASync(batch)
'db.ExecuteASync("INSERT INTO b4alog SET log_value='only one query', log_time="&DateTime.Now&";","")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub MySQL_ExecResult(meta As Map)
Log(meta)
End Sub
Sub MySQL_BatchResult(batch As Map)
Log(batch)
End Sub
Sub MySQL_QueryResult(data As List, meta As Map)
ToastMessageShow("test",True)
'lv1.AddTwoLines("text1","text")
Dim m As Map = meta
' Log("MySQL_QueryResult("&meta&")")
'ToastMessageShow(meta.Get("RecordCount") & " rows retrieved in " & meta.Get("ms") & " milliseconds", True)
'
' Dim sb As StringBuilder
' sb.Initialize
'
For i=0 To data.Size-1
'Log("r:"&data.Get(i))
Dim COL As Map
COL=data.Get(i)
lv1.AddTwoLines(COL.Get("id"),COL.Get("nume"))
Next
End Sub
Sub MySQL_ListTables(tables As List, ms As Long)
Log("MySQL_ListTables("&ms&"ms)")
For i=0 To tables.Size-1
'Log("Table "&tables.Get(i))
Next
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
Last edited: