How can I run the examples from the first edition with another database than MS Access?

The first edition of the book describes how to use an MS Access database for all examples. How can I use another database?
Answer:
You can use any database you like, as long as there’s a JDBC driver for it. Just put the JDBC driver classes in the WEB-INF/lib or WEB-INF/classes directory and change the JDBC URL in the example JSP pages to point to your database. Mike Braden has been kind enough to contribute instructions for how to run the examples with Oracle.

Lucy Newman has done the same for PostgreSQL, and Masako Onishi has contributed inststructions for InstantDB.

The second edition of the book uses the JSP Standard Tag Library (JSTL) actions for all database access. The data source used by the JSTL actions is configured in the web.xmlfile for the application, to make it easier to switch between databases.

I have also included a script with all SQL statements needed to create the example tables, located in WEB-INF/examples.sql. You can use this script to create the tables in a MySQL database, and it should work fine for most other database engines as well.

Leave a Reply

Your email address will not be published. Required fields are marked *