Hello everyone,
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
Maybe you need to allow access to MySQL;
Using
I wish to be useful.
Note:
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")
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.
you can change username root to another one.
Using
B4X:
'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
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim a As MYSQL
Dim L As List
Dim hsv As HorizontalScrollView
Dim svRows As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'write your own parameters
'a.setDatabase("server ipnumber (not name)","databasename","username","password") 'Cancel this line
'you can write named server
a.setDatabase("server ipnumber or url","databasename","username","password")
' select query
' L=a.Query("select * from tb_Test")
' or get table list for database
L = a.TableList 'you can get all tables for default database
' CUD: Create, Update, Delete
' or UPDATE query
' Dim r as Int ' return affected rows count
' r = a.ExecuteNonQuery("update tablename set fieldname='xxxx' where keyname='xx'; ")
If L.IsInitialized=False Then
Msgbox("Records Not Found","Warning")
Return
End If
Dim row As List,cols As Int ,rows As Int
rows = L.Size
row = L.Get(0) 'Header row
cols = row.Size
hsv.Initialize(cols*150dip,0)
Activity.AddView(hsv,0,0,100%x,100%y)
svRows.Initialize(rows*30dip)
hsv.Panel.AddView(svRows,0,30dip,cols*150dip,100%y-30dip)
'CREATE HEADER LABELS
For j=0 To cols-1
hsv.Panel.AddView(LabelCreate(row.Get(j),Colors.DarkGray,Colors.White) _
,j*150dip _
,0 _
,149dip _
,29dip)
Next
'CREATE RECORD LABELS
For i=1 To L.Size-1
row = L.Get(i)
For j=0 To cols-1
svRows.Panel.AddView( LabelCreate(row.Get(j),Colors.LightGray,Colors.Black) _
,j*150dip _
,i*30dip-30dip _
,149dip _
,29dip)
Next
Next
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub LabelCreate(str As String,backcolor As Int,textcolor As Int) As Label
Dim t As Label
t.Initialize(0)
t.text=" " & str
t.color=backcolor
t.textcolor=textcolor
t.Gravity = Gravity.CENTER_VERTICAL
Return t
End Sub
Note:
Be carefully working with databases, responsibility for problems caused by this library is yours.
This library userfull 'in firm' applications.
Because MySQL IPNumber should be accessible through the network.
I'm canceling this red-colored description. You can connect if Mysql server accessible anywhere.
This library userfull 'in firm' applications.
Because MySQL IPNumber should be accessible through the network.
I'm canceling this red-colored description. You can connect if Mysql server accessible anywhere.
Attachments
Last edited: