2011-01-21 18:34:23 +00:00
|
|
|
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
|
|
|
|
|
*/
|
2011-06-24 23:20:59 +00:00
|
|
|
public class SimpleSQLHandler<T> implements SQLResultHandler<T> {
|
2011-01-21 18:34:23 +00:00
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
}
|