JDBC - Driver connecting

JDBC - Driver connection creation

    The important step of connecting database is implementing the driver.  The following code will help you to implement the driver. 

Create package
Create new class name as Implementation.java





First Program: (connecting driver) Implementation.java


package com.javabasic.jdbc.project;
import java.lang.ClassNotFoundException;
public class Implementation {

      public static void main(String[] args)
      {
            try
            {
                  System.out.println("Connecting to driver");
                  Class.forName("com.mysql.jdbc.Driver");
                  System.out.println("Connection successful");
                 
            }
            catch(ClassNotFoundException error)
            {
                 System.out.println("Error:"+error.getMessage());
            }
      }
}


Next step: Database connection

No comments:

Post a Comment