Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jdbc JDBC Drive For Mysql

Related Tutorials


 
 

Share on Google+Share on Google+

JDBC Drive For Mysql

Advertisement
In this Tutorial we want to describe you a code that help you in understanding 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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 17, 2008

Related Tutorials

Discuss: JDBC Drive For Mysql   View All Comments

Post your Comment


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