📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
✅ Some premium posts are free to read — no account needed. Follow me on Medium to stay updated and support my writing.
🎓 Top 10 Udemy Courses (Huge Discount): Explore My Udemy Courses — Learn through real-time, project-based development.
▶️ Subscribe to My YouTube Channel (172K+ subscribers): Java Guides on YouTube
In this tutorial, we use the MySQL Connector/J driver. It is the official JDBC driver for MySQL.
What is JDBC API?
Java Database Connectivity or JDBC API provides industry-standard and database-independent connectivity between the Java applications and relational database servers(relational databases, spreadsheets, and flat files).Using the JDBC API, we can access virtually any data source, from relational databases to spreadsheets and flat files. JDBC technology also provides a common base on which tools and alternate interfaces can be built.
- The first part of JDBC API is part of standard java packages in java.sql package. We use java.sql package API for accessing and processing data stored in a data source (usually a relational database) using the Java programming language. For example Connection, Statement, ResultSet, etc are part of java.sql package.
- For the second part is the JDBC driver (there are four different types of JDBC drivers) A JDBC driver is a set of Java classes that implement the JDBC interfaces, targeting a specific database. The JDBC interfaces come with standard Java, but the implementation of these interfaces is specific to the database you need to connect to. Such an implementation is called a JDBC driver. For example, mysql-connector-java.jar, postgresql.7.4.jar, etc.
JDBC Driver Types
- Type 1: JDBC-ODBC bridge driver
- Type 2: Java + Native code driver
- Type 3: All Java + Middleware translation driver
- Type 4: All Java driver.
Type 1: JDBC-ODBC bridge driver
Type 2: Java + Native code driver
Type 3: All Java + Middleware translation driver
Type 4: All Java driver
How to install a JDBC driver?
JDBC API - Statement Interface Examples
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 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 API - PreparedStatement Examples
Example to update a record in a table using PreparedStatement interface.
Example to retrieve records from a table using 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 API - CallableStatement Examples
JDBC API - Transactions
How to use JDBC transactions with examples.JDBC API - SQLExceptions Handling
JDBC API - java.sql Package
In this article, we will learn commonly used methods of PreparedStatement interface.
In this article, we will learn commonly used methods of 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 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 API - 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.
Insert and Retrieve Images
Servlet + JSP + JDBC + MySQL Examples
JSP + JDBC
- JSP + JDBC + MySQL Example - In this article, we will build a simple Employee Registration module using JSP, JDBC, and MySQL database.
- JSP Registration Form + JDBC + MySQL Example - In this article, we will build a simple Employee Registration module using JSP, JDBC, and MySQL database.
- JSP Login Form + JDBC + MySQL Example - In this article, we will build a simple Login Form using JSP, JDBC and MySQL database.
JDBC API FAQ
Example to dynamically insert rows using StringBuilder and PreparedStatement placeholders ?.This article provides how to retrieve the column names of a table using getMetaData() method.
Example of how to use DataSource to connect with MySQL database.
Comments
Post a Comment
Leave Comment