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:
- Standard API — Same coding approach for all databases
- Database Independence — Switch databases with minimal changes
- Easy Database Access — Simple, consistent interface
- SQL Execution Support — Supports SELECT, INSERT, UPDATE, DELETE
1.4 Real-Time Example
A Banking Application:
Java Program → JDBC → Bank DatabaseJDBC retrieves account details and updates balances securely.
1.5 JDBC Architecture
┌──────────────────┐
│ Java Application │
└────────┬─────────┘
↓
┌──────────────────┐
│ JDBC API │
└────────┬─────────┘
↓
┌──────────────────┐
│ DriverManager │
└────────┬─────────┘
↓
┌──────────────────┐
│ JDBC Driver │
└────────┬─────────┘
↓
┌──────────────────┐
│ Database │
└──────────────────┘Components:
- Java Application — The program that needs database access
- JDBC API — Interfaces and classes for database operations
- DriverManager — Manages JDBC drivers and creates connections
- JDBC Driver — Translates JDBC calls into database-specific calls
- Database — The actual data store
1.6 Advantages of JDBC
| # | Advantage | Explanation |
|---|---|---|
| 1 | Platform Independent | Works on all Java-supported platforms |
| 2 | Database Independent | Can connect to multiple databases |
| 3 | Standard API | Same coding approach for different databases |
| 4 | Secure | Supports authentication and authorization |
| 5 | Easy SQL Execution | Supports 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 → DatabaseFeatures:
- 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 → DatabaseFeatures:
- 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 → DatabaseFeatures:
- 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 → DatabaseExample:
Class.forName("com.mysql.cj.jdbc.Driver");Advantages:
- Fastest — Direct communication with database
- Pure Java — No native code
- Portable — Works on any platform
- Most commonly used — Industry standard
Disadvantages:
- Database-specific driver required
- One driver per database type
2.5 Driver Comparison
| Driver | Speed | Platform Independent | Client Installation | Use Case |
|---|---|---|---|---|
| Type 1 | Slow | No | ODBC required | Legacy, testing |
| Type 2 | Medium | No | Native libraries | Legacy systems |
| Type 3 | Fast | Yes | Middleware server | Enterprise web apps |
| Type 4 | Fastest | Yes | None | Modern applications |
3. JDBC Packages
3.1 java.sql Package
Contains core JDBC classes and interfaces.
Important Interfaces:
ConnectionStatementPreparedStatementCallableStatementResultSet
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
| Interface | Purpose | Example |
|---|---|---|
| Connection | Represents database connection | Connection con; |
| Statement | Executes SQL statements | Statement stmt; |
| PreparedStatement | Precompiled SQL with parameters | PreparedStatement ps; |
| CallableStatement | Calls stored procedures | CallableStatement cs; |
| ResultSet | Stores query results | ResultSet rs; |
Example:
Connection con = DriverManager.getConnection(url, user, password);3.4 JDBC Classes
| Class | Purpose |
|---|---|
| DriverManager | Creates connections |
| SQLException | Handles database exceptions |
| Types | SQL 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/databaseExample:
jdbc:mysql://localhost:3306/testComponents:
| 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 → Database6.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 → Database6.4 Limitations
- Slow Performance — Extra translation layer
- Platform Dependent — Requires ODBC
- Requires ODBC Installation — Additional setup
- 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.Driver7.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 Successful8. 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 automatically8.3 Connection Pooling Basics
What is Connection Pooling? A pool of reusable database connections.
Without Pooling:
Request → Create Connection → Execute Query → Close ConnectionWith Pooling:
Request → Connection Pool → DatabaseAdvantages:
- Faster Performance — No connection creation overhead
- Reduced Overhead — Reuse existing connections
- Better Scalability — Handle more concurrent requests
8.4 Performance Considerations
| Technique | Benefit |
|---|---|
| PreparedStatement | Faster, prevents SQL injection |
| Close Resources | Avoids memory leaks |
| Connection Pooling | Improves application performance |
8.5 Best Practices
- Use Type 4 Drivers — Fastest and most portable
- Use PreparedStatement — Prevents SQL Injection
- Close Connections — Always release resources
- Handle Exceptions — Catch
SQLException - Use Connection Pooling — Suitable for enterprise applications
9. JDBC Programming Components
9.1 Statement Objects
Three main statement types:
| Statement Type | Purpose |
|---|---|
| Statement | Simple SQL queries |
| PreparedStatement | Precompiled SQL with parameters |
| CallableStatement | Calls 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:
- Faster execution — Precompiled
- Prevents SQL Injection — Parameters are escaped
- 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:
- Executes stored procedures
- Better performance
- Reduced network traffic
9.5 Query Execution Methods
| Method | Used For | Returns |
|---|---|---|
executeQuery() | SELECT | ResultSet |
executeUpdate() | INSERT, UPDATE, DELETE | int (affected rows) |
execute() | Unknown query type | boolean |
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
| Method | Purpose |
|---|---|
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 Type | Example |
|---|---|
| INT | 101 |
| VARCHAR | Rahul |
| FLOAT | 95.5 |
| DATE | 2026-06-06 |
| BOOLEAN | TRUE |
11.2 Java Data Types
| Java Type | Example |
|---|---|
| int | 101 |
| String | Rahul |
| float | 95.5f |
| Date | new Date() |
| boolean | true |
11.3 Type Mapping
| SQL Type | Java Type |
|---|---|
| INT | int |
| BIGINT | long |
| FLOAT | float |
| DOUBLE | double |
| VARCHAR | String |
| DATE | java.sql.Date |
| TIME | java.sql.Time |
| TIMESTAMP | java.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
| Interface | Purpose |
|---|---|
| DatabaseMetaData | Information about the database and DBMS |
| ResultSetMetaData | Information about columns returned by a query |
| ParameterMetaData | Information 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: VARCHAR12.4 DatabaseMetaData Example
DatabaseMetaData dm = con.getMetaData();
System.out.println(dm.getDatabaseProductName());Output:
MySQL12.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
- Dynamic Reports — Generate reports based on table structure
- Database Analysis — Analyze schema and data types
- Admin Tools — Build database management tools
- 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
| Property | Meaning |
|---|---|
| Atomicity | All operations succeed or fail together |
| Consistency | Database remains valid |
| Isolation | Transactions execute independently |
| Durability | Changes 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 sql214. 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
- Print SQL Query — Verify the query
- Check URL — Verify connection string
- Verify Driver — Ensure driver is loaded
- Verify Credentials — Check username/password
- 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:
- Fewer database calls — One trip instead of many
- Faster execution — Reduced network latency
- 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
- Payroll Processing — Update many employee records
- Student Result Upload — Insert bulk results
- Bulk Data Import — Migrate large datasets
- 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 closing16.3 Performance Tuning
| Technique | Benefit |
|---|---|
| Connection Pooling | Reduces connection creation overhead |
| Batch Processing | Improves bulk operation speed |
| PreparedStatement | Improves 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 standards18. Key Syntax — Quick Reference
| Concept | Syntax/Example |
|---|---|
| Load Driver | Class.forName("com.mysql.cj.jdbc.Driver"); |
| Establish Connection | DriverManager.getConnection(url, user, password); |
| Create Statement | con.createStatement(); |
| Execute SELECT | stmt.executeQuery("SELECT * FROM table"); |
| Execute INSERT/UPDATE/DELETE | stmt.executeUpdate("..."); |
| Create PreparedStatement | con.prepareStatement("SELECT * FROM t WHERE id=?"); |
| Set Parameter | ps.setInt(1, 101); |
| Execute PreparedStatement | ps.executeQuery(); |
| Call Stored Procedure | con.prepareCall("{call proc()}"); |
| Process ResultSet | while (rs.next()) { rs.getString("col"); } |
| Get Column by Name | rs.getString("name"); |
| Get Column by Index | rs.getString(2); |
| Commit | con.commit(); |
| Rollback | con.rollback(); |
| Savepoint | con.setSavepoint(); |
| Batch Add | stmt.addBatch("..."); |
| Batch Execute | stmt.executeBatch(); |
| Get Metadata | rs.getMetaData(); |
| Get Column Count | meta.getColumnCount(); |
| Get Column Name | meta.getColumnName(i); |
| Get Column Type | meta.getColumnTypeName(i); |
| try-with-resources | try (Connection con = ...) { } |
19. Exam-Focused Points
- JDBC — Java API for database connectivity.
- JDBC Architecture — Application → API → DriverManager → Driver → Database.
- Driver Types — Type 1 (ODBC), Type 2 (Native), Type 3 (Network), Type 4 (Thin, best).
- Five Steps — Load → Connect → Execute → Process → Close.
- Connection URL —
jdbc:mysql://host:port/database. - Statement vs PreparedStatement — Simple vs precompiled; Prepared prevents SQL injection.
- CallableStatement — Calls stored procedures.
- executeQuery() — For SELECT, returns ResultSet.
- executeUpdate() — For INSERT/UPDATE/DELETE, returns int.
- ResultSet cursor —
next(),previous(),first(),last(). - ResultSetMetaData — Information about query columns.
- DatabaseMetaData — Information about the database.
- ACID — Atomicity, Consistency, Isolation, Durability.
- Commit/Rollback — Save/undo transaction changes.
- Savepoint — Partial rollback point.
- Batch processing — Multiple statements in one trip.
- Connection pooling — Reuse connections for performance.
- try-with-resources — Auto-close resources.
- SQLException — Handle database errors.
- Best practices — Type 4 driver, PreparedStatement, close resources, use pooling.
20. Glossary of Key Terms
| Term | Definition |
|---|---|
| JDBC | Java Database Connectivity; API for database access |
| Driver | Translates JDBC calls into database-specific calls |
| DriverManager | Manages JDBC drivers and creates connections |
| Connection | Active link to a database |
| Statement | Executes simple SQL queries |
| PreparedStatement | Precompiled SQL with parameters |
| CallableStatement | Calls stored procedures |
| ResultSet | Stores query results |
| ResultSetMetaData | Information about query columns |
| DatabaseMetaData | Information about the database |
| ACID | Atomicity, Consistency, Isolation, Durability |
| Commit | Save changes permanently |
| Rollback | Undo changes |
| Savepoint | Partial rollback point |
| Batch Processing | Multiple SQL statements in one trip |
| Connection Pooling | Reuse of database connections |
| SQL Injection | Security vulnerability prevented by PreparedStatement |
| Type 4 Driver | Pure Java thin driver; fastest and most portable |
| try-with-resources | Auto-close resources in Java 7+ |