|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsnaq.db.QueryValidator
snaq.db.SimpleQueryValidator
public class SimpleQueryValidator
ConnectionValidator
implementation that validates database
connections by issuing a SQL query, and simply checking if the query
succeeded or failed.
By default it does not check if any results are returned.
This class is provided as a convenience for providing connection validation.
Constructor Summary | |
---|---|
SimpleQueryValidator(String query)
Creates a new SimpleQueryValidator instance using the
specified SQL query string. |
|
SimpleQueryValidator(String query,
boolean checkHasResults)
Creates a new SimpleQueryValidator instance using the
specified SQL query string. |
Method Summary | |
---|---|
boolean |
checkResults(ResultSet results)
Checks the results of the SQL query to see if it indicates a valid connection. |
String |
getQueryString()
Returns the SQL query string to be issued to the database. |
Methods inherited from class snaq.db.QueryValidator |
---|
isValid |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleQueryValidator(String query)
SimpleQueryValidator
instance using the
specified SQL query string.
query
- SQL query to issue for validationpublic SimpleQueryValidator(String query, boolean checkHasResults)
SimpleQueryValidator
instance using the
specified SQL query string.
query
- SQL query to issue for validationcheckHasResults
- whether to check if any results are returnedMethod Detail |
---|
public String getQueryString()
getQueryString
in class QueryValidator
public boolean checkResults(ResultSet results) throws SQLException
return checkHasResults ? results.next() : true;such that if results-checking was specified when the instance was created then the connection is only validated if some results are returned, otherwise the simply fact of the statement being executed successfully is used for validation.
checkResults
in class QueryValidator
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 |