Java Database Connectivity (JDBC) Tutorials
- Details
- Written by Nam Ha Minh
- Last Updated on 25 October 2024   |   Print Email
This page is designed for those who are new to database programming with Java and want to have a comprehensive, well-curated list of tutorials to follow a long. Beginners will find this page a great learning resource to get started with JDBC, intermediate programmers will find it's great to refresh their knowledge, and experienced ones will find it's a helpful reference for their daily programming tasks.
You know, JDBC is an application programming interface (API) that enables Java applications working with relational databases in a standard way. JDBC acts as an abstraction layer between Java application and the database, allowing programmers to write Java code once and run that code on different databases without modifying the code - only JDBC driver needs to be changed.
The JDBC API is part of Java SE so you don't have to import any external libraries to use. Just import interfaces and classes from the two packages java.sql and javax.sql. The latest version is JDBC 4.3 which is included in Java SE 9 or newer.
1. Prerequisites for JDBC Programming:
These are two must-have JDBC references: you can find in the first one the official links and Maven dependency to get JDBC drivers for popular database systems, and the second reference helps you understand the JDBC URL syntax for different databases.
- JDBC Driver Download for common databases
- Syntax of JDBC database connection URLs for common databases
2. Fundamental JDBC Tutorials:
The following tutorials are fundamentals to learn JDBC. You will get started by creating new connection to a database server, then learn how to execute different types of queries (CRUD - Create, Retrieve, Update and Delete). The tutorial about JDBC transaction is a little more advanced, and the last one explains how to execute database stored procedures within Java applications.
- How to connect to a database
- JDBC CRUD Tutorial (Create, Retrieve, Update and Delete)
- JDBC Transactions Tutorial
- How to execute stored procedures using JDBC
3. Making Connection to a specific database:
You can find in the following articles the proven code examples about creating connection to various database systems: MySQL, Oracle, Microsoft SQL Server, PostgreSQL, SQLite, Microsoft Access, MongoDB and H2.
- Connect to MySQL database
- Connect to Oracle database
- Connect to Microsoft SQL Server database
- Connect to PostgreSQL database
- Connect to SQLite database
- Connect to Microsoft Access database
- Connect to MongoDB database
- Connect to H2 database
4. Apache Derby (JavaDB) Tutorials:
Apache Derby is a lightweight, portable database engine written in Java so it's a perfect choice for embedding small relational databases in Java applications. The following tutorials help you write code to use Apache Derby in different modes: embedded and client-server.
- Connect to Apache Derby (JavaDB)
- How to Get Started with Apache Derby (JavaDB)
- How to work with Derby in Embedded Mode
- How to work with Derby database in network client server mode
5. Advanced JDBC Tutorials:
You can find in the following articles the helpful code examples about advanced database operations such as reading database meta data, using scrollable and updatable result sets, using cached rowset, inserting binary (byte arrays) data into database. And the last tutorial about JDBC batch update will help you optimize your application in terms of updating a large amount of data to the database.
- How to insert binary data (file) to database
- How to read binary data (file) from database
- How to use Scrollable Result Sets
- How to Use Updatable Result Sets
- How to Use CachedRowSet
- How to Read Database Meta Data
- JDBC Batch Update Tutorial
6. Miscellaneous JDBC Tutorials:
Sometimes you need to get the names of all database schemas, or get the ID value of the recently-inserted record - these examples will help:
7. Other Tutorials that are based on JDBC:
Integrating JDBC with other technologies is necessary to develop completely functional database-driven applications. Practice the following tutorials to learn using JDBC in Java web applicatitions with Servlet, Spring framework and Spring Boot.
- JSP Servlet JDBC MySQL Create Read Update Delete (CRUD) Tutorial
- How to use JDBC with Spring Boot
- Spring JDBC Template Example
8. JDBC Tutorial Videos:
Like to learn following videos? Check this playlist on YouTube: Java Database Programming with JDBC