BTCE | 5th Sem
Adv-Java SubjectUnit 3

Adv-Java Unit 3: Complete Concept Guide

Unit 3: The Concept of JDBC -> Generated and Prepared By Thiruselvan (ThiruXD)

1. Introduction to JDBC

1.1 What is JDBC?

JDBC (Java Database Connectivity) is a Java API that allows Java applications to:

  • Connect to databases
  • Execute SQL queries
  • Process results

JDBC acts as a bridge between Java applications and databases. It is part of the java.sql package and provides a standard interface for database access.

1.2 JDBC Workflow

┌──────────────────┐
│ Java Application │
└────────┬─────────┘
         ↓
┌──────────────────┐
│      JDBC        │
└────────┬─────────┘
         ↓
┌──────────────────┐
│   JDBC Driver    │
└────────┬─────────┘
         ↓
┌──────────────────┐
│    Database      │
│ (MySQL, Oracle,  │
│  SQL Server)     │
└──────────────────┘

1.3 Need for JDBC

Before JDBC:

  • Each database had its own API
  • Programs were database-dependent
  • Changing databases required rewriting code

JDBC Provides:

  1. Standard API — Same coding approach for all databases
  2. Database Independence — Switch databases with minimal changes
  3. Easy Database Access — Simple, consistent interface
  4. SQL Execution Support — Supports SELECT, INSERT, UPDATE, DELETE

1.4 Real-Time Example

A Banking Application:

Java Program → JDBC → Bank Database

JDBC retrieves account details and updates balances securely.

1.5 JDBC Architecture

┌──────────────────┐
│ Java Application │
└────────┬─────────┘
         ↓
┌──────────────────┐
│    JDBC API      │
└────────┬─────────┘
         ↓
┌──────────────────┐
│  DriverManager   │
└────────┬─────────┘
         ↓
┌──────────────────┐
│   JDBC Driver    │
└────────┬─────────┘
         ↓
┌──────────────────┐
│    Database      │
└──────────────────┘

Components:

  1. Java Application — The program that needs database access
  2. JDBC API — Interfaces and classes for database operations
  3. DriverManager — Manages JDBC drivers and creates connections
  4. JDBC Driver — Translates JDBC calls into database-specific calls
  5. Database — The actual data store

1.6 Advantages of JDBC

#AdvantageExplanation
1Platform IndependentWorks on all Java-supported platforms
2Database IndependentCan connect to multiple databases
3Standard APISame coding approach for different databases
4SecureSupports authentication and authorization
5Easy SQL ExecutionSupports SELECT, INSERT, UPDATE, DELETE

2. JDBC Driver Types

A JDBC Driver converts JDBC calls into database-specific calls.

2.1 Type 1: JDBC-ODBC Bridge Driver

Java Program → JDBC → ODBC Driver → Database

Features:

  • Uses ODBC (Open Database Connectivity)
  • Easy to configure
  • Slow performance

Example:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Advantages:

  • Easy setup
  • Can connect to any database with an ODBC driver

Disadvantages:

  • Platform dependent
  • Not recommended for production
  • Removed after Java 8

2.2 Type 2: Native API Driver

Java → Native Driver → Database

Features:

  • Uses native database libraries
  • Faster than Type 1

Advantages:

  • Faster than Type 1
  • Better performance

Disadvantages:

  • Requires native installation on client machine
  • Platform dependent

2.3 Type 3: Network Protocol Driver

Java → Middleware Server → Database

Features:

  • Uses middleware server
  • Database independent

Advantages:

  • Database independent
  • No client-side installation
  • Good for web applications

Disadvantages:

  • Additional server required
  • Extra network hop adds latency

2.4 Type 4: Thin Driver (Pure Java)

Java → Database

Example:

Class.forName("com.mysql.cj.jdbc.Driver");

Advantages:

  1. Fastest — Direct communication with database
  2. Pure Java — No native code
  3. Portable — Works on any platform
  4. Most commonly used — Industry standard

Disadvantages:

  • Database-specific driver required
  • One driver per database type

2.5 Driver Comparison

DriverSpeedPlatform IndependentClient InstallationUse Case
Type 1SlowNoODBC requiredLegacy, testing
Type 2MediumNoNative librariesLegacy systems
Type 3FastYesMiddleware serverEnterprise web apps
Type 4FastestYesNoneModern applications

3. JDBC Packages

3.1 java.sql Package

Contains core JDBC classes and interfaces.

Important Interfaces:

  • Connection
  • Statement
  • PreparedStatement
  • CallableStatement
  • ResultSet

Example:

import java.sql.*;

3.2 javax.sql Package

Provides advanced JDBC features.

Features:

  • Connection Pooling
  • RowSet
  • DataSource

Example:

import javax.sql.DataSource;

3.3 JDBC Interfaces

InterfacePurposeExample
ConnectionRepresents database connectionConnection con;
StatementExecutes SQL statementsStatement stmt;
PreparedStatementPrecompiled SQL with parametersPreparedStatement ps;
CallableStatementCalls stored proceduresCallableStatement cs;
ResultSetStores query resultsResultSet rs;

Example:

Connection con = DriverManager.getConnection(url, user, password);

3.4 JDBC Classes

ClassPurpose
DriverManagerCreates connections
SQLExceptionHandles database exceptions
TypesSQL type constants

Example:

try {
    Connection con = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
    e.printStackTrace();
}

4. JDBC Process Overview

4.1 Five Steps of JDBC

┌──────────────────┐
│ 1. Load Driver   │
└────────┬─────────┘
         ↓
┌──────────────────┐
│ 2. Establish     │
│    Connection    │
└────────┬─────────┘
         ↓
┌──────────────────┐
│ 3. Execute Query │
└────────┬─────────┘
         ↓
┌──────────────────┐
│ 4. Process       │
│    Result        │
└────────┬─────────┘
         ↓
┌──────────────────┐
│ 5. Close         │
│    Resources     │
└──────────────────┘

4.2 Step 1: Loading Drivers

Class.forName("com.mysql.cj.jdbc.Driver");

Loads the JDBC driver class into memory.

4.3 Step 2: Establishing Connection

Connection con = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/test",
    "root",
    "root"
);

4.4 Step 3: Executing Query

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM student");

4.5 Step 4: Processing Result

while (rs.next()) {
    System.out.println(rs.getString("name"));
}

4.6 Step 5: Closing Resources

rs.close();
stmt.close();
con.close();

4.7 Complete JDBC Program

import java.sql.*;

public class JdbcExample {
    public static void main(String[] args) throws Exception {
        // Step 1: Load Driver
        Class.forName("com.mysql.cj.jdbc.Driver");

        // Step 2: Establish Connection
        Connection con = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/test", "root", "root");

        // Step 3: Execute Query
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM student");

        // Step 4: Process Result
        while (rs.next()) {
            System.out.println(rs.getString("name"));
        }

        // Step 5: Close Resources
        con.close();
    }
}

5. Database Connectivity

5.1 Connection Interface

Represents an active connection with the database.

Connection con;

5.2 Establishing Connections

Connection con = DriverManager.getConnection(url, user, password);

5.3 Connection URL

MySQL URL Format:

jdbc:mysql://host:port/database

Example:

jdbc:mysql://localhost:3306/test

Components: | Part | Meaning | |——|———| | jdbc:mysql:// | Protocol and subprotocol | | localhost | Host name | | 3306 | Port number | | test | Database name |

5.4 Database Credentials

String user = "root";
String password = "root";

Used for authentication.

5.5 Complete Connection Example

Connection con = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/test",
    "root",
    "root"
);

6. JDBC/ODBC Bridge

6.1 JDBC-ODBC Architecture

Java Application → JDBC API → ODBC Driver → Database

6.2 Bridge Configuration

Step 1: Create ODBC Data Source Step 2: Register JDBC-ODBC Driver

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

6.3 Connectivity Process

Java → JDBC → ODBC → Database

6.4 Limitations

  1. Slow Performance — Extra translation layer
  2. Platform Dependent — Requires ODBC
  3. Requires ODBC Installation — Additional setup
  4. Removed in Java 8 — No longer supported

7. MySQL Database Integration

