Skip to Content
JavaServer Pages, 3rd Edition
book

JavaServer Pages, 3rd Edition

by Hans Bergsten
December 2003
Intermediate to advanced
764 pages
24h 58m
English
O'Reilly Media, Inc.
Content preview from JavaServer Pages, 3rd Edition

The DataSource Interface and JDBC Drivers

Before we get started with the examples, let’s look at how to identify the database you want to access. The JSTL actions can find this information in many different ways, to make the simple scenario simple and the more complex ones possible. In all cases, though, they get access to the database through an instance of a JDBC interface named javax.sql.DataSource.

The DataSource interface is part of the Java 2 Standard Edition (J2SE) 1.4, and for prior versions of the J2SE, it’s available in the JDBC 2.0 Optional Package. To access a database, a connection to the database must first be established. Opening a database connection is very time-consuming. A nice thing with a DataSource is that it can represent something called a connection pool. Connection pools are described in more detail in Chapter 24, but it’s exactly what it sounds like: a pool of database connections that can be shared by multiple clients. With a connection pool, a connection to the database is opened once and stays open until the application is shut down. When a database action needs a connection, it gets it from the pool through the DataSource object and uses it to execute one or more SQL statements. When the action closes the connection, the connection is returned to the pool where it can be picked up by the next action that needs it.

In addition to the DataSource, the JDBC API contains other classes and interfaces that allow a Java application to process SQL statements ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

More Servlets and JavaServer Pages™

More Servlets and JavaServer Pages™

Marty Hall

Publisher Resources

ISBN: 0596005636Errata Page