Added a simple sql query handler

This commit is contained in:
Ziver Koc 2011-01-21 18:34:23 +00:00
parent 7aa180f512
commit b31bd5c853
2 changed files with 30 additions and 7 deletions

View file

@ -0,0 +1,27 @@
package zutil.db.handler;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import zutil.db.SQLResultHandler;
/**
* Returns the first column of the first row from the query
*
* @author Ziver
*/
public class SimpleResultHandler<T> implements SQLResultHandler<T> {
/**
* Is called to handle an result from an query.
*
* @param stmt is the query
* @param result is the ResultSet
*/
@SuppressWarnings("unchecked")
public T handleQueryResult(Statement stmt, ResultSet result) throws SQLException{
if( result.next() )
return (T) result.getObject(1);
return null;
}
}