7.1 MySQL Driver Setup

Download MySQL Connector/J (JDBC driver for MySQL).

Common Driver Class:

com.mysql.cj.jdbc.Driver

7.2 Connecting Java with MySQL

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/test",
    "root",
    "root"
);

7.3 Database Operations

Insert:

stmt.executeUpdate("INSERT INTO student VALUES(1,'Rahul')");

Update:

stmt.executeUpdate("UPDATE student SET name='Amit'");

Delete:

stmt.executeUpdate("DELETE FROM student");

Select:

stmt.executeQuery("SELECT * FROM student");

7.4 Connection Testing

if (con != null) {
    System.out.println("Connection Successful");
}

Output:

Connection Successful

8. Connection Management

8.1 Resource Handling

Always close resources after use.

rs.close();
stmt.close();
con.close();

8.2 Using try-with-resources

try (Connection con = DriverManager.getConnection(url, user, password)) {
    // Use connection
} // Resources close automatically

8.3 Connection Pooling Basics

What is Connection Pooling? A pool of reusable database connections.

Without Pooling:

Request → Create Connection → Execute Query → Close Connection

With Pooling:

Request → Connection Pool → Database

Advantages:

  1. Faster Performance — No connection creation overhead
  2. Reduced Overhead — Reuse existing connections
  3. Better Scalability — Handle more concurrent requests

8.4 Performance Considerations

TechniqueBenefit
PreparedStatementFaster, prevents SQL injection
Close ResourcesAvoids memory leaks
Connection PoolingImproves application performance

8.5 Best Practices

  1. Use Type 4 Drivers — Fastest and most portable
  2. Use PreparedStatement — Prevents SQL Injection
  3. Close Connections — Always release resources
  4. Handle Exceptions — Catch SQLException
  5. Use Connection Pooling — Suitable for enterprise applications

9. JDBC Programming Components

9.1 Statement Objects

Three main statement types:

Statement TypePurpose
StatementSimple SQL queries
PreparedStatementPrecompiled SQL with parameters
CallableStatementCalls stored procedures

9.2 Statement Interface

Creating a Statement:

Statement stmt = con.createStatement();

Example:

import java.sql.*;

public class StatementDemo {
    public static void main(String[] args) throws Exception {
        Connection con = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/test", "root", "root");

        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM student");

        while (rs.next()) {
            System.out.println(rs.getString("name"));
        }
        con.close();
    }
}

Advantages:

  • Easy to use
  • Suitable for static queries

Disadvantages:

  • SQL Injection risk
  • Slower for repeated execution

9.3 PreparedStatement

What is PreparedStatement? A precompiled SQL statement — the SQL is compiled once and can be executed multiple times with different parameters.

Syntax:

PreparedStatement ps = con.prepareStatement(
    "SELECT * FROM student WHERE id=?"
);

Example:

PreparedStatement ps = con.prepareStatement(
    "SELECT * FROM student WHERE id=?");
ps.setInt(1, 101);
ResultSet rs = ps.executeQuery();

Insert Example:

PreparedStatement ps = con.prepareStatement(
    "INSERT INTO student VALUES(?,?)");
ps.setInt(1, 101);
ps.setString(2, "Rahul");
ps.executeUpdate();

Advantages:

  1. Faster execution — Precompiled
  2. Prevents SQL Injection — Parameters are escaped
  3. Reusable — Can be executed multiple times

9.4 CallableStatement

What is CallableStatement? Used to call stored procedures in the database.

Syntax:

CallableStatement cs = con.prepareCall("{call procedureName()}");

Example:

Stored Procedure:

CREATE PROCEDURE getStudents()
BEGIN
    SELECT * FROM student;
END;

Java Code:

CallableStatement cs = con.prepareCall("{call getStudents()}");
ResultSet rs = cs.executeQuery();

Advantages:

  1. Executes stored procedures
  2. Better performance
  3. Reduced network traffic

9.5 Query Execution Methods

MethodUsed ForReturns
executeQuery()SELECTResultSet
executeUpdate()INSERT, UPDATE, DELETEint (affected rows)
execute()Unknown query typeboolean

