Monday, 4 April 2011

MySQL JDBC Connection Properties

There are several things to remember when configuring a MySQL JDBC driver connection. Firstly, you need to specify the driver and the driver class is com.mysql.jdbc.Driver located in the mysql-connector-java-5.x.x.jar archive file and available for download from

You also need to configure an appropriate MySQL url. This has the format:

jdbc:mysql://<hostname>:<port number>/<database-name>

for example:


- as the port number is optional.

In order for your Java application to connect to your MySQL you need some code which’ll look abit like this:

      try {
        con = DriverManager.getConnection
(url, userName, password);
} catch (SQLException e) {

No comments: