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.Connection; 018 import java.sql.ResultSet; 019 import java.sql.SQLException; 020 import java.sql.Statement; 021 022 /** 023 * A wrapper around {@link java.sql.Statement} or 024 * {@link java.sql.PreparedStatement} which hides the differences 025 * between the two. 026 * 027 * @author Howard Lewis Ship 028 * @see org.apache.tapestry.contrib.jdbc.StatementAssembly#createStatement(Connection) 029 * 030 **/ 031 032 public interface IStatement 033 { 034 /** 035 * Returns the SQL associated with this statement. 036 * 037 **/ 038 039 String getSQL(); 040 041 /** 042 * Returns the underlying {@link java.sql.Statement} 043 * (or {@link java.sql.PreparedStatement}). 044 * 045 **/ 046 047 Statement getStatement(); 048 049 /** 050 * Closes the underlying statement, and nulls the reference to it. 051 * 052 **/ 053 054 void close() throws SQLException; 055 056 /** 057 * Executes the statement as a query, returning a {@link ResultSet}. 058 * 059 **/ 060 061 ResultSet executeQuery() throws SQLException; 062 063 /** 064 * Executes the statement as an update, returning the number of rows 065 * affected. 066 * 067 **/ 068 069 int executeUpdate() throws SQLException; 070 }