Hola, esta es la seccion de código que tendrías que poner en tu clase java para conectarte:
Código PHP:
Statement stmt;
//Register the JDBC driver for MySQL.
Class.forName("com.mysql.jdbc.Driver");
//Define URL of database server for
// database named mysql on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql://localhost:3306/mysql";
//Get a connection to the database for a
// user named root with a blank password.
// This user is the default administrator
// having full privileges to do anything.
Connection con =
DriverManager.getConnection(
url,"root", "");
//Display URL and connection information
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
El ejemplo completo lo encuentras en:
http://www.developer.com/java/data/article.php/3417381