|
EAF 7.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Utility for querying object from a database. Allocates connections from the database connection pool, ensures the integrity of those connections, and manages result sets after a query is performed. Returns objects representing data in the database.
Example - querying a user:
import org.enhydra.dods.DODS;
import com.lutris.appserver.server.sql.*;
DBQuery dbQuery =
DODS.getDatabaseManager().createQuery(DATABASE_NAME);
// NOTE: class CustomerQuery implements Query { ... }
CustomerQuery
customerQuery = new CustomerQuery();
String [] loginIds = { "customer1", "customer2" };
try {
for (int idx=0; idx < loginIds.length; idx++) {
customerQuery.setQueryLoginId(loginIds[idx]);
dbQuery.query(customerQuery); // query the database
// Print all query results.
CustomerDO customerResult;
while ((customerResult =
(CustomerDO)dbQuery.next()) != null) {
System.out.println("Customer name for " +
loginIds[idx] +
" is " + customerResult.getName());
}
}
}
finally {
//
// Return database connections used by
// this object back to the connection pool
// and free any other resources consumed
// by this object.
//
dbQuery.release();
}
| Method Summary | |
boolean |
handleException(java.sql.SQLException e)
Exception handler. |
java.lang.Object |
next()
Returns a new object representing the next result form the query. |
void |
query(Query q)
Query the database. |
void |
release()
Frees all resources consumed by this query. |
void |
validate()
Method to ensure this object is still valid. |
| Method Detail |
public void query(Query q)
throws java.sql.SQLException
q - Query interface via which the query will be executed.
java.sql.SQLException - If a database access error occurs.
public java.lang.Object next()
throws java.sql.SQLException,
ObjectIdException
java.sql.SQLException - If a database access error occurs.
ObjectIdException - If ObjectId was not found.public void release()
public boolean handleException(java.sql.SQLException e)
public void validate()
throws java.sql.SQLException
java.sql.SQLException - If a database access error occurs.
|
EAF 7.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||