×

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

How to Print array in Java?

A Java array is a data structure that allows us to hold components of the same data type. An array's items are kept in a single memory region. As a...

6 minutes read.

How to enable java in chrome

The Java module is huge for the Java Runtime Environment (JRE). It permits a program to work with the Java stage to run Java applets. Essentially, each of the undertakings connect...

3 minutes read.

Java Integer remainder Unsigned() method

The remainderUnsigned() method of Java Integer class returns the unsigned remainder by dividing the first and second argument. Syntax public static int remainderUnsigned(int dividend, int divisor)  Parameters The ‘dividend’ and ‘divisor’ represents the value...

1 minute read.

Comparetoignorecase in Java

In Java, the function compareToIgnoreCase ( ) is part of the String class, which is part of the java.lang package. It is used to compare any two strings while disregarding...

4 minutes read.

How to Create Singleton Class in Java

In this tutorial, we will discuss the singleton class and how to create it. Introduction Java is a purely object-oriented programming language. It consists of classes and objects. But Singleton is one...

4 minutes read.

Bin Packing Problem Java

Assigning some items with known weights to bins with consistent capacities is necessary for the bin packing problem. The goal is to use the smallest possible boxes while ensuring everything is put...

6 minutes read.

Swing Program in Java

Java Swing is part of Java Foundation Classes (JFC). The swing toolkit is used to generate Graphical User Interface (GUI) for programs written in Java. The Java swing API is...

4 minutes read.

Bubble Sort in Java

Bubble Sort in Java Bubble sort isalso known as sinking sort. It is one of the simplest sorting algorithms. In the bubble sort algorithm, the given array is traversed from left...

5 minutes read.

Java Viva Questions and Answers

Question: Explain Java programming language. Answer: It is a high-level programming language. This programming language is based on the principles of object-oriented programming. Large-scale applications can be developed by using this...

16 minutes read.

Class vs Object in Java

Java : Java is a pure object oriented language. It was introduced by James Gosling in the year 1995. The first public implementation of java was done by sun micro systems...

7 minutes read.

Java Integer getInteger() method

The getInteger() method of Integer class determines the integer value of the system property with the given name. Syntax` public static Integer getInteger(String nm) Parameters The parameter ‘nm’ represents the property name. Throws The getInteger ()...

1 minute read.

Buffer reader to read string in Java

The Buffered Reader class of Java is used to read the stream of characters from the input stream. Program to read string using Buffer reader import java.io.*; class  Demo {   public static void main(String...

3 minutes read.

Java Serialization

JAVA SERIALIZATION Serialization is a process by which objects can be represented as a sequence of bytes. These bytes have information about object's data, object's type and datatypes of members in...

3 minutes read.

Command Class in Java

We use the command class to run commands against the database. The Command class may find a set of parameter objects for use in sending values to a stored procedure...

3 minutes read.

Shopping Bill in Java

Java Shopping Bill Here in this program, we are about to create a JAVA class called Products which will have some properties or attributes like prod_name (Product Name ), qty (quantity),...

4 minutes read.

Java Case Keyword

Case keyword: In this article we are going to learn the concept of a java case keyword.Generally, java case keyword is used with the switch statements.Case keyword is implemented in conditional...

3 minutes read.

Java Integer min() method

The min()  method of Integer class returns the smaller of two int values. It returns the same result as by calling Math.min.  Syntax public static int min(int a, int b) Parameters The parameters ‘a’...

2 minutes read.

Java Boolean getBoolean() Method

The getBoolean() method of Java Boolean class returns true if the specified system property is not null and is equal to the String ‘true’, else the result returned is false. Syntax public...

1 minute read.

Short Circuit Logical Operators in Java

When there are two or more relational expressions in a decision-making statement, logical operators are utilized to combine them. The logical operators short circuit and not-short circuit fall into two...

5 minutes read.

Java Boolean compareTo() method

The compareTo() method of Java Boolean class compares the Boolean argument with the Boolean instance and returns integer value, zero, or negative 1, or positive 1 based on the result...

2 minutes read.