B4J Question B4j MySQL remote

Duque

Active Member
Licensed User
Longtime User
Some friendly colleague who passed me some example threads on how to connect Mysql with the b4j I come from vb6 so I'm good rookie, I also accept threads from any example of echos programs with b4j
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi! soyVB6

despite it may depend what are you looking for:

1.- Create a middleware between your B4A/I apps and your mySQL database

or

2.- Make a direct connection for your B4J UI apps.

it is actually very easy.

you need, 1 library (JSQL), one additional jar and a line of code:
B4X:
#Region Project Attributes
    #AdditionalJar: yourConnectorJarHere
#End Region

Sub Process_Globals
Public SQL1 As SQL
End Sub

Sub AppStart (Form1 As Form, Args() As String)
'this line is for direct connection. 
SQL1.Initialize2("org.mariadb.jdbc.Driver","jdbc:mysql://pathToServer/database","user","password")
End Sub

Download the additional jar from here:
https://dev.mysql.com/downloads/connector/j/3.1.html
(i do not know which one it is, i suppose that the later the better)
 
Upvote 0

Duque

Active Member
Licensed User
Longtime User
B4X:
#AdditionalJar: mysql-connector-java-3.1.14-bin
'----
sql.Initialize2("com.mysql.jdbc.Driver","jdbc:mysql://www/bd","us","pass")

With this works perfect I did a couple of queries with sql.ExecQuerySingleResult and it effectively connects, BUT there is no cursor to handle data like b4a, how do I manage the data here? Thank you
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…