### Connect MySQL DB

Brief steps on how to connect to a MySQL database.
See also B4J HowTo > MySQL > Connect using JDBC Overview.
Libraries
Required is the MySQL/J connector, to be stored in the B4J additional libraries folder.
mysql-connector-java-5.1.29-bin.jar
Add the Library to the Project Attributes
#AdditionalJar: mysql-connector-java-5.1.29-bin.jar
Include the jSQL Library
This is done in the B4J IDE Library Manager.
Declare SQL a Var in Class Globals or Process Globals
Private gSQL as SQL
Init the connection
'Connecting to a Remote MySQL Database with IP Address 192.168.0.16, database notes, user notesuser and password.
Try
gSQL.Initialize("com.mysql.jdbc.Driver", "jdbc:mysql://192.168.0.16/notes?user=notesuser&password=YOURPASSWORD")
Catch
Log(LastException.Message)
End Try
Another way is using
Try
gSQL.Initialize2("com.mysql.jdbc.Driver", "jdbc:mysql://192.168.0.16/notes?characterEncoding=utf8", "username", "password")
Catch
Log(LastException.Message)
End Try

Changed: , Category: MySQL, File: T6C223M1645.htm, ID: 1645