001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.contrib.jdbc;
016
017 import java.sql.ResultSet;
018 import java.sql.SQLException;
019 import java.sql.Statement;
020
021 /**
022 * A wrapper around {@link java.sql.Statement} or
023 * {@link java.sql.PreparedStatement} which hides the differences
024 * between the two.
025 *
026 * @author Howard Lewis Ship
027 * @see org.apache.tapestry.contrib.jdbc.StatementAssembly#createStatement(Connection)
028 *
029 **/
030
031 public interface IStatement
032 {
033 /**
034 * Returns the SQL associated with this statement.
035 *
036 **/
037
038 public String getSQL();
039
040 /**
041 * Returns the underlying {@link java.sql.Statement}
042 * (or {@link java.sql.PreparedStatement}).
043 *
044 **/
045
046 public Statement getStatement();
047
048 /**
049 * Closes the underlying statement, and nulls the reference to it.
050 *
051 **/
052
053 public void close() throws SQLException;
054
055 /**
056 * Executes the statement as a query, returning a {@link ResultSet}.
057 *
058 **/
059
060 public ResultSet executeQuery() throws SQLException;
061
062 /**
063 * Executes the statement as an update, returning the number of rows
064 * affected.
065 *
066 **/
067
068 public int executeUpdate() throws SQLException;
069 }