JDBC Tutorial


This is complete beginners to expert up-to-date JDBC tutorial. In this tutorial, we will learn the latest features added to JDBC 4,4.1 and 4.2 release. All the source code examples in this tutorial are developed using JDK 8 with JDBC 4.2.
JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases.

JDBC Statement Interface Examples

          Example to create a table using a Statement interface.
          Example to insert multiple records in a table using Statement interface.
          Example to update a record in a table using Statement interface.
          Example to retrieve records from a table using Statement interface.
          Example to delete a record from a table using a Statement interface.
          Example to insert records in a batch process via Statement interface.
          Example to update records in a batch process via Statement interface.

JDBC PreparedStatement Interface Examples

         Example to insert a record in a table using the PreparedStatement interface.
         Example to update a record in a table using the PreparedStatement interface.
          Example to retrieve records from a table using the PreparedStatement interface.
          Example to pass a list of values to IN clause using PreparedStatement interface.
          Example to insert records in a batch process via PreparedStatement interface.
          Example to update records in a batch process via PreparedStatement interface.

JDBC CallableStatement Interface Examples

          Create and use Stored Procedure examples using the CallableStatement interface.

Insert and Retrieve Images

JDBC Transactions

          How to use JDBC transactions with examples.

JDBC SQLExceptions Handling

          In this article, we will learn how to handle SQLExceptions while working with JDBC.

JDBC java.sql Package

          In this article, we will learn commonly used methods of Connection interface with examples.
         In this article, we will learn commonly used methods of Statement interface with examples.
          In this article, we will learn commonly used methods of the PreparedStatement interface.
          In this article, we will learn commonly used methods of the CallableStatement interface.
          In this article, we will learn commonly used methods of ResultSet interface with examples.
          In this article, we will learn commonly used methods of the ResultSetMetaData interface.
          In this article, we will learn commonly used methods of DatabaseMetadata interface.
          In this article, we will learn commonly used methods of DriverManager class with examples.

JDBC Batch Processing

         Example to update records in a batch process using Statement and PreparedStatement interfaces.
         Example to insert records in a batch process using Statement and PreparedStatement interfaces.
          Example to insert records in a batch process via Statement interface.
         Example to update records in a batch process via Statement interface.
         Example to insert records in a batch process via PreparedStatement interface.
          Example to update records in a batch process via PreparedStatement interface.

JDBC + In-Memory Databases

JSP + JDBC

  • JSP + JDBC + MySQL Example -  In this article, we will build a simple Employee Registration module using JSPJDBC, and MySQL database.

JDBC FAQ

         Example to dynamically insert rows using StringBuilder and PreparedStatement placeholders ?.
         This article provides how-to to retrieve the column names of a table using the getMetaData() method.
          Example of how to use DataSource to connect with MySQL database.

Resource and Useful Links

Comments