Home All about JAVA JDBC in Java | What is Java Data Base Connectivity ?

JDBC in Java | What is Java Data Base Connectivity ?

JDBC in Java | What is Java DataBase Connectivity?

Java is used for adding and executing queries with the JDBC database. The JDBC uses JDBC engines to communicate with the database.

We can use the JDBC API to access tabular data stored in any relational database. With the JDBC API, we can save, update, delete, and restore data from the database. This is similar to the Open Database (ODBC).


JDBC full form Java DataBase Connectivity.

JDBC with Java

JDBC for connecting to a Java database is a standard Java API with a separate connection between Java development languages ​​and multiple databases.

The JDBC set includes an API for the following tasks related to database usage.

  1. Turn your organization into a source of detailed information.
  2. Create SQL or MySQL statements.
  3. View and modify cause records.

Basically, JDBC is a requirement that provides a complete set of connections that allows you to get a complete database. Java is used to various types of executables-

  • Java Applications
  • Java Applets
  • Java Servlets
  • Java ServerPages (JSPs)
  • Business JavaBeans (EJBs).

It performs various executable files to access the JDBC Motorists database and take advantage of stored data.

JDBC provides features such as ODBC, allowing Java applications to extract code outside the database.

We Use JDBC in Java

Prior to JDBC, the ODBC API was an API database for adding and running queries to a database. The ODBC API uses an ODBC driver written in the O language (ie, platform-dependent and certified). Therefore, Java has identified an API (JDBC API) used by JDBC drivers (written in Java).

We can control the JDBC API with Java and use it to do the following:

  1. Connect to the database
  2. Request and update statements in the database
  3. Get the result from the database.

   Read more about :

                                              Detail about JavaFX

JDBC in Java Architecture

The JDBC API allows you to get detailed two-tier and three-tier management models about access to resources, but the JDBC Framework has two levels.

JDBC API: Provides the JDBC administrator application.

JDBC Auto Owner API: JDBC Manager enables connection.

The JDBC API uses a separate manager and database engine to provide a real connection to resources for various data.

The JDBC Motor Manager ensures that the correct instructions are used to access each data resource. A motorist-manager can help several drivers who are connected to different heterogeneous retail resources at the same time.

Common JDBC in Java Components

DriverManager: These classes manage the list of database drivers. Adapts connection requests to a java application using a sub-method with detailed resource engines. The first cars to recognize the sub-protocol under JDBC used it to create a detailed resource connection.

Driver: This interface manages the emails of the database server. Aspects of the car owner directly connect you. Instead, you use DriverManager aspects that manage aspects of this type.

Connection: This interface has all the methods for calling a database. The text item represents the connection view.

Statement: You use this aspect created from this interface to publish SQL statements to a database. Some of the proposed connections support certain aspects in addition to the performance of the stored technique.

ResultSet: This information stores the data retrieved from the database after applying the SQL query statement aspects. It acts as a stimulant to move its parts.

SQLException: These types manage errors that occur in a detailed resource program.

Steps to create JDBC in Java Application

  1. Import the packages: first, you need to include the packages containing the JDBC classes needed for database programming. Most often, using import java.sql.*.
  2. Register the JDBC driver: Second, you can register the JDBC driver.
  3. Open a connection: Third, you can use the getConnection() method to create a Connection object, which represents a physical connection with the database.
  4. Execute a query: Fourth you can require using an object of type Statement for building and submitting an SQL statement to the database.
  5. Extract data from the result set: Fifth you can requires that you use the appropriate getXXX() method to retrieve the data from the result set.
  6. Clean up the environment: Last you can require closing all database resources on the JVM’s garbage collection.

Steps :—>

  1. importsql.*;
  2. classMysqlCon{
  3. publicstatic void main(String args[]){

    JDBC with Java
  4. try{
  5. forName(“com.mysql.jdbc.Driver”);
  6. Connection con=DriverManager.getConnection(
  7. “jdbc:mysql://localhost:3306/sonoo”,”root”,”root”);
  8. Statement stmt=con.createStatement();
  9. ResultSet rs=stmt.executeQuery(“select * from emp”);
  10. while(rs.next())
  11. out.println(rs.getInt(1)+”  “+rs.getString(2)+”  “+rs.getString(3));
  12. close();
  13. }catch(Exception e){ System.out.println(e);}
  14. }
  15. }

JDBC Driver 

Type 1: JDBC-ODBC Bridge Diver

Type 1 driver includes ODBC drivers installed on the client machine with the JDBC bridge. ODBC also configures the data source name (DSN) that represents the target database.

Type 2: JDBC-Native API

In a Type 2 driver, JDBC API calls are converted to local C / C ++ API calls that are specific to the database. These instructions are provided by the database providers and apply to the same JDBC-ODBC bridge. The driver for the supplier must be installed on each customer’s machine.

Type 3: JDBC-Net pure Java

Type 3 drivers use a three-level view to access the database. JDBC clients use standard networking standards to communicate with a central application server. The information about the socket is returned by the central application server to the required call format in the DBMS and sent to the database server.

Type 4: 100% Pure Java

In a Type 4 driver, a simple Java-based driver communicates directly with the supplier’s database through an outlet connection. This is a high-performance driver available in the database and provided by the developer.

The JDBC 4.0 Packages (JDBC in Java)

Java.sql and javax.sql – JDBC 4.0. This guide is the latest version of JDBC at the time of writing. It offers basic training programs for getting resources for your website.

The new features in these provide include changes in the following areas −

Automatic details resource car owner running.

Exception managing developments.

Enhanced BLOB/CLOB performance.

Connection and announcement interface developments.

National character set support.

SQL ROWID access.

SQL 2003 XML details type support.





Please enter your comment!
Please enter your name here

Most Popular

How to download Elyments App?  

Download and Uses of Elyments App Elyments App is the first Indian social media app. This app helps to access many social media like Facebook,...

What is ADSL? Detail about ADSL

What is ADSL The ADSL is a distance-sensitive technology. This is because the quality of the signal and the internet speed depends on the user's...

What is Digital Subscriber Line (DSL)

What is Digital Subscriber Line (DSL) Digital Subscriber Line (DSL) is a very common and important thing of broadband internet connection. DSL connects the internet...

Internet access technology

Internet access technology Internet access technology is techniques that provide the connection types between user and internet service providers. The rapid growth of the Internet...