|
OpMath | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.opmath.test.db.ContactConnection
Provides mediation between the com.opmath.util.db JDBC interface and the contact book servlet.
Demonstrates the use of DMLDoc (as contained within Open Math Utilities v010) with Tomcat 4.0 / Servlet 2.3 and a local JDBC connection.
Copyright: (c) 2002 The Open Math Company Limited
The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.
| Constructor Summary | |
ContactConnection(String className,
String path,
String user,
String pass)
Constructs a new ContactConnection instance, which mediates between the contact servlet and the database adapter. |
|
| Method Summary | |
void |
close()
Closes the database. |
void |
create(String given,
String family,
String email,
String phone)
Creates a new contact book entry. |
void |
createTable()
Creates a new contact book table in the database. |
void |
delete(int id)
Delets an existing contact book entry with the given unique ID. |
ResultSet |
query(String given,
String family)
Selects contact book records whose given name or family name fields are similar to those in the given parameters. |
ResultSet |
read(int id)
Finds one contact book entry with the given unique ID. |
ResultSet |
readAll()
Finds all contact book records. |
void |
update(int id,
String given,
String family,
String email,
String phone)
Updates an existing contact book entry. |
| Methods inherited from class java.lang.Object |
|
| Constructor Detail |
public ContactConnection(String className,
String path,
String user,
String pass)
throws ClassNotFoundException,
SQLException
Constructs a new ContactConnection instance, which mediates between the contact servlet and the database adapter. A database connection is opened.
className - a String naming the class of the database
adapter for DBObject.path - a String giving the absolute path to the
directory used by the embedded database driver.user - a String for the database username.pass - a String for the database password.ClassNotFoundException - if the class className
cannot be accessed.SQLException - if a database connection cannot be established.| Method Detail |
public void createTable()
throws SQLException
Creates a new contact book table in the database. The fields are contactId (the primary key) givenName, familyName, emailAddress, and phoneNumber
SQLException - if the table could not be created.
public void close()
throws SQLException
Closes the database. (In the case of a remote database, the client connection is closed. In the case of an embedded database, the driver is 'shut down'.) Once the database is closed, this class only allows it to be reopened by creating a new instance.
SQLException - if the database could not be closed.
public ResultSet readAll()
throws SQLException
Finds all contact book records. The returned result set is sorted by family name, then given name.
ResultSet carrying the retrieved data.SQLException - if the find operation failed.
public ResultSet read(int id)
throws SQLException
Finds one contact book entry with the given unique ID.
id - an int supplying the unique ID.ResultSet carrying the retrieved data.SQLException - if the find operation failed.
public ResultSet query(String given,
String family)
throws SQLException
Selects contact book records whose given name or family name fields are similar to those in the given parameters. If oneor other parameter is the empty string, it is treated as a wildcard. The returned result set is sorted by family name, then given name.
given - a String specifying the given name field.family - a String specifying the family name field.ResultSet carrying the retrieved data.SQLException - if the query could not be completed.
public void create(String given,
String family,
String email,
String phone)
throws SQLException
Creates a new contact book entry. The new entry will have givenName, familyName, emailAddress, and phoneNumber fields as specified by the given paramters.
The primary key value of the new contact book entry is calculated by selecting the highest existing primary key value, and adding 1. (The primary keyis set to 1 if this is the first record in the contact book.)
given - a String specifying the givenName field.family - a String specifying the familyName field.email - a String specifying the emailAddress field.phone - a String specifying the phoneNumber field.SQLException - if the add operation could not be completed.
public void update(int id,
String given,
String family,
String email,
String phone)
throws SQLException
Updates an existing contact book entry. All fields of the contact book record are updated, with the exception of the primary key.
given - a String specifying the new givenName value.family - a String specifying the new familyName value.email - a String specifying the new emailAddress value.phone - a String specifying the new phoneNumber value.SQLException - if the update operation could not be completed.
public void delete(int id)
throws SQLException
Delets an existing contact book entry with the given unique ID.
id - an int supplying the unique ID.SQLException - if the delete operation could not be completed.
|
OpMath | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||