iOS Question MySql connector for B4i

NagyLajos

Member
Licensed User
Longtime User
Hi @Erel ,

I would like to ask for help.

I would need a MySql library for the iOS version of the application. I have found one for the Android version, it operates well, but I do not have for iOS. I know, you prefer RDC, but to me it Is not a good solution.

The situation is the following. You have approximately 100 different severs with different operation systems. The common in them is all have MySql server and the application has to gain data from than. Servers can be in local network or having internet connection. It can be a notebook, a PC or a normal server. It might happen that it has to serve only 15 or 1000 users at one time. If we’d use RDC than PHP and webserver should be installed to each beside MySql. PHP scripts should be installed as well. If something changes in case of direct launch only the database’s structure has to be changed, in case of RDC scripts might have to be changed.

I have found a ‘Connector’ written in Objective C, I have tried to make library from it. It looks good, however the test program signs a program. I use a Local Mac Builder.

I attach the XCode project and the error message.

Regards

Lajos
 

Attachments

  • iMySql.zip
    29.6 KB · Views: 346
  • Error.PNG
    20.1 KB · Views: 348

Erel

B4X founder
Staff member
Licensed User
Longtime User
Several mistakes here.

1. jRDC2 has nothing to do with PHP. Try it.
2. Much simpler to update the queries in the jRDC2 configuration file than updating queries in thousands of clients apps.

libmysqlclient is a C library. It will not be simple to wrap it (correctly) with Swift or Objective C.
 
Upvote 0

NagyLajos

Member
Licensed User
Longtime User
@Erel
Thank you very much for your quick reply.
I’m looking at it, but I don’t yet see how it’s possible to have multiple databases on a server and want to access it through JRDC. Do you need a separate JRDC server for each database?
Attached is the planned structure. A scanned QR code determines which server to connect to which database. It works well in the android app. That's why I thought under iOS.
Unfortunately, I didn't program much in C.
 

Attachments

  • Structure.PNG
    38 KB · Views: 352
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
jRDC2 is 1000 times more powerful than any direct solution. You can modify jRDC2 in any way you need.

I wasn't able to find the post that discusses the modified jRDC2 that supports multiple database so I attach it here. Start with the regular jRDC2 and then switch to this one.
 

Attachments

  • jRDCMulti.zip
    4.9 KB · Views: 575
Upvote 0

Sergio Castellari

Active Member
Licensed User

Hello,

I understand that I should start a new thread, but I want to know more about jRDCMulti

I am using the first version of JRDC2. But I need to be able to use different DBs. I don't realize how I should use this new version to indicate the DB in the query.
Currently in the client application I do:

B4X:
Public Sub AuditSQL (cAuditoria As String, cTip As String) As ResumableSub
    DateTime.DateFormat = "yyyy-MM-dd"                        'Doy formato a la Fecha
    Dim cFecha = DateTime.Date(DateTime.Now) As String
    Dim cTime = DateTime.Time(DateTime.now) As String
    'Log("fecha: " & cFecha)
    Dim aCom() As String
    aCom = Array As String(cFecha,cTime,Main.pUsuario,Main.pNetName,cAuditoria,cTip)
    Dim res As Boolean
    Dim cmd As DBCommand = CreateCommand("auditSQL", aCom)
    Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
    Wait For(j) JobDone(j As HttpJob)
    res = j.Success
    If j.Success Then
        Log("Auditoría OK !!!")
    Else
        Log("Auditoría FALLO !!!")
    End If
    j.Release
    Return res
End Sub

In Config.Properties I have the following:

#Inserción de Auditoría
sql.auditSQL=Insert into AUDIT (FECHA,HORA,USUARIO,PC,PROCESO,NOTAS) Value (?,?,?,?,?,?)


Where would the DB indicate?
How do I configure the DB in my B4A application?
Excuse my ignorance, but it is important to me. I need to make an APP for different clients that access different DBs.
Cheers,
 
Upvote 0

NagyLajos

Member
Licensed User
Longtime User
Hello!

There are several options:
- there will be more SQL rows in config.propertis. For example:
...... sql.Db1InsertTable1 =
...... sql.Db2InsertTable2 =
and so on.

- you can modify the structure of DbCommand to include the required database, but you will also need to modify JDRCMulti to handle it:

B4X:
Type DBCommand (DbName as string, Name As String, Parameter As String)

So you don't need as many sql .... commands.
Of course, if the structure of the databases is similar.

Regards

Lajos
 
Last edited by a moderator:
Upvote 0

Sergio Castellari

Active Member
Licensed User

Hello @NagyLajos !

The structure of the databases are the same. What I need is to be able to indicate the Database to use in the query. I wish to have a single jRDC2, which can be accessed by indicating the Database.
Have you modified it that way?
Could you share it?

Thank you in advance for your words!

Hugs,
Sergio
 
Upvote 0

NagyLajos

Member
Licensed User
Longtime User
Hello @Sergio Castellari



Try modifying the DbCommand type in JRDC2:
Original:
B4X:
Type DBCommand (Name As String, Parameter As String)
Modified:
B4X:
Type DBCommand (Name As String, Database As String, Parameter As String)

On each side, of course. And the command processing also needs to be modified:

B4X:
Dim m As Map = ser.ConvertBytesToObject (Bit.InputStreamToBytes (in))
Dim cmd As DBCommand = m.Get ("command")
Dim DBName As String = cmd.Database
Connector = Main.Connectors.Get (DBName)

And it can work.

Regard's

Lajos
 
Last edited by a moderator:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…