01: /*
02: * Copyright 2005-2007 Noelios Consulting.
03: *
04: * The contents of this file are subject to the terms of the Common Development
05: * and Distribution License (the "License"). You may not use this file except in
06: * compliance with the License.
07: *
08: * You can obtain a copy of the license at
09: * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
10: * language governing permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL HEADER in each file and
13: * include the License file at http://www.opensource.org/licenses/cddl1.txt If
14: * applicable, add the following below this CDDL HEADER, with the fields
15: * enclosed by brackets "[]" replaced with your own identifying information:
16: * Portions Copyright [yyyy] [name of copyright owner]
17: */
18:
19: package com.noelios.restlet.ext.jdbc;
20:
21: import java.io.Serializable;
22: import java.sql.ResultSet;
23: import java.sql.SQLException;
24: import java.sql.Statement;
25:
26: /**
27: * JDBC result wrapper. Used by the JDBC client connector as a response entity
28: * of JDBC calls.
29: *
30: * @author Jerome Louvel (contact@noelios.com)
31: */
32: public class JdbcResult implements Serializable {
33: private static final long serialVersionUID = 1L;
34:
35: /** The JDBC statement. */
36: private transient Statement statement;
37:
38: /**
39: * Constructor.
40: *
41: * @param statement
42: * The JDBC statement.
43: */
44: public JdbcResult(Statement statement) {
45: this .statement = statement;
46: }
47:
48: /**
49: * Release the statement connection. To call when result navigation is done.
50: *
51: * @throws SQLException
52: */
53: public void release() throws SQLException {
54: // One connection per jdbcResult
55: // releasing the instance means releasing the connection too
56: // and not only the statement.
57: statement.getConnection().close();
58: }
59:
60: /**
61: * Returns the result set.
62: *
63: * @return The result set.
64: * @throws SQLException
65: */
66: public ResultSet getResultSet() throws SQLException {
67: return statement.getResultSet();
68: }
69:
70: /**
71: * Returns the generated keys.
72: *
73: * @return The generated keys.
74: * @throws SQLException
75: */
76: public ResultSet getGeneratedKeys() throws SQLException {
77: return statement.getGeneratedKeys();
78: }
79:
80: /**
81: * Returns the update count.
82: *
83: * @return The update count.
84: * @throws SQLException
85: */
86: public int getUpdateCount() throws SQLException {
87: return statement.getUpdateCount();
88: }
89:
90: }
|