apache > db
Apache Derby Fortune Server Tutorial
 
Font size:      

Introduction

Goals

In this section you'll understand the Derby database support behind the Fortune Server. This section describes the SQL components organized into the sections below:

  • ij: Explains how to use the Derby SQL scripting tool.
  • Tables: Describes the tables in the fortunes database.
  • Functions: Describes the three SQL functions that the Fortune Server adds (tutRand, tutMatch, and tutReplace).
  • Exercise: You create your own working database, create the schema, load the data and execute SQL statements that use the SQL functions.

Fortune Server SQL Source

The FORTUNE_HOME/sql directory provides the files listed below:

File Description
create_fortunes.sql Creates the fortunes database and the tables and functions. Also populates two of the tables (fortune_meta and offensive).
update_offensive.sql Updates the fortunes.offense column based on the entries in the offensive table.
fortuneServerSql.jar Contains classes that implement the SQL functions.

Shut Tomcat Down

This section of the Fortune Server tutorial uses ij. You'll create your own database to work with, but it will also be useful to connect to the fortunes database.

If your Tomcat server is up from having started it in the Getting Started section, then it is connected to the fortunes database. Since a database can be accessed by only one JVM, shut it down now (CATALINA_HOME/bin/shutdown.sh).