O'Reilly logo

Jakarta Struts Cookbook by Bill Siggelkow

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.7. Accessing Message Resources from a Database

Problem

You want to store all labels, messages, and other static text in a database rather than a properties file, while still being able to access the values using the bean:message tag.

Solution

  1. Download the OJBMessageResources distribution from http://prdownloads.sourceforge.net/struts/ojb-message-resources.zip?download.

  2. Extract the ZIP file into a directory on your computer.

  3. Copy the ojb-msg-res.jar file from the ojb-message-resources/dist folder into your application's WEB-INF/lib folder.

  4. Copy the properties, XML, and DTD files from the ojb-message-resources/config folder to your application's src folder. When you build your application, these files must be copied to the WEB-INF/classes folder.

  5. Create the tables to hold the Objec Relational Bridge (OJB) metadata tables. OJB uses these tables to keep internal mapping information. Example 2-12 shows the data definition SQL that creates these tables for the MySQL database. These statements for other databases are included with the OJB distribution.

Example 2-12. OJB metadata DDL (MySQL)

CREATE TABLE ojb_dlist ( ID int NOT NULL default '0', SIZE_ int default NULL, PRIMARY KEY (ID) ) TYPE=MyISAM; CREATE TABLE ojb_dlist_entries ( ID int NOT NULL default '0', DLIST_ID int NOT NULL default '0', POSITION_ int default NULL, OID_ longblob, PRIMARY KEY (ID) ) TYPE=MyISAM; CREATE TABLE ojb_dmap ( ID int NOT NULL default '0', SIZE_ int default NULL, PRIMARY KEY (ID) ) TYPE=MyISAM; CREATE TABLE ojb_dmap_entries ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required