Examples:

// executeQuery()
ResultSet rs = stmt.executeQuery("SELECT * FROM student");

// executeUpdate()
int rows = stmt.executeUpdate("DELETE FROM student");

// execute()
boolean result = stmt.execute(sql);

10. ResultSet Processing

10.1 Retrieving Records

ResultSet rs = stmt.executeQuery("SELECT * FROM student");

while (rs.next()) {
    System.out.println(rs.getString("name"));
}

10.2 Cursor Navigation

MethodPurpose
next()Moves forward
previous()Moves backward
first()Moves to first row
last()Moves to last row
absolute(n)Moves to nth row
relative(n)Moves n rows from current

Example:

rs.first();
System.out.println(rs.getString("name"));

10.3 Data Extraction

Using Column Name:

String name = rs.getString("name");

Using Column Index:

String name = rs.getString(2);

Example:

while (rs.next()) {
    int id = rs.getInt("id");
    String name = rs.getString("name");
    System.out.println(id + " " + name);
}

10.4 Updating Records

Updatable ResultSet allows modifications.

rs.absolute(1);
rs.updateString("name", "Amit");
rs.updateRow();

11. JDBC Data Types

11.1 SQL Data Types

SQL TypeExample
INT101
VARCHARRahul
FLOAT95.5
DATE2026-06-06
BOOLEANTRUE

11.2 Java Data Types

Java TypeExample
int101
StringRahul
float95.5f
Datenew Date()
booleantrue

11.3 Type Mapping

SQL TypeJava Type
INTint
BIGINTlong
FLOATfloat
DOUBLEdouble
VARCHARString
DATEjava.sql.Date
TIMEjava.sql.Time
TIMESTAMPjava.sql.Timestamp

Example:

int id = rs.getInt("id");
String name = rs.getString("name");

11.4 Data Conversion

JDBC performs automatic conversion.

java.sql.Date d = rs.getDate("dob");

Insert Date:

PreparedStatement ps = con.prepareStatement(
    "INSERT INTO student VALUES(?)");
ps.setDate(1, java.sql.Date.valueOf("2026-06-06"));

12. Metadata Management

12.1 What is Metadata?

Metadata means “data about data.” In JDBC, metadata provides information about:

  • Database structure
  • Tables and columns
  • Column data types
  • Query results

12.2 Main JDBC Metadata Interfaces

InterfacePurpose
DatabaseMetaDataInformation about the database and DBMS
ResultSetMetaDataInformation about columns returned by a query
ParameterMetaDataInformation about parameters in a PreparedStatement

12.3 ResultSetMetaData Example

Table: student | id | name | age | course | |—-|——|—–|——–| | 1 | Rahul | 20 | CSE | | 2 | Priya | 21 | AIML |

Java Code:

import java.sql.*;

public class MetadataExample {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/school";
        String user = "root";
        String password = "root";

