|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsnaq.db.QueryValidator
public abstract class QueryValidator
Abstract ConnectionValidator implementation that validates
database connections by issuing a SQL query.
To create a simple ConnectionValidator implementation which validates using a SQL query, extend this class and implement the abstract methods.
For example, the getQueryString() method could be implemented to
return the string:
SELECT * FROM test WHERE test_id < 10;
This would cause this SQL query to be issued to the database whenever
a connection needs validating. If the query causes a SQLException
to be thrown then the validation automatically fails.
If the query completes successfully, the generated ResultSet
is then passed to the checkResults(ResultSet) method.
This class is provided as a convenience for providing connection validation.
| Constructor Summary | |
|---|---|
QueryValidator()
|
|
| Method Summary | |
|---|---|
abstract boolean |
checkResults(ResultSet results)
Checks the results of the SQL query to see if it indicates a valid connection. |
abstract String |
getQueryString()
Returns the SQL query string to be issued to the database. |
boolean |
isValid(Connection con)
Determines whether the specified connection is good to use. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public QueryValidator()
| Method Detail |
|---|
public final boolean isValid(Connection con)
throws SQLException
isValid in interface ConnectionValidatorcon - Connection instance to check for validity
SQLExceptionpublic abstract String getQueryString()
public abstract boolean checkResults(ResultSet results)
throws SQLException
results - ResultSet instance produced from SQL query
SQLException - if checking the results throws such an exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||