Chapter 16: JavaServer Pages: Part II
pages 16 - 29
Acronyms
- JDBC - Java Database Connectivity
- ODBC - Open Database Connectivity
Accessing a Database in JSP Pages
- Load the JDBC driver. The driver serves as a bridge
between the JDBC (ODBC) classes and the database itself.
Follow the steps on pages 20-22 to register a
desired database as an ODBC data source.
- Define the connection URL.
- Establish the connection.
- Create a statement object.
- Execute a query or update the data.
- Process the results.
- Close the connection.
Take a look at the retrieveDB.jsp source code below. Each
of these steps is documented in the code.
- java.lang.Class
- java.sql.Connection
- java.sql.DriverManager
- java.sql.ResultSet
- java.sql.Statement
Sample Code
Exercise
Create a database that contains account names and passwords.
Construct a JSP form/program that allows a user to login.
The program should display an appropriate message depending
on whether the user entered a valid account name and password.
When you are finished, have either Jack or John verify the
functionality of your JSP program. We will also look at the
underlying code.