-
Notifications
You must be signed in to change notification settings - Fork 1
Topic 07: Relational Databases
Zhamri Che Ani edited this page May 6, 2026
·
1 revision
To introduce students to database connectivity concepts in Java using JDBC, enabling them to connect Java applications to relational databases, execute SQL statements, process query results, and develop database-driven applications.
Students should be able to:
- Explain the concept of database connectivity and JDBC architecture.
- Understand the role of JDBC interfaces such as
Driver,Connection,Statement,PreparedStatementandResultSet. - Load and configure JDBC drivers for database access.
- Establish a connection between Java applications and relational databases.
- Execute SQL statements using
StatementandPreparedStatement. - Process and retrieve data from a
ResultSet. - Perform CRUD (Create, Read, Update, Delete) operations using SQL.
- Apply parameterized queries using
PreparedStatement. - Use batch processing to execute multiple SQL statements efficiently.
- Retrieve database metadata using
DatabaseMetaData. - Develop simple Java database applications integrated with MySQL.
- Introduction to Database Applications
- Components of database systems
- Database management systems (DBMS)
- Client-server database applications
- Introduction to JDBC
- JDBC overview
- Advantages of JDBC
- JDBC architecture
- JDBC Interfaces and Components
DriverManagerConnectionStatementPreparedStatementResultSet
- Steps in JDBC Application Development
- Load JDBC driver
- Establish database connection
- Create SQL statements
- Execute queries
- Process query results
- Close resources
- Connecting Java with MySQL
- MySQL Connector/J
- JDBC URL format
- Database authentication
- Executing SQL Statements
executeQuery()executeUpdate()
- Processing Result Sets
- Navigating rows
- Retrieving column values
- Getter methods:
getInt()getString()getDouble()
- Prepared Statements
- Parameterized SQL queries
- Preventing SQL injection
-
setString(),setInt(), etc.
- Batch Processing
addBatch()executeBatch()- Performance optimization
- Database Metadata
DatabaseMetaData- Database structure information
- Supported database features
- Basic SQL for JDBC
CREATE TABLESELECTWHEREORDER BYINSERTUPDATEDELETE
Students create a Java program that:
- Connects to a MySQL database
- Displays a successful connection message
Students write SQL code and Java programs to:
- Create a
studentstable - Define columns such as:
- id
- name
- program
- cgpa
Example:
CREATE TABLE students (
id INT PRIMARY KEY,
name VARCHAR(50),
program VARCHAR(50),
cgpa DOUBLE
);Students develop a Java application that:
- Accepts student data from keyboard input
- Inserts records into the database using
PreparedStatement
Students create a program that:
- Retrieves all records using
SELECT - Displays the data using
ResultSet
Example Output:
ID Name Program CGPA
1 Ali Software Eng 3.50
2 Siti AI 3.80
Students implement:
- Record update functionality
- Record deletion functionality
- SQL queries using
WHEREclause
Students develop a Java program that:
- Inserts multiple records using batch processing
- Measures execution efficiency
Students create a program that:
- Retrieves database metadata
- Displays:
- Database name
- Driver version
- Supported SQL features
- https://docs.oracle.com/en/database/oracle/oracle-database/26/jjdbc/introducing-JDBC.html#GUID-864DB502-5E50-4044-8132-33D6AAF8927A
- JDBC Online Tutorial @ http://download.oracle.com/javase/tutorial/jdbc/index.html.
- JDBC Home Page @ http://www.oracle.com/technetwork/java/javase/jdbc/index.html.
- MySQL Home Page @ https://dev.mysql.com/, and documentation.
- MySQL 8.0 Reference Manual @ https://dev.mysql.com/doc/refman/8.0/en/.
- https://docs.oracle.com/javase/tutorial/jdbc/basics/index.html
- https://en.wikipedia.org/wiki/Java_Database_Connectivity
- https://www3.ntu.edu.sg/home/ehchua/programming/java/JDBC_Basic.html
- https://www.baeldung.com/java-jdbc
- https://medium.com/@Bharat2044/what-is-jdbc-introduction-to-java-database-connectivity-649677818a8b
- https://www.tutorialspoint.com/jdbc/index.htm
- https://www.geeksforgeeks.org/java/jdbc-tutorial/