Android Question using SQL en jSQL in same project

MarcRB

Active Member
Licensed User
Longtime User
Hello,

I do have a B4A project that uses SQL to connect to a local SQLite database. Perfect working.

At this moment I will add a new function that needs to connect to an external public MySQL database.
If I try to use jSQL there is some conflict between SQL keyword from SQL library and jSQL library.
They both use SQL.

Public DBlite as SQL (SQL lib)
Public DBMySQL as SQL (jSQL lib)

Is there any trick to use jSQL in combination with SQL?

Thanks in advance
 
Solution
Thanks for your help.

Setting up a webserver and a php serverside script/page is a little bit overkill for this minor function.
I really want to connect to MySQL directly. I know it is insecure by jdbc, but in this case there is no secret data.

More searching point me to https://www.b4x.com/android/forum/threads/jdbcsql-directly-connect-to-remote-databases.84016/#content .
It is a port of B4J jSQL library.
The SQL type was renamed to JdbcSQL and ResultSet was renamed to JdbcResultSet, this allows using it together with the SQL library.
For me, in this case, the solution I needed.

Alex_197

Well-Known Member
Licensed User
Longtime User
Hello,

I do have a B4A project that uses SQL to connect to a local SQLite database. Perfect working.

At this moment I will add a new function that needs to connect to an external public MySQL database.
If I try to use jSQL there is some conflict between SQL keyword from SQL library and jSQL library.
They both use SQL.

Public DBlite as SQL (SQL lib)
Public DBMySQL as SQL (jSQL lib)

Is there any trick to use jSQL in combination with SQL?

Thanks in advance
I'm suing the same local SQLite and connect to the MS SQL on the external server. I'm using OkHTTP to the website that itself connects me to the SQL server. I'm using ASP.NET and the website returns me JSON
 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
I'm suing the same local SQLite and connect to the MS SQL on the external server. I'm using OkHTTP to the website that itself connects me to the SQL server. I'm using ASP.NET and the website returns me JSON
In my case I do not use my own external MySQL database. I have only an ipadress , databasename, username and password.

I'm trying to do the local SQLite also with jdbc. Maybe this can be a solution.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
In my case I do not use my own external MySQL database. I have only an ipadress , databasename, username and password.

I'm trying to do the local SQLite also with jdbc. Maybe this can be a solution.
So you have all you need - you can create either php or asp.net page that will communicate with the db and send json back to the app. JDBC - is it secure? over http you can use https.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
They are all the same and do the same work. No need to add the two.
SQL for B4A
jSQL FOR B4
iSQL FOR B4i

Connecting to Mysql db, look at the initializing method. Remote connection to online mysql database is very difficult and needs some configurations. Best bet is to connect through php or other server scripts as @Alex_197 said.

 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
Thanks for your help.

Setting up a webserver and a php serverside script/page is a little bit overkill for this minor function.
I really want to connect to MySQL directly. I know it is insecure by jdbc, but in this case there is no secret data.

More searching point me to https://www.b4x.com/android/forum/threads/jdbcsql-directly-connect-to-remote-databases.84016/#content .
It is a port of B4J jSQL library.
The SQL type was renamed to JdbcSQL and ResultSet was renamed to JdbcResultSet, this allows using it together with the SQL library.
For me, in this case, the solution I needed.
 
Upvote 0
Solution

klaus

Expert
Licensed User
Longtime User
Be aware when using SQL in B4J you need to add this line in the Main module:
B4X:
#AdditionalJar: sqlite-jdbc-3.7.2
The version number may be different.

The declaration is the same for both:
B4X:
Public DBlite as SQL

But the initialization is different:
B4X:
#If B4J
        DBlite.InitializeSQLite(SQLDataBasePath, SQLDateBaseName, True)
#Else
        DBlite.Initialize(SQLDataBasePath, SQLDateBaseName, True)
#End If
 
Upvote 0
Top