×

Design of JDBC

Java applications may interface using database systems from many vendors using the Java Database Connectivity (JDBC) Application Software Interface (API) from Sun Microsystem. To connect spreadsheets, JDBC and database drivers collaborate. The JDBC design, used to interface databases, specifies the JDBC elements.

JDBC modules

The four main parts of JDBC are utilized to interface with both databases.

JDBC API(Application Programming interface)

JDBC Test Suite

JDBC Driver Manager

JDB- ODBC Bridge Driver

1.JDBC API: JDBC API offers a variety of interfaces and techniques for quickly connecting to diverse databases.

javax.sql.*;  
java.sql.*;  

2)   JDBC Test Suite: The JDBC Test Suite enables programmers to test the different actions by JDBC Drivers, including deletion, updating, and inserting.

3) JDBC Driver management: To link to a database, the JDBC Driver manager loads a particular driver to the dataset into an application. Additionally, a data system call to the database is made using the JDBC Driver Manager to carry out request execution.

4) JDBC-ODBC Bridge Drivers: To link database drivers to the database, JDBC-ODBC Bridge Motorists are utilized. The ODBC function call is translated via the bridge from the JDBC method calls. To operate the ODBC (Open Database Connectivity) features, it uses the native libraries contained in the sun. jdbc.odbc module.

JDBC structure

1) Application: The Apache servlet or applet that interacts with both the source of data is the implementation.

2) The JDBC API: This tool enables Java programs to execute SQL operations and get results.

Below are some of the essential interfaces and classes specified in the JDBC API:

  • Drivers
  • DriverManager
  • Statement
  • Connection
  • Callable
  • Statement
  • PreparedStatement
  • Result
  • Set
  • SQL data

3. DriverManager: DriverManager is a key component of the JDBC design.

The corporate apps are linked to numerous databases via drivers particular to each database.

4) JDBC drivers: To interface with a data source using the JDBC, one requires a JDBC driver that interfaces with the target data source in a feasible way.

Various JDBC Configurations Types are:

The JDBC design uses a two- and a three-tier paradigm to access the specified database.

Paradigm with two tiers: In this architecture, the program communicates directly with both the data source. The JDBC driver establishes the connection between the data source and the program. Whenever a user sends a query to a data source, the user receives the query's reply immediately.  A customer paradigm links the user device to the source of data, which may be on a separate system. The client computer sends the questions, and the server sends the results of those questions, functioning as the server.

Three-tier architecture: In this architecture, user inquiries are routed to middle-tier systems, from which they get directives that are then forwarded to the data source. The intermediate layer receives the responses to such requests and sends these to the user back.

Functioning of JDBC 

The JDBC API must be used by any Software application that wants to communicate with databases. The JDBC driver for data sources like Oracle or MySql must be installed before communication with the data source may occur.

import java.lang.*;
import java.sql.*; 
import java.io.*; import java.util.*; class JDBC1
{ 
public static void main(String args[]) { 
try { 
System.out.println("step1 : load the driver class \n"); Class.forName("oracle.jdbc.driver.OracleDriver"); 
System.out.println("step2 : create the connection object \n"); 


Connection con=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:xe",
"rohith","1113"); 
System.out.println("step3 : create the statement object \n"); 
Statement stmt=con.createStatement(); 
System.out.println("step4 : execute query (or) resultset \n"); ResultSet rs=stmt.executeQuery("select * from csec1"); 
while(rs.next()) { 
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3)); }
System.out.println("\nstep5 : close the connection object \n"); con.close(); 
79 
}//try 
catch(Exception e)
{ System.out.println(e); }//catch 
}//main 
}//JDBC1 

Output

Design of JDBC

Related Topics

Java Program to print even and odd numbers using 2 threads

Using two threads in a single thread is even odd printing in Java programming with multiple threads. To create code that prints even and odd using two threads, we must...

2 minutes read.

Static class in Java

In Java, a class is a file containing the Java byte code. It can essentially specifically be executed on the JVM (Java Virtual Machine), fairly significant. The JVM is mostly...

7 minutes read.

Java String equals() method

equals() method compares two string based on the their content. Syntax public boolean equals(Objects anObject) parameter anObject: Object to be compared with the current String. Returns It returns true when the current String is equivalent to...

1 minute read.

Java File Input Stream

Java makes use of stream ideas to speed up input and output processes. All packages of input and output streams are contained in java.io.package. Stream: A stream is nothing more...

5 minutes read.

Get yesterdays date by no of days in Java

In this tutorial, we are going to learn how to get yesterday’s date by the no of days in Java. Using the Calendar class, one can get the current date....

1 minute read.

How to Convert Integer to String in Java

How to Convert int to String in Java It is used when you want to convert an integer to String. You can convert int to String by using the following methods: Using...

3 minutes read.

Different Ways to Print Exception Message in Java

In this section, we will learn how to use various Java Throwable class methods to print exception messages. The Throwable class has the three methods listed below for printing the...

4 minutes read.

File Operation in Java

In Java, a file is an Abstract data type. These are used to store the data which is related. Files are named storage locations. With a file we can perform...

7 minutes read.

Java LinkedList

LinkedList Java The Java LinkedList is used to store the elements by using a doubly linked list. It contains the duplicate items, also maintains the order of the insertion, the class...

5 minutes read.

Difference between Aggregation and Composition in Java

What is Aggregation? Before we start discussing Aggregation, we have to know some general information about our classes in java. Generally we have two members in our classes , the first...

8 minutes read.

Java Math atan() Method

The atan() method of Math class computes the trigonometric Arc Tangent (inverse of tangent ) of an angle. The value returned is between -pi/2 to pi/2. Syntax: public static double atan(double a) Parameters: The...

2 minutes read.

Java class class

Java Class class instances are an executing Java application's implementation of the classes and interfaces. As well as, every Array is indeed an object that is common for all Arrays...

6 minutes read.

Davis Staircase Problem in Java

Davis has several stairs in his home and prefers to ascend one, two, or three steps at a time. As a highly clever youngster, he thinks about how many ways...

3 minutes read.

Java IO

It is a part of java libraries but is often known as I/O streams, file I/O, and file handling. The Java I/O concept satisfies the need for input processing and...

4 minutes read.

How to Change the Day in the Date using Java?

To operate with the date and time in Java, we need the Calendar abstract class. It provides a number of helpful interfaces that enable us to convert dates between a...

4 minutes read.

Root exception in java

Java: The main feature of java which is not in C or object oriented programming language is platform independence. Not only the platform independence there are many other features in java...

3 minutes read.

Java String toLowerCase() methods

Java String toLowerCase() method is used to convert all the characters of the String into lower case. Syntax: public String toLowerCase()              public String toLowerCase(Locale locale) Returns: It returns Lower...

1 minute read.

How to find characters with the maximum number of times in a string java

Problem statement In this problem, users want to find the maximum count of a character from the string and return the character along with its count. Your task is to create...

3 minutes read.

Magic Square in Java

A square with numbers is referred to as a magic square. The numbers in a magic square of order n are arranged to ensure that the sum of all of...

4 minutes read.

How to Convert double to int in Java

The double is a larger data type than int. When we assign a larger type value to a variable of smaller type, then we need to perform the explicit conversion....

2 minutes read.