Types of JDBC Drivers in Java6 Mar 2025 | 4 min read A Java API called Java Database Connectivity (JDBC) enables Java programs to access and work with data stored in databases. JDBC offers a common set of classes and interfaces to connect to databases, run SQL commands, and retrieve data. The software elements known as JDBC drivers enable Java programs to connect to particular kinds of databases. This article will discuss the various JDBC driver types in Java. JDBC-ODBC Bridge Driver, Type 1 JDBC DriverThe JDBC-ODBC bridge driver is another name for the Type 1 JDBC driver. ODBC drivers connect Java programs to databases using this obsolete driver. To connect to the database, the driver translates JDBC calls into ODBC calls, which are then forwarded to the ODBC driver via the driver. This driver should not be used in production situations and is only advised for usage in small-scale applications. Native-API/partially Java Type 2 JDBC DriverThe Native-API/Partially Java driver is another name for the Type 2 JDBC driver. To connect to databases, this driver employs native database client libraries. A Java component of the driver interacts with a native component via a vendor-specific API. Although this driver performs better than the Type 1 driver, it is still not advised to use it in production settings. Network-Protocol/Java Middleware Driver, Type 3 JDBC DriverThe Network Protocol/Java Middleware Driver is another name for the Type 3 JDBC driver. In order to connect to databases, this driver employs a middleware server. A Java client component of the driver uses a vendor-specific protocol to connect with a middleware server. Then, the middleware server uses a vendor-specific protocol to connect to the database server. Compared to the Type 2 driver, this driver offers improved performance and scalability. Pure Java Driver, Type 4 JDBC DriverThe Pure Java driver is another name for the Type 4 JDBC driver. This driver utilizes a vendor-specific protocol to interface directly with the database server and is entirely Java-based. The client system does not need to have any native components or middleware servers installed to use this driver. It is advised to use this driver in production applications since it offers optimum performance and scalability. Steps for Connecting to JDBCStep 1: Load the JDBC driver class The JDBC driver class must be loaded first. Setting up a connection to the database is the responsibility of the driver class. The JDBC driver class may be loaded using the Class.forName() function. Step 2: Establish a connection to the database Setting up a connection to the database is the next step. Use of DriverManager is possible.To connect to the database, use the getConnection() function. The database's URL is specified by the URL option. The user is authenticated using the username and password parameters. Step 3: Create a statement object You may build a statement object once you've established a connection to the database. SQL statements are carried out using the statement object. Step 4: Carry out a SQL command You may use a statement object to execute SQL statements once you've created one. SELECT statements are carried out using the executeQuery() function, whereas INSERT, UPDATE, and DELETE statements are carried out using the executeUpdate() method. The SQL statement to be performed is specified by the sql argument. The SELECT statement's output is included in a ResultSet object that is returned by the executeQuery() function. Step 5: Process the result set A while loop can be used to process the result set. The cursor is advanced to the following entry in the result set using the next() function. The values of the columns in the current row can be retrieved using the getString(), getInt(), or getDouble() functions. The id, name, and balance values for each row in the result set are retrieved by this code, which then outputs them to the console. Filename: JdbcExample.java Customer Table
Output: ID: 1, Name: John Doe, Balance: 1000.0 ID: 2, Name: Jane Doe, Balance: 2000.0 Next TopicUnmarshalling in Java |
How to Return Value from Lambda Expression Java
? Lambda expressions were introduced in Java 8 and are a powerful tool for writing concise, functional-style code. A lambda expression is an anonymous function that can be used to implement a method defined by a functional interface. Functional interfaces are interfaces that define only a single...
4 min read
Java StrictMath Class
The java.lang.StrictMath class offers numerous methods for carrying out numeric operations, such as determining squares, square roots, cubes, cube roots, exponential results, and trigonometric functions. It ensures strict precision and consistent results across all platforms. public final class StrictMath extends Object Handling NaN Arguments: The StrictMath...
11 min read
Find if an Array of Strings can be Chained to form a Circle in Java
Find whether an array of strings may be linked together to create a circle. If the last character of string X and the first character of string Y are the same, then string X can be positioned in a circle before string Y. Example 1: Input: String a =...
7 min read
Image Processing in Java: Image Edge Detection Operators in Digital Image Processing
Image processing is an essential aspect of computer vision that allows the computer to realize and process images like the human brain. Java provides a strong environment wherein the image processing algorithms can be implemented with robust libraries, coupled with independence from platform dependence. Edge detection...
7 min read
Non-primitive data types in Java
Data types define the type of data that is stored in the variable. The type specifies the kind of data (different sizes and values). Java programming language has two types of data types Primitive data types (predefined data types) Non-primitive data types In this section, we will understand the non-primitive...
5 min read
How to Print Table in Java
? In this section, we will understand the logic to print tables and also implement that logic in Java programs. A table (or multiplication table) is a sequence of numbers that are generated using multiplication. We enter an integer as input of which we want to print the...
2 min read
Sorting a Java Vector in Descending Order Using Comparator
Introduction: A dynamic array-like data structure that lets you store and work with objects is the Java Vector class. Sorting the components of a Vector in a precise order might often be necessary, whether you are working on a small project or a large-scale application. In this...
3 min read
Giuga numbers in Java
A Giuga Number is a composite number N that has a unique property. The property states that for every prime factor, p of N, N divided by p minus 1 ((N/p) - 1) should also be divisible by p. If a number N satisfies this condition...
5 min read
Abstract Factory Design Pattern in Java
Design patterns are important in software development because they helps us to create code that is both robust and easy to maintain. One such essential design pattern is the Abstract Factory Design Pattern. The pattern belongs to the category of creational design patterns that allows for...
4 min read
Difference Between System.out.print() and System.out.println() Function in Java
In Java, System.out.print() and System.out.println() are two methods defined in the System class to send output to the console. They look and sound similar, but they behave differently in terms of cursor movement and formatting of the output. Java System.out.print() Method The System.out.print() method prints the specified...
3 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India