# JDBC

***What's JDBC ??***

JDBC (Java Database Connectivity) is a Java API that allows Java applications to connect to databases, execute SQL queries, and retrieve or modify data. JDBC driver implements the database-specific communication.

![](https://cdn.hashnode.com/uploads/covers/68496e2b746e5e01f89ed801/ef03d552-8667-46e6-a561-9c6ed00120a8.png align="center")

For example, suppose you're building a Java backend for an movie Ticket-booking application. You need to store users, movies, and tickets in PostgreSQL. JDBC lets your Java code communicate with that database.

![](https://cdn.hashnode.com/uploads/covers/68496e2b746e5e01f89ed801/a4ab7070-d913-4f57-98cd-ce51460b8d7b.png align="center")

Q1. We have different db's like MySQL, PostgreSQL, Oracle DB.. so do we need seperate code, methods for each kind to DB to interact with them ??

A. No, Java created **interfaces** and **abstract classes**, (which have only method initialization but no definition) so that create an object with interface reference type and u can simply use similar methods. So **java.sql.\*** has all method definitions and DB vendors had overridden their own version of functionality. DB vendors made their group of .class files (all method bodies) into JAR.

![](https://cdn.hashnode.com/uploads/covers/68496e2b746e5e01f89ed801/683fe6d2-e4d5-427c-aad9-456d44b426f9.png align="center")
