The recommended way from the MySQL-website is connecting to the MySQL-Server through JDBC with the Connector/J-driver. MySQL Connector/J is a native Java driver that converts JDBC (Java Database Connectivity) calls into the network protocol used by the MySQL database.
The installation of this driver is very simple:
Download the driver and copy the included Jar-file (e.g. "mysql-connector-java-3.0.17-ga-bin.jar") to the "[...]\jre\lib\
ext"-folder in your current Java-installation.
The JDBC API is designed to make it possible for you to write a single Jabaco/Java program and to use it to manipulate the data in a variety of different SQL database servers without a requirement to modify and/or recompile the program.
Connection-sample:
|
Jabaco Source
|
1
2
3
4
5
6
|
On Error Resume Next
Dim driver As Class
driver = Class.forName("com.mysql.jdbc.Driver")
If driver = Nothing Then MsgBox "Not found!"
On Error Goto 0
Call Database1.Connect("jdbc:mysql://server:port/database", "username", "password")
|
You have to modify server, port, database, username and password. Short usage-sample:
|
Jabaco Source
|
1
2
3
4
5
|
Dim myRes As ResultSet
myRes = Database1.ExecuteStatement("SELECT * FROM users LIMIT 10")
Call myRes.first
MsgBox myRes.getString(1)
MsgBox myRes.getString("nickname")
|
Further information about JDBC:
http://java.sun.com/products/jdbc/overview.html
Further information about MySQL with JDBC:
http://dev.mysql.com/usingmysql/java/