/* XBN Java: Generically useful, non-GUI Java code. http://sourceforge.net/projects/xbnjava Copyright (C) 1997-2003, Jeff Epstein All rights reserved. Modifications: No Redistribution in binary form, with or without modifications, are permitted provided that the following conditions are met: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * If modifications are made to source code then this license should indicate that fact in the "Modifications" section above. * Neither the author, nor the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [NOTE: This license contains NO advertising clause.] */ package xbn.db; import xbn.XBNObject; import java.sql.SQLException; import java.sql.Statement; /**
A convenience class to manage a Statement, and the associated DBConnDirect and sql text.
Source code: DBConnStatement.java.
Create a DBConnStatement.
@param db_connDirect The database connection. May not be null. @param s_sql The sql statement. May not be null or zero characters in length. **/ public DBConnStatement(DBConnDirect db_connDirect, String s_sql) { this(db_connDirect, s_sql, -1, -1, false); } /**Create a DBConnStatement.
@param db_connDirect The database connection. May not be null. @param s_sql The sql statement. May not be null or zero characters in length. @param i_resultSetType See Connection.createStatement for information. @param i_resultSetConcurrency See Connection.createStatement for information. **/ public DBConnStatement(DBConnDirect db_connDirect, String s_sql, int i_resultSetType, int i_resultSetConcurrency) { this(db_connDirect, s_sql, i_resultSetType, i_resultSetConcurrency, true); } private DBConnStatement(DBConnDirect db_connDirect, String s_sql, int i_resultSetType, int i_resultSetConcurrency, boolean b_useExtraStatementParams) { throwAXIfNull(db_connDirect, "db_connDirect", sCNSTR); throwAXIfBadStr(s_sql, "s_sql", sCNSTR); dbConn = db_connDirect; sSql = s_sql; iResultSetType = i_resultSetType; iResultSetConcurrency = i_resultSetConcurrency; bUseExtraStatementParams = b_useExtraStatementParams; } /**Actually create and get the statement.
**/ public abstract Statement getStatement(); /**Get the DBConnDirect for direct manipulation.
@return db_connDirect exactly as provided to the constructor. **/ public final DBConnDirect getDBConnDirect() { return dbConn; } /**Get the sql statement.
@return s_sql exactly as provided to the constructor. **/ public final String getSql() { return sSql; } /**Get the ResultSet type.
@return i_resultSetType exactly as provided to the constructor. @exception AssertException If the two-parameter constructor was used, meaning the result set type setting was never provided. **/ public final int getRSType() { if(!wereExtraRSSettingsProvided()) { throwAX("getRSType: wereExtraRSSettingsProvided() is false. No RSType setting was provided."); } return iResultSetType; } /**Get the ResultSet concurrency.
@return i_resultSetConcurrency exactly as provided to the constructor. @exception AssertException If the two-parameter constructor was used, meaning the result set concurrency setting was never provided. **/ public final int getRSConcurrency() { if(!wereExtraRSSettingsProvided()) { throwAX("getRSConcurrency: wereExtraRSSettingsProvided() is false. No RSConcurrency setting was provided."); } return iResultSetConcurrency; } /**Were the extra ResultSet settings provided?
@return true If the four-parameter contructor was used.