JDBC Environment Setup
Now let us do discuss out various types of drivers in JDBC. So basically there are 4 types of standard drivers listed below:
Now, you must be wondering about they are their point do come out which drivers to be used. The solution to this is as simple as we need to use the driver as per accordance with the database with which we are interacting.
Note: Drivers to be used are directly propionate to which kind of database with which we are dealing.
Drivers are mentioned in the tabular format below corresponding to the database which is as follows:
Database | Driver name |
---|---|
MySQL | com.mysql.jdbc.Driver |
Now you must be wondering out from where these listed drivers are to be imported. So in order to import the drivers, you need to download a JAR file from the web. Considering the most frequently used database namely MySQL you need to download a JAR file named ‘mysql.connector‘ and so on it goes for other databases.
Note: It is not an essential step as different IDE’s possesses different traits. In some IDE these connectors are inbuilt such as NetBeans while in Eclipse you need to import this JAR file as discussed above by simply downloading corresponding JAR file from the internet and load in the project.
If you do not know how to import JAR files to libraries in java IDE, first go through this step.
JDBC Tutorial
JDBC stands for Java Database Connectivity. JDBC is a Java API or tool used in Java applications to interact with the database. It is a specification from Sun Microsystems that provides APIs for Java applications to communicate with different databases. Interfaces and Classes for JDBC API comes under java.sql package. In this Java JDBC tutorial, we will be learning about what is Java Database Connectivity with suitable example.
In the present world, where we mostly deal with websites and databases it is as if they matter the most but if we closely look over it is data that matters the most. If we look closer that all developers are revolving and working over the web and mobile technologies but what remains the same is the data.
Hence, there is an urgency to figure out how data is being handled for which this concept comes into play.
Let us do have an overview of why do we need this term which can be better interpreted with the image provided below.
Why do we need to learn advanced java?
As we are well versed with all the concepts of Core Java now comes the time to build projects that will results out in building an application as a final product. So if we do are only aware of core java we can only build applications that can be run on the machine where the components of it are stored(in simpler words one can say where all the codes are written). These types of applications are known as standalone applications.
Note: Standalone applications being one of two types of applications in the programming world only holds for 5% of the applications in the real world.
Hence, the scope is very constricted if we only do build standalone applications resulting out in the very little scope of development and scalability which gives birth to advance java which in turn gives birth to 3 components primarily namely JSP, Servlets, and JDBC in order to make the applications run on multiple machines. With the evolution of these 3 components, it removes the constraint of running only a single machine as it was impractical to users in the real-world application is made but forcing users to install then use them. Now, these types of applications are known as web applications that are the applications providing the services to the end-users without installing them. These applications are known as web applications which are not standalone applications.
Now you must be wondering what is JSP and Servlet and how JDBC is interrelated with them. For the time being, just focus only on JDBC in order to get started with what exactly it is and how to use it by referring to the image depicted below as follows:
Note: Conclusion drawn from Image is as follows:
- JSP stands for Java Server Pages where these pages are considered as View Components as Presentation logic.
- Servlet is meant for internal processing going on such as reading, fetching values from the database, comparison, etc in the backend as Processing Logic in our process servlet. Servlets do also contain java classes for this background processing for processing logic.
- JDBC is meant for Connectivity of Java Application in servlets as discussed to our Database.