JDBC Drive For Mysql

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

Ads

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

Advertisements

Share on Google+Share on Google+

JDBC Drive For Mysql

Posted on: November 17, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: JDBC Drive For Mysql   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads