Skip to main content

JDBC

Updated 1 min readMarkdown

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.

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.

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.

No comments yet. Be the first to comment.