01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: DbResultSetHandler.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.database;
09:
10: import com.uwyn.rife.database.queries.Query;
11: import com.uwyn.rife.tools.ExceptionUtils;
12: import java.sql.SQLException;
13: import java.util.logging.Logger;
14:
15: /**
16: * By extending this class it's possible to easily customize the behaviour of
17: * some methods in the {@link DbQueryManager} class.
18: * <p>You're able to perform custom logic with the resultset of a query by
19: * overriding the {@link #concludeResults(DbResultSet) concludeResults} method
20: * and returning an object.
21: * <p>You're not supposed to close the resultset in this method.
22: *
23: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
24: * @version $Revision: 3634 $
25: * @see DbResultSet
26: * @see DbQueryManager
27: * @since 1.0
28: */
29: public abstract class DbResultSetHandler implements Cloneable {
30: public DbStatement createStatement(DbConnection connection) {
31: return connection.createStatement();
32: }
33:
34: public DbPreparedStatement getPreparedStatement(Query query,
35: DbConnection connection) {
36: return connection.getPreparedStatement(query);
37: }
38:
39: public Object concludeResults(DbResultSet resultset)
40: throws SQLException {
41: return null;
42: }
43:
44: /**
45: * Simply clones the instance with the default clone method since this
46: * class contains no member variables.
47: *
48: * @since 1.0
49: */
50: public Object clone() {
51: try {
52: return super .clone();
53: } catch (CloneNotSupportedException e) {
54: // this should never happen
55: Logger.getLogger("com.uwyn.rife.database").severe(
56: ExceptionUtils.getExceptionStackTrace(e));
57: return null;
58: }
59: }
60: }
|