Java

Java Database Connectivity (JDBC)

14 lessons in this section of the Java tutorial. Work through them in order, or jump to the one you need.

  1. 1.JDBC Architecture

    JDBC (Java Database Connectivity) is the standard Java API for connecting to and executing operations against relational databases, defined as a set of interfaces in…

  2. 2.JDBC Drivers

    A JDBC driver is the vendor-specific library that implements the java.sql/javax.sql interfaces for a particular database product, translating standard JDBC calls into…

  3. 3.DriverManager

    java.sql.DriverManager is the original, classic entry point into JDBC: a static factory class that maintains a registry of available Driver implementations and hands…

  4. 4.Connection

    java.sql.Connection represents a single session with a specific database — the live link through which all statements, transactions, and metadata queries flow, and the…

  5. 5.Statement

    java.sql.Statement is the base JDBC interface for sending SQL to a database and retrieving results, representing the simplest way to execute a static SQL string with no…

  6. 6.PreparedStatement

    java.sql.PreparedStatement extends Statement to support parameterized SQL: a SQL string containing one or more '?' placeholders, prepared once and then executed any…

  7. 7.CallableStatement

    java.sql.CallableStatement extends PreparedStatement to invoke database stored procedures and stored functions through a standardized JDBC escape syntax, supporting IN…

  8. 8.ResultSet

    java.sql.ResultSet represents the tabular result of a SQL query, exposing a cursor that starts positioned before the first row and is advanced one row at a time via…

  9. 9.Transactions

    A transaction is a sequence of one or more SQL operations that must succeed or fail together as a single atomic unit, and JDBC exposes transaction control directly on…

  10. 10.Batch Processing

    JDBC batch processing groups multiple SQL statements together so they can be sent to the database and executed in a single network round trip, rather than incurring the…

  11. 11.Connection Pooling

    Connection pooling maintains a set of already-open, reusable database connections so that application code can borrow one, use it, and return it, rather than paying the…

  12. 12.Metadata

    JDBC exposes two distinct families of metadata that describe different things: DatabaseMetaData, obtained from a Connection, describes the database server itself — its…

  13. 13.RowSet

    javax.sql.RowSet extends ResultSet with JavaBean-style properties and event-listener support, and its most commonly used subtype, CachedRowSet, additionally disconnects…

  14. 14.Stored Procedures

    Stored procedures are precompiled routines that live and execute inside the database itself, written in a vendor-specific procedural SQL dialect (PL/pgSQL for…