MarcRB Active Member Licensed User Longtime User Feb 25, 2023 #1 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
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 MarcRB Feb 26, 2023 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.
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.
A Alex_197 Well-Known Member Licensed User Longtime User Feb 25, 2023 #2 MarcRB said: 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 Click to expand... 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 said: 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 Click to expand... 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
MarcRB Active Member Licensed User Longtime User Feb 25, 2023 #3 Alex_197 said: 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 Click to expand... 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 said: 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 Click to expand... 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.
A Alex_197 Well-Known Member Licensed User Longtime User Feb 25, 2023 #4 MarcRB said: 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. Click to expand... 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
MarcRB said: 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. Click to expand... 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.
mcqueccu Expert Licensed User Longtime User Feb 26, 2023 #5 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. Complete tutorial: B4A & Your own (local) php & MySql Server (Xampp) with b4a Update: Newer releases of XAMPP come with MariaDB except of MySQL. Basically the same but the php scripts have to be changed a little bit: - mysql is changed to mysqli - "$con" (variable that holds the connection) has to be added to every sql statement "mysqli_query($con,"SELECT * FROM... www.b4x.com Upvote 0
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. Complete tutorial: B4A & Your own (local) php & MySql Server (Xampp) with b4a Update: Newer releases of XAMPP come with MariaDB except of MySQL. Basically the same but the php scripts have to be changed a little bit: - mysql is changed to mysqli - "$con" (variable that holds the connection) has to be added to every sql statement "mysqli_query($con,"SELECT * FROM... www.b4x.com
MarcRB Active Member Licensed User Longtime User Feb 26, 2023 #6 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
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.
klaus Expert Licensed User Longtime User Feb 26, 2023 #7 Be aware when using SQL in B4J you need to add this line in the Main module: B4X: Copy #AdditionalJar: sqlite-jdbc-3.7.2 The version number may be different. The declaration is the same for both: B4X: Copy Public DBlite as SQL But the initialization is different: B4X: Copy #If B4J DBlite.InitializeSQLite(SQLDataBasePath, SQLDateBaseName, True) #Else DBlite.Initialize(SQLDataBasePath, SQLDateBaseName, True) #End If Upvote 0
Be aware when using SQL in B4J you need to add this line in the Main module: B4X: Copy #AdditionalJar: sqlite-jdbc-3.7.2 The version number may be different. The declaration is the same for both: B4X: Copy Public DBlite as SQL But the initialization is different: B4X: Copy #If B4J DBlite.InitializeSQLite(SQLDataBasePath, SQLDateBaseName, True) #Else DBlite.Initialize(SQLDataBasePath, SQLDateBaseName, True) #End If