Professional Documents
Culture Documents
http://www. mysql.com/products/connector-j
JDBC and the
MySQL Connector/J
You need a JDBC driver in order to enable
communication between your Java program and the
database.
3
Next, we need to tell BlueJ that we have already added
the JDBC driver for MySQL so that our Java programs can use
them. We need to do this step in order to tell BlueJ where to
find the JDBC driver to enable Java programs to access
MySQL. In BlueJ, we do this by
3
1. This statement registers the MySQL driver class with this Java program, in order to make
this Java program access data on the MySQL server. "com.mysql.jdbc. Driver" enables a
Java program to communicate successfully with the MySQL database server.
2. This statement defines the URL of the MySQL database named friends residing on our
computer named localhost.
3. This statement gets a connection to the database at the specified URL for a user named
peter with a password=peter. In effect, this statement logs this Java program onto the
MySQL database server using peter’s account.
Take note that we grant Peter with password peter all the privilege to manipulate the
database friend.