JDBC Drive For Mysql

In this Tutorial we want to describe you a code that help you in understanding JDBC Drive for Mysql.

JDBC Drive For Mysql

JDBC Drive For Mysql

     

In this Tutorial we want to describe you a code that help you in understanding JDBC Drive for Mysql. The code include a class JdbDriveForMysql,Inside the main method we declared a string driver initialized  with "com.mysql.jdbc.Driver".The try block include the following steps-

Driver loading: loading a driver is the first step by calling a class.forname( ) and passed driver class as argument. Once the driver is loaded ,you connect the front end of the Java application to the backend database. In case there will be an exception occurred  in loading a database driver  in the try block. The catch block check the exception and println print the exception.

Finally the println print the value of  jdbc driver for mysql is specified in string driver. 

JdbcDriveForMysql .java


public class JdbcDriveForMysql {
  public static void main(String args[]) {
  String driver = "com.mysql.jdbc.Driver";
  try {
  Class.forName(driver);
  System.out.println("jdbc driver for mysql : " + driver);
  catch (Exception e) {
  System.out.println(e);
  }
  }
}

Output

jdbc driver for mysql : com.mysql.jdbc.Driver

Download code