|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> [ sql overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lutris.appserver.server.sql
Interface DBQuery

- public interface DBQuery
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 com.lutris.appserver.server.LBS;
import com.lutris.appserver.server.sql.*;
DBQuery dbQuery =
LBS.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();
}
- Since:
- LBS1.8
- Version:
- $Revision: 1.17.12.1 $
| 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 |
query
public void query(Query q) throws java.sql.SQLException
- Query the database.
next
public java.lang.Object next() throws java.sql.SQLException, ObjectIdException
- Returns a new object representing the next result form
the query.
release
public void release()
- Frees all resources consumed by this query.
Connections are returned to the connection pool.
Subsequent queries via this object,
will throw an exception.
handleException
public boolean handleException(java.sql.SQLException e)
- Exception handler. This object is should not be
used for subsequent queries if this method returns
false.
validate
public void validate()
throws java.sql.SQLException
- Method to ensure this object is still valid.
Once this object has been released it cannot be
used any more.
|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> [ sql overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC