Connect to MySQL with JDBC

Price: INR 8,999.00
Price: INR 15,999.00
Was: INR 16,999.00

In this tutorial, you will see, How can you connect MySQL with JDBC. Java Database Connectivity(JDBC) is an Application Programming Interface(API). JDBC is used to connect Java application with Database.

JDBC is used to interact with the various type of Databases such as Oracle, MS Access, My SQL and SQL Server. To connect Java with different Databases we have different drivers and jar files.

 

Using JDBC we can execute the queries using Java Application and retrieve the results in Database.

To connect MySQL to your java Application, You need to download MySQL JDBC connector. You can download this from here! (Download Connector)

 

From here Download the ‘ZIP’ file. After unzip open the unzipped directory here you will get the file named ‘mysql-connector-java-5.0.8-bin’. This is the jar file which will help us to connect the MySQL with JDBC.

  1. To connect with your Java application with MySQL DB. First of all, you need to import the sql package in your java class.

  2. Include that ‘mysql-connector-java-5.0.8-bin’ file in your project. We have already seen, How to import external jar files into your project in eclipse.
    (Right Click project -> Build path-> Configure Build path-> Libraries-> Add External JARs -> Import Jar -> Click OK Button)

  3. Use Connection Interface to establish the connection.

 

How to Test Database Connection using Selenium

 

You can run the above Test and verify the Database connectivity.

You can also run the above code on your local machine. So this is the way, How can we test the Database connectivity Test using selenium.

0 Comment

Leave a Reply