A simple MySQL interface for JXTA Search

The design of JXTA Search promotes information discovery by providing a mechanism formalizing database searches using a simple XML-derived markup language called the Query Response Protocol (QRP). Many web sites already have existing database capabilities driven by any number of database servers. The JXTA Search Database Servlet classes are designed to provide an example of a simple Java Servlet and MySQL database driven back end, useful for fielding queries on a JXTA Search network. In the near future, these classes will be extended to allow any JXTA peer to implement a database for handling queries.

Design

The net.jxta.search.dbadapter package is simple and small by design. The emphasis is on providing a running example that is quickly implemented. The code may be useful for extending to more sophisticated purposes.

The example uses a small database of URLs and descriptions from the field of civil engineering. The user provides a query term or terms, which is processed by a query handler (upper cased, white space collapsed), then passed to a table in a MySQL database. The code uses a single database ("jxtaserach") with a single table ("rockeng"). The username of the table is currently root with no password. In a production environment, this username-password should be set to values appropriate to the environment.

Currently, query handling uses implicit quoting. That is, query terms are concatenated and white space collapsed to form the term used for querying the database back end. This has the advantage of being very simple to implement. The disadvantage is that the user might form an otherwise reasonable query that returns no results from the database search.

The MySQL database server

Since most of what is available via the web exists in databases and not as static web pages, the ability to interact with databases using a web application interface potentially opens up an enormous amount of information. Existing search engines such as Google store information from statuc web pages, and even with hundreds of millions of documents stored, finding the correct document or set of documents can be hot or miss, often just plain miss. This is the "recall" problem of information retrieval, where recall is defined as the the ability of a search to return relevant documents. To improve recall, JXTA Search requires a information provider registration. Each node on a JXTA Search network uses the registration (a simple XML-derived markup) to announce it's capability to provide relevant results for a set of search terms.

In this example web application for database/servlet JXTA Search node, a very simple database of highly specialized terms related to rock engineering will be constructed. There is nothing especially significant about rock engineering, and the narrowness of the field serves both to emphasize a few widely disseminated links on the web at the same time as burying links which may provide results with high relevance. Thus, nodes providing information relevant to rock engineering are good candidates for the JXTA Search network.

For this simple servlet web application, the MySQL database server has a number of attractive qualities. Firstly, it's either free or inexpensive. Binaries for most platforms (MS Windows, Linux, several Unix systems including Solaris) are available as free downloads. Secondly, the documentation available for download or on the web site is pretty good. Database systems are intrinsically complicated beasts, and the MySQL documentation, while terse, is complete and accurate enough for this example application. For this article, it's assumed that a MySQL database is already installed, that the reader has root access to the server, or has a sympathetic database administrator willing to spend a few minutes time setting it up.

Setting it up

After the MySQL server is installed, several more tasks must be accomplished. First, a database for the servlet must be created, and then a user with the appropriate security must be created to have access to that database. For this example, the database is named jxtasearch, and may be created from the MySQL client prompt:

mysql> create database jxtasearch;
Next, a table called rockeng for the data:
mysql> create table rockeng (TERM VARCHAR(32),
    -> TITLE VARCHAR(100),
    -> URL VARCHAR(250),
    -> DESCRIPTION VARCHAR(250)); 
Then, the table containing all of the data needs to be loaded into the jxtasearch database. First, switch to the jxtasearch database:
mysql> use jaxtasearch;
The jxtasearch.txt file contains a few lines of information about some specialized rock engineering web sites, each field separated by tab characters. The following command will load all the data in this file into the rockeng table.
mysql> load data local infile "jxtasearch.txt" into table rockeng;
Now, the servlet user must be created. For this example we make the username jxtasearch with password limestone:
mysql > grant select on jxtasearch.rockeng to 
     -> jxtasearch@localhost identified by 'limstone';
This last command allows a user named jxtasearch (the servlet) the privilege of issuing an SQL SELECT statement on the table called rockeng in the database jxtasearch. This user has no other privileges, that is, the usr cannot issue any other SQL statements on any other table in the jxtasearch database.


$Id: design.html,v 1.2 2001/06/13 23:52:46 ddoolin Exp $