Chapter 23. Access to Databases

A database forms part of many enterprise applications, and Web applications are prime candidates for searching, displaying, and capturing data. Understanding how to use a database in a Web application is a very important part of a JSP developer's toolkit. Persistence of data is such a common requirement in modern applications that many developers consider not having any data storage or retrieval to be a mistake in the collection of requirements.

This chapter covers an introduction to databases and the standard means of accessing relational databases from Java, the JDBC API. It explores the different ways of accessing databases from a JSP, from using the <sql> tags provided by the JSTL for simple applications to more comprehensive approaches that are used as the complexity of the data model and data use increases. This exploration includes an examination of different types of common data access mechanisms using JDBC, as well as the issues associated with object-relational mapping (ORM).

Finally, the chapter looks at some other database access mechanisms, including object-relational mapping tools such as Hibernate and JDO.

This chapter covers the following topics:

  • The fundamental components used in accessing databases from Java

  • An introduction to the JDBC APIs

  • Different techniques for accessing databases

  • How to use direct JDBC calls to access a database

  • How to use Hibernate to access a database

This chapter assumes a basic working knowledge of SQL syntax and ...

Get Beginning JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.