Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Main")
' Event Database Host Username Password Databasename
'db.Initialize("sql","host.com","dbuser","dbpassword","database")
' Manfred
db.Initialize("MySQL","host","user","password","database")
db.ListTablesAsync
Dim j As HttpJob
j.Initialize("JobName",Me)
j.Download("http://snapshots.basic4android.de")
End Sub
Sub Activity_Resume
Log("Activity_Resume()")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub MySQL_ExecResult(meta As Map)
Log(meta)
End Sub
Sub MySQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int)
Log($"MySQL_Status(${Connected},${ReConnecting},${RetriesLeft})"$)
End Sub
Sub MySQL_ListTables(tables As List, ms As Long)
Log($"MySQL_ListTables(${tables},${ms} ms)"$)
End Sub
Sub JobDone(Job As HttpJob)
Log("JobDone("&Job.JobName&")")
ProgressDialogHide
If Job.Success Then
'Dim res As String = Job.GetString
'Log("Server response: " & res)
Else
ToastMessageShow("Error: " & Job.ErrorMessage,True)
End If
Job.Release
End Sub
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Raising.. mysql_status
Connected to Database
** Activity (main) Resume **
Activity_Resume()
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (mysql_status)
sending message to waiting queue (mysql_listtables)
** Service (httputils2service) Create **
** Service (httputils2service) Start **
running waiting messages (2)
MySQL_Status(true,false,0)
MySQL_ListTables([Alphabetical list of products, Categories, Category Sales for 1997, Current Product List, Customer and Suppliers by City, CustomerCustomerDemo, CustomerDemographics, Customers, EmployeeTerritories, Employees, Invoices, Order Details, Order Details Extended, Order Subtotals, Orders, Orders Qry, Product Sales for 1997, Products, Products Above Average Price, Products by Category, Quarterly Orders, Region, Sales Totals by Amount, Sales by Category, Shippers, Summary of Sales by Quarter, Summary of Sales by Year, Suppliers, Territories, b4alibs, b4alog, b4j_users, invoices],69 ms)
** Activity (main) Resume **
Activity_Resume()
JobDone(JobName)
Mhhh... ok i send you code this evening . Thank you for nowB4X:Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: 'Activity.LoadLayout("Main") ' Event Database Host Username Password Databasename 'db.Initialize("sql","host.com","dbuser","dbpassword","database") ' Manfred db.Initialize("MySQL","host","user","password","database") db.ListTablesAsync Dim j As HttpJob j.Initialize("JobName",Me) j.Download("http://snapshots.basic4android.de") End Sub Sub Activity_Resume Log("Activity_Resume()") End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub MySQL_ExecResult(meta As Map) Log(meta) End Sub Sub MySQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int) Log($"MySQL_Status(${Connected},${ReConnecting},${RetriesLeft})"$) End Sub Sub MySQL_ListTables(tables As List, ms As Long) Log($"MySQL_ListTables(${tables},${ms} ms)"$) End Sub Sub JobDone(Job As HttpJob) Log("JobDone("&Job.JobName&")") ProgressDialogHide If Job.Success Then 'Dim res As String = Job.GetString 'Log("Server response: " & res) Else ToastMessageShow("Error: " & Job.ErrorMessage,True) End If Job.Release End Sub
Works!
B4X:Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: 'Activity.LoadLayout("Main") ' Event Database Host Username Password Databasename 'db.Initialize("sql","host.com","dbuser","dbpassword","database") ' Manfred db.Initialize("MySQL","host","user","password","database") db.ListTablesAsync Dim j As HttpJob j.Initialize("JobName",Me) j.Download("http://snapshots.basic4android.de") End Sub Sub Activity_Resume Log("Activity_Resume()") End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub MySQL_ExecResult(meta As Map) Log(meta) End Sub Sub MySQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int) Log($"MySQL_Status(${Connected},${ReConnecting},${RetriesLeft})"$) End Sub Sub MySQL_ListTables(tables As List, ms As Long) Log($"MySQL_ListTables(${tables},${ms} ms)"$) End Sub Sub JobDone(Job As HttpJob) Log("JobDone("&Job.JobName&")") ProgressDialogHide If Job.Success Then 'Dim res As String = Job.GetString 'Log("Server response: " & res) Else ToastMessageShow("Error: " & Job.ErrorMessage,True) End If Job.Release End Sub
Works!
Due to the fact that the lib is using Andrid Async-Tasks it will not work on b4j
i dont know how to do this in b4j
you cn easily use the jSQL library to connect to a remote db with b4jThanks anyway
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim sql1 As SQL
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNIFIED")
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
sql1.InitializeAsync("sql1", "com.mysql.jdbc.Driver", "jdbc:mysql://hostname/dbname?characterEncoding=utf8", "username", "dbpassword")
MainForm.Show
End Sub
Sub sql1_Ready (Success As Boolean)
Log(Success)
If Success = False Then
Log(LastException)
Return
End If
Dim rs As ResultSet = sql1.ExecQuery("SELECT table_name FROM information_schema.tables")
Do While rs.NextRow
Log(rs.GetString2(0))
Loop
rs.Close
End Sub
Hey Don, what are you using to display the table, are you using the FlexibleTable class?
Yes it's the flexi table Class.Hey Don, what are you using to display the table, are you using the FlexibleTable class?
Thanks jahswani, yes i know, i'm just asking because i like how it looks.Yes it's the flexi table Class.
Note that this not part of this library.
Sub Create_Table
TblInvList.Initialize(Me, "TblInvList", 5, Gravity.CENTER_HORIZONTAL, True)
TblInvList.AddToActivity(PnlTable, 0dip, 0dip, PnlTable.Width, PnlTable.Height)
TblInvList.SetHeader(Array As String("Name", "Continent", "Region", "Population", "Local Name"))
TblInvList.SetColumnsWidths(Array As Int(20%x, 20%x, 20%x, 12%x, 28%x))
TblInvList.SetCellAlignments(Array As Int (Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)))
End Sub
Sub Populate_Table
If ResultList.IsInitialized = False Then
Msgbox("Records Not Found", "Warning")
Else
TblInvList.ClearAll
'Log(ResultList)
Dim Row As String
For I = 0 To ResultList.Size - 1
'Log(Row)
Row = ResultList.Get(I)
TblInvList.AddRow(Regex.Split(",", Row.Replace("[","").Replace("]","")))
Next
End If
End Sub
Sub TblInvList_CellClick (Col As Int, Row As Int)
ActionBar.Subtitle = TblInvList.GetValue(Col, Row)
End Sub
Sub TblInvList_CellLongClick (Col As Int, Row As Int)
ActionBar.Subtitle = TblInvList.GetValue(Col, Row)
End Sub
Sub MySQL_QueryResult(data As List, meta As Map)
ResultList = data
ToastMessageShow(meta.Get("RecordCount") & " rows retrieved in " & meta.Get("ms") & " milliseconds", True)
CallSub(Null, Populate_Table)
' For i = 0 To data.Size - 1
' Log(data.Get(i))
' Next
' Log(data.Size)
' Log("Meta = " & meta.Size)
End Sub