Programming in Java

Unit 14: JDBC Database Programming

From raw SQL to enterprise CRUD apps — master JDBC architecture, driver types, PreparedStatement, transactions, and build real database applications in Java.

⏱️ Time to Complete: 7 hrs theory + 6 hrs lab  |  💰 Earning Potential: ₹10K–₹40K/month  |  📝 30 MCQs (Bloom's Mapped)

💼 Jobs this unlocks: Java Backend Developer (₹5–10 LPA)  |  Full-Stack Developer (₹6–14 LPA)  |  Database Application Developer (₹4–8 LPA)

Section A

Opening Hook — The Database Behind Every Ticket

🚂 How IRCTC Handles 12 Lakh Simultaneous Database Queries During Tatkal

Every morning at 10:00 AM, millions of Indians slam the IRCTC booking page. In a 60-second Tatkal window, the system handles 12 lakh (1.2 million) simultaneous database queries. Each search, each seat check, each booking confirmation is a JDBC PreparedStatement flying through a managed connection pool to an Oracle/PostgreSQL database backend.

Behind the scenes, IRCTC's Java application servers maintain pools of pre-opened database connections (using HikariCP/C3P0). When you click "Book Now," your request grabs a connection from the pool, executes a parameterised SQL query (SELECT available_seats FROM trains WHERE train_no=? AND date=?), reads the ResultSet, and if seats exist, fires an INSERT INTO bookings — all within 200 milliseconds.

Every ticket you book = one JDBC call. Every "Seat not available" pop-up = another JDBC call. Every payment confirmation = yet another JDBC call. Without JDBC, there is no IRCTC, no online banking, no e-commerce checkout, no digital India.

🇮🇳 IRCTC🇮🇳 SBI YONO🇮🇳 Paytm🇮🇳 Infosys🇮🇳 TCS🇮🇳 Flipkart
India processes over 10 billion UPI transactions per month. Every single one of those transactions involves multiple JDBC calls — checking balance, debiting sender, crediting receiver, logging audit trail. That's 40+ billion JDBC operations per month just for UPI alone. The java.sql package is literally the backbone of India's digital payments infrastructure.
Section B

Learning Outcomes — Bloom's Taxonomy Mapped

Bloom's LevelLearning Outcome
🔵 RememberList the four components of JDBC API (Driver, Connection, Statement, ResultSet) and name the four JDBC driver types
🔵 RememberRecall the syntax for DriverManager.getConnection() and the steps to execute a SQL query in Java
🟢 UnderstandExplain the difference between Statement, PreparedStatement, and CallableStatement with real-world examples
🟢 UnderstandDescribe how SQL injection attacks work and why PreparedStatement prevents them
🟡 ApplyWrite complete Java CRUD programs (INSERT, SELECT, UPDATE, DELETE) using PreparedStatement with MySQL
🟡 ApplyImplement transaction management using setAutoCommit(false), commit(), and rollback()
🟠 AnalyzeCompare the four JDBC driver types and determine which is suitable for different deployment scenarios
🟠 AnalyzeAnalyze connection pooling benefits and diagnose connection leak problems in a Java application
🔴 EvaluateEvaluate whether a given code snippet is vulnerable to SQL injection and propose fixes
🔴 EvaluateAssess the trade-offs between batch processing vs individual inserts for bulk data operations
🟣 CreateDesign and build a complete College Library CRUD application with MySQL backend
🟣 CreateArchitect a Student Marks Entry System with transaction-safe multi-table updates