        try {
            Connection con = DriverManager.getConnection(url, user, password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM student");

            ResultSetMetaData meta = rs.getMetaData();
            int columnCount = meta.getColumnCount();
            System.out.println("Number of columns: " + columnCount);

            for (int i = 1; i <= columnCount; i++) {
                System.out.println("Column Name: " + meta.getColumnName(i));
                System.out.println("Data Type: " + meta.getColumnTypeName(i));
                System.out.println();
            }

            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

Output:

Number of columns: 4
Column Name: id
Data Type: INT

Column Name: name
Data Type: VARCHAR

Column Name: age
Data Type: INT

Column Name: course
Data Type: VARCHAR

12.4 DatabaseMetaData Example

DatabaseMetaData dm = con.getMetaData();
System.out.println(dm.getDatabaseProductName());

Output:

MySQL

12.5 Schema Information

Schema describes database structure.

DatabaseMetaData dm = con.getMetaData();
ResultSet tables = dm.getTables(null, null, "%", null);

Lists all tables in the database.

12.6 Metadata Applications

  1. Dynamic Reports — Generate reports based on table structure
  2. Database Analysis — Analyze schema and data types
  3. Admin Tools — Build database management tools
  4. Data Migration — Map columns between databases

13. Transaction Processing

13.1 What is a Transaction?

A transaction is a group of SQL operations executed as a single unit.

13.2 ACID Properties

PropertyMeaning
AtomicityAll operations succeed or fail together
ConsistencyDatabase remains valid
IsolationTransactions execute independently
DurabilityChanges remain permanent

13.3 Commit Operations

Commit saves changes permanently.

con.commit();

Example:

con.setAutoCommit(false);
stmt.executeUpdate(sql1);
stmt.executeUpdate(sql2);
con.commit();

13.4 Rollback Operations

Rollback undoes changes.

con.rollback();

Example:

try {
    stmt.executeUpdate(sql);
    con.commit();
} catch (Exception e) {
    con.rollback();
}

13.5 Savepoints

Savepoints are partial rollback points.

Savepoint sp = con.setSavepoint();

Example:

stmt.executeUpdate(sql1);
Savepoint sp = con.setSavepoint();
stmt.executeUpdate(sql2);
con.rollback(sp);   // Rolls back only sql2

14. Exception Handling in JDBC

14.1 SQLException

Most JDBC errors generate SQLException.

catch (SQLException e) {
    System.out.println(e.getMessage());
}

14.2 Error Codes

catch (SQLException e) {
    System.out.println(e.getErrorCode());
}

14.3 Exception Chaining

Multiple exceptions may occur.

SQLException ex = e.getNextException();

14.4 Debugging Techniques

  1. Print SQL Query — Verify the query
  2. Check URL — Verify connection string
  3. Verify Driver — Ensure driver is loaded
  4. Verify Credentials — Check username/password
  5. Read Stack Trace — Identify the error

Example:

catch (SQLException e) {
    e.printStackTrace();
}

15. Batch Processing

15.1 What is Batch Processing?

Batch Processing executes multiple SQL statements together in one trip to the database.

15.2 Batch Updates

Statement stmt = con.createStatement();
stmt.addBatch("INSERT INTO student VALUES(1,'A')");
stmt.addBatch("INSERT INTO student VALUES(2,'B')");

15.3 Performance Optimization

Benefits:

  1. Fewer database calls — One trip instead of many
  2. Faster execution — Reduced network latency
  3. Better scalability — Handles large data volumes

15.4 Batch Execution

int result[] = stmt.executeBatch();

15.5 Complete Example

Statement stmt = con.createStatement();
stmt.addBatch("INSERT INTO student VALUES(1,'Rahul')");
stmt.addBatch("INSERT INTO student VALUES(2,'Amit')");
stmt.executeBatch();

15.6 Practical Applications

  1. Payroll Processing — Update many employee records
  2. Student Result Upload — Insert bulk results
  3. Bulk Data Import — Migrate large datasets
  4. Inventory Updates — Update stock in bulk

16. JDBC Best Practices

16.1 Secure Database Access

Use PreparedStatement:

PreparedStatement ps = con.prepareStatement(
    "SELECT * FROM user WHERE id=?");

Prevents SQL Injection by escaping parameters.

16.2 Resource Management

Always close:

rs.close();
stmt.close();
con.close();

Better Approach — try-with-resources:

try (Connection con = DriverManager.getConnection(url, user, password)) {
    // Use connection
}   // Automatic closing

16.3 Performance Tuning

TechniqueBenefit
Connection PoolingReduces connection creation overhead
Batch ProcessingImproves bulk operation speed
PreparedStatementImproves repeated query execution

16.4 Coding Standards

Use Meaningful Variable Names:

Connection connection;
PreparedStatement pstmt;
ResultSet resultSet;

Handle Exceptions Properly:

catch (SQLException e) {
    e.printStackTrace();
}

Avoid Hardcoded Values:

String url = "jdbc:mysql://localhost:3306/test";

Store in configuration file instead.


17. Unit Summary

THE CONCEPT OF JDBC
│
├── Introduction to JDBC
│   ├── Definition and workflow
│   ├── Need for JDBC
│   └── Architecture and advantages
│
├── JDBC Driver Types
│   ├── Type 1: JDBC-ODBC Bridge
│   ├── Type 2: Native API Driver
│   ├── Type 3: Network Protocol Driver
│   └── Type 4: Thin Driver (most used)
│
├── JDBC Packages
│   ├── java.sql (core)
│   ├── javax.sql (advanced)
│   ├── Interfaces: Connection, Statement, ResultSet
│   └── Classes: DriverManager, SQLException
│
├── JDBC Process (5 Steps)
│   ├── 1. Load Driver
│   ├── 2. Establish Connection
│   ├── 3. Execute Query
│   ├── 4. Process Result
│   └── 5. Close Resources
│
├── Database Connectivity
│   ├── Connection Interface
│   ├── Connection URLs
│   ├── Credentials
│   └── JDBC/ODBC Bridge
│
├── MySQL Integration
│   ├── Driver setup
│   ├── Connection
│   └── CRUD operations
│
├── Connection Management
│   ├── Resource handling
│   ├── try-with-resources
│   └── Connection pooling
│
├── JDBC Programming Components
│   ├── Statement
│   ├── PreparedStatement
│   ├── CallableStatement
│   └── Query execution methods
│
├── ResultSet Processing
│   ├── Retrieving records
│   ├── Cursor navigation
│   ├── Data extraction
│   └── Updating records
│
├── JDBC Data Types
│   ├── SQL types
│   ├── Java types
│   └── Type mapping
│
├── Metadata Management
│   ├── DatabaseMetaData
│   ├── ResultSetMetaData
│   └── Schema information
│
├── Transaction Processing
│   ├── ACID properties
│   ├── Commit
│   ├── Rollback
│   └── Savepoints
│
├── Exception Handling
│   ├── SQLException
│   ├── Error codes
│   └── Debugging
│
├── Batch Processing
│   ├── Batch updates
│   ├── Performance
│   └── Applications
│
└── Best Practices
    ├── Secure access
    ├── Resource management
    ├── Performance tuning
    └── Coding standards

18. Key Syntax — Quick Reference

ConceptSyntax/Example
Load DriverClass.forName("com.mysql.cj.jdbc.Driver");
Establish ConnectionDriverManager.getConnection(url, user, password);
Create Statementcon.createStatement();
Execute SELECTstmt.executeQuery("SELECT * FROM table");
Execute INSERT/UPDATE/DELETEstmt.executeUpdate("...");
Create PreparedStatementcon.prepareStatement("SELECT * FROM t WHERE id=?");
Set Parameterps.setInt(1, 101);
Execute PreparedStatementps.executeQuery();
Call Stored Procedurecon.prepareCall("{call proc()}");
Process ResultSetwhile (rs.next()) { rs.getString("col"); }
Get Column by Namers.getString("name");
Get Column by Indexrs.getString(2);
Commitcon.commit();
Rollbackcon.rollback();
Savepointcon.setSavepoint();
Batch Addstmt.addBatch("...");
Batch Executestmt.executeBatch();
Get Metadatars.getMetaData();
Get Column Countmeta.getColumnCount();
Get Column Namemeta.getColumnName(i);
Get Column Typemeta.getColumnTypeName(i);
try-with-resourcestry (Connection con = ...) { }

19. Exam-Focused Points

  1. JDBC — Java API for database connectivity.
  2. JDBC Architecture — Application → API → DriverManager → Driver → Database.
  3. Driver Types — Type 1 (ODBC), Type 2 (Native), Type 3 (Network), Type 4 (Thin, best).
  4. Five Steps — Load → Connect → Execute → Process → Close.
  5. Connection URL — jdbc:mysql://host:port/database.
  6. Statement vs PreparedStatement — Simple vs precompiled; Prepared prevents SQL injection.
  7. CallableStatement — Calls stored procedures.
  8. executeQuery() — For SELECT, returns ResultSet.
  9. executeUpdate() — For INSERT/UPDATE/DELETE, returns int.
  10. ResultSet cursor — next(), previous(), first(), last().
  11. ResultSetMetaData — Information about query columns.
  12. DatabaseMetaData — Information about the database.
  13. ACID — Atomicity, Consistency, Isolation, Durability.
  14. Commit/Rollback — Save/undo transaction changes.
  15. Savepoint — Partial rollback point.
  16. Batch processing — Multiple statements in one trip.
  17. Connection pooling — Reuse connections for performance.
  18. try-with-resources — Auto-close resources.
  19. SQLException — Handle database errors.
  20. Best practices — Type 4 driver, PreparedStatement, close resources, use pooling.

20. Glossary of Key Terms

TermDefinition
JDBCJava Database Connectivity; API for database access
DriverTranslates JDBC calls into database-specific calls
DriverManagerManages JDBC drivers and creates connections
ConnectionActive link to a database
StatementExecutes simple SQL queries
PreparedStatementPrecompiled SQL with parameters
CallableStatementCalls stored procedures
ResultSetStores query results
ResultSetMetaDataInformation about query columns
DatabaseMetaDataInformation about the database
ACIDAtomicity, Consistency, Isolation, Durability
CommitSave changes permanently
RollbackUndo changes
SavepointPartial rollback point
Batch ProcessingMultiple SQL statements in one trip
Connection PoolingReuse of database connections
SQL InjectionSecurity vulnerability prevented by PreparedStatement
Type 4 DriverPure Java thin driver; fastest and most portable
try-with-resourcesAuto-close resources in Java 7+

On this page

1. Introduction to JDBC1.1 What is JDBC?1.2 JDBC Workflow1.3 Need for JDBC1.4 Real-Time Example1.5 JDBC Architecture1.6 Advantages of JDBC2. JDBC Driver Types2.1 Type 1: JDBC-ODBC Bridge Driver2.2 Type 2: Native API Driver2.3 Type 3: Network Protocol Driver2.4 Type 4: Thin Driver (Pure Java)2.5 Driver Comparison3. JDBC Packages3.1 java.sql Package3.2 javax.sql Package3.3 JDBC Interfaces3.4 JDBC Classes4. JDBC Process Overview4.1 Five Steps of JDBC4.2 Step 1: Loading Drivers4.3 Step 2: Establishing Connection4.4 Step 3: Executing Query4.5 Step 4: Processing Result4.6 Step 5: Closing Resources4.7 Complete JDBC Program5. Database Connectivity5.1 Connection Interface5.2 Establishing Connections5.3 Connection URL5.4 Database Credentials5.5 Complete Connection Example6. JDBC/ODBC Bridge6.1 JDBC-ODBC Architecture6.2 Bridge Configuration6.3 Connectivity Process6.4 Limitations7. MySQL Database Integration7.1 MySQL Driver Setup7.2 Connecting Java with MySQL7.3 Database Operations7.4 Connection Testing8. Connection Management8.1 Resource Handling8.2 Using try-with-resources8.3 Connection Pooling Basics8.4 Performance Considerations8.5 Best Practices9. JDBC Programming Components9.1 Statement Objects9.2 Statement Interface9.3 PreparedStatement9.4 CallableStatement9.5 Query Execution Methods10. ResultSet Processing10.1 Retrieving Records10.2 Cursor Navigation10.3 Data Extraction10.4 Updating Records11. JDBC Data Types11.1 SQL Data Types11.2 Java Data Types11.3 Type Mapping11.4 Data Conversion12. Metadata Management12.1 What is Metadata?12.2 Main JDBC Metadata Interfaces12.3 ResultSetMetaData Example12.4 DatabaseMetaData Example12.5 Schema Information12.6 Metadata Applications13. Transaction Processing13.1 What is a Transaction?13.2 ACID Properties13.3 Commit Operations13.4 Rollback Operations13.5 Savepoints14. Exception Handling in JDBC14.1 SQLException14.2 Error Codes14.3 Exception Chaining14.4 Debugging Techniques15. Batch Processing15.1 What is Batch Processing?15.2 Batch Updates15.3 Performance Optimization15.4 Batch Execution15.5 Complete Example15.6 Practical Applications16. JDBC Best Practices16.1 Secure Database Access16.2 Resource Management16.3 Performance Tuning16.4 Coding Standards17. Unit Summary18. Key Syntax — Quick Reference19. Exam-Focused Points20. Glossary of Key Terms