Monday, 9 January 2012

Connecting MySQL in xampp with java

phpMyAdmin in xampp server is used  to manage MySQL database.We can connecting java with mysql xampp using the below code:

Xampp should be installed.

In the java code 
  String url = "jdbc:mysql://localhost:3306/"; ( MySQL server in xampp is installed in port 3306)
  String dbName = "test";
  String driver = "com.mysql.jdbc.Driver";
  String userName = "root";
  String password = "";
  try {
      Connection con =DriverManager.getConnection(url+dbName,userName,password);

We need to put mysql-connector-java-5.1.18-bin.jar in the classpath.

No comments:

Post a Comment