http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java new file mode 100644 index 0000000..be0e2ac --- /dev/null +++ b/src/main/java/org/apache/commons/dbutils2/AbstractExecutor.java @@ -0,0 +1,323 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.dbutils2; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Types; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Abstract class for executing a query, insert, update, or batch. + * + * @since 2.0 + * @author William Speirs <[email protected]> + */ +abstract class AbstractExecutor<T extends AbstractExecutor<T>> { + + private static final String COLON = ":"; // TODO: change this to any character + + private final Connection conn; + private final String sql; + private final PreparedStatement stmt; + + private final Map<String, List<Integer>> paramPosMap; + private final Map<String, Object> paramValueMap; + private Integer currentPosition = Integer.valueOf(0); + + public AbstractExecutor(final Connection conn, final String sql) throws SQLException { + this.conn = conn; + this.sql = sql; + this.paramPosMap = new HashMap<String, List<Integer>>(); + this.paramValueMap = new HashMap<String, Object>(); + + final Pattern paramPattern = Pattern.compile("(:\\w+)"); + final Matcher matcher = paramPattern.matcher(sql); + + // go through finding params + while(matcher.find()) { + insertParamPosition(matcher.group().replace(COLON, "")); + } + + // replace all of the :names with ?, and create a prepared statement + stmt = conn.prepareStatement(sql.replaceAll(":\\w+", "\\?")); + } + + /** + * Helper method to insert params and the current position into the map. + * @param param the SQL param. + */ + private void insertParamPosition(final String param) { + List<Integer> posList = paramPosMap.get(param); + + // create a new list if we need to + if(posList == null) { + posList = new ArrayList<Integer>(); + paramPosMap.put(param, posList); + } + + // increment first, so we match SQL numbering + posList.add(++currentPosition); + } + + /** + * Gets the SQL statement that was passed into the constructor. + * @return the SQL statement passed into the constructor. + */ + protected String getSql() { + return sql; + } + + /** + * Returns the underlying prepared statement. + * @return the underlying prepared statement. + */ + protected PreparedStatement getStatement() { + return stmt; + } + + /** + * Returns the underlying connection. + * @return the underlying connection. + */ + protected Connection getConnection() { + return conn; + } + + /** + * Throws an exception if there are unmapped params. + * @throws SQLException if there are unmapped params. + */ + protected void throwIfUnmappedParams() throws SQLException { + if(paramPosMap.size() != 0) { + final Set<String> unmappedParams = paramPosMap.keySet(); + final StringBuilder sb = new StringBuilder("There are unbound parameters: "); + + for(String param:unmappedParams) { + sb.append(param); + sb.append(", "); + } + + // remove the last comma + sb.delete(sb.length()-2, sb.length()); + + // throw our exception + throw new SQLException(sb.toString()); + } + } + + /** + * Binds a named parameter to a value. + * + * @param name the name of the parameter in the SQL statement. + * @param value the value of the parameter in the SQL statement. + * @return this execution object to provide the fluent style. + * @throws SQLException thrown if the parameter is not found, already bound, or there is an issue binding it. + */ + public T bind(final String name, final Object value) throws SQLException { + return bind(name, value, true); + } + + /** + * Binds null to a parameter. + * Types.VARCHAR is used as the type's parameter. + * This usually works, but fails with some Oracle and MS SQL drivers. + * @param name the name of the parameter. + * @return this execution object to provide the fluent style. + * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null. + */ + public T bindNull(final String name) throws SQLException { + return bindNull(name, Types.VARCHAR, true); + } + + /** + * Binds null to a parameter, specifying the parameter's type. + * @param name the name of the parameter. + * @param sqlType the type of the parameter. + * @return this execution object to provide the fluent style. + * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null. + */ + public T bindNull(final String name, final int sqlType) throws SQLException { + return bindNull(name, sqlType, true); + } + + /** + * Given a param name and sqlType, binds a null to that parameter. + * @param name the name of the parameter. + * @param sqlType the type of the parameter. + * @param removeFromPosMap if the param should be removed from the pos map. + * @return this + * @throws SQLException if there is an SQLException during binding. + */ + protected T bindNull(String name, int sqlType, boolean removeFromPosMap) throws SQLException { + name = name.replace(COLON, ""); // so we can take ":name" or "name" + + final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name); + + if(pos == null) { + throw new SQLException(name + " is not found in the SQL statement"); + } + + // go through and bind all of the positions for this name + for(Integer p:pos) { + stmt.setNull(p, sqlType); + } + + // add the param and value to our map + paramValueMap.put(name, null); + + // suppressed because the casting will always work here + @SuppressWarnings("unchecked") + final T ret = (T) this; + + return ret; + } + + /** + * Binds value to name, but does not do the bookkeeping. + * @param name the parameter name. + * @param value the value. + * @param removeFromPosMap if the param should be removed from the pos map. + * @return this + * @throws SQLException if there is an SQLException during binding. + */ + protected T bind(String name, final Object value, boolean removeFromPosMap) throws SQLException { + name = name.replace(COLON, ""); // so we can take ":name" or "name" + + final List<Integer> pos = removeFromPosMap ? paramPosMap.remove(name) : paramPosMap.get(name); + + if(pos == null) { + throw new SQLException(name + " is not found in the SQL statement"); + } + + // go through and bind all of the positions for this name + for(Integer p:pos) { + // TODO: need to figure out how to bind NULL + stmt.setObject(p, value); + } + + // add the param and value to our map + paramValueMap.put(name, value); + + // suppressed because the casting will always work here + @SuppressWarnings("unchecked") + final T ret = (T) this; + + return ret; + } + + /** + * Used for batch calls so we can clear the map after the addBatch call. + */ + protected void clearValueMap() { + paramValueMap.clear(); + } + + /** + * Throws a new exception with a more informative error message. + * + * @param cause The original exception that will be chained to the new + * exception when it's rethrown. + * + * @throws SQLException if a database access error occurs + */ + protected void rethrow(SQLException cause) throws SQLException { + String causeMessage = cause.getMessage(); + + if (causeMessage == null) { + causeMessage = ""; + } + + final StringBuffer msg = new StringBuffer(causeMessage); + + msg.append(" Query: "); + msg.append(sql); + msg.append(" Parameters: "); + + // loop through adding the parameter to value mappings + for(Map.Entry<String, Object> param:paramValueMap.entrySet()) { + msg.append(param.getKey()); + msg.append("="); + msg.append(param.getValue()); + msg.append(" "); + } + + final SQLException e = new SQLException(msg.toString(), cause.getSQLState(), cause.getErrorCode()); + e.setNextException(cause); + + throw e; + } + + /** + * Wrap the <code>ResultSet</code> in a decorator before processing it. This + * implementation returns the <code>ResultSet</code> it is given without any + * decoration. + * + * @param rs The <code>ResultSet</code> to decorate; never <code>null</code>. + * @return The <code>ResultSet</code> wrapped in some decorator. + */ + protected ResultSet wrap(ResultSet rs) { + return rs; + } + + /** + * Close a <code>Connection</code>. This implementation avoids closing if + * null and does <strong>not</strong> suppress any exceptions. Subclasses + * can override to provide special handling like logging. + * + * @param conn Connection to close + * @throws SQLException if a database access error occurs + */ + protected void close(Connection conn) throws SQLException { + DbUtils.close(conn); + } + + /** + * Close a <code>Statement</code>. This implementation avoids closing if + * null and does <strong>not</strong> suppress any exceptions. Subclasses + * can override to provide special handling like logging. + * + * @param stmt Statement to close + * @throws SQLException if a database access error occurs + */ + protected void close(Statement stmt) throws SQLException { + DbUtils.close(stmt); + } + + /** + * Close a <code>ResultSet</code>. This implementation avoids closing if + * null and does <strong>not</strong> suppress any exceptions. Subclasses + * can override to provide special handling like logging. + * + * @param rs ResultSet to close + * @throws SQLException if a database access error occurs + */ + protected void close(ResultSet rs) throws SQLException { + DbUtils.close(rs); + } + + +}
http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java new file mode 100644 index 0000000..41cb990 --- /dev/null +++ b/src/main/java/org/apache/commons/dbutils2/AsyncExecutor.java @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.dbutils2; + +import java.sql.SQLException; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +/** + * Convenience class for executing QueryExecutor, InsertExecutor, or UpdateExecutors asynchronously. + * + * @author William Speirs <[email protected]> + * @since 2.0 + */ +public class AsyncExecutor { + + private final ExecutorService executorService; + + /** + * Constructor for AsyncQueryRunner which uses a provided ExecutorService and underlying QueryRunner. + * + * @param executorService the {@code ExecutorService} instance used to run JDBC invocations concurrently. + * @param queryRunner the {@code QueryRunner} instance to use for the queries. + */ + public AsyncExecutor(ExecutorService executorService) { + this.executorService = executorService; + } + + /** + * Execute a {@link org.apache.commons.dbutils2.BatchExecutor}. + * @return A <code>Future</code> which returns the result of the batch call. + * @throws SQLException if a database access error occurs + */ + public Future<int[]> execute(final BatchExecutor executor) throws SQLException { + return executorService.submit(new Callable<int[]>() { + + @Override + public int[] call() throws Exception { + return executor.execute(); + } + + }); + } + + /** + * Execute a {@link org.apache.commons.dbutils2.QueryExecutor} given a handler. + * @param <T> The type of object that the handler returns + * @param handler The handler that converts the results into an object. + * @return A <code>Future</code> which returns the result of the query call. + * @throws SQLException if a database access error occurs + */ + public <T> Future<T> execute(final QueryExecutor executor, final ResultSetHandler<T> handler) throws SQLException { + return executorService.submit(new Callable<T>() { + + @Override + public T call() throws Exception { + return executor.execute(handler); + } + + }); + } + + /** + * Execute a {@link org.apache.commons.dbutils2.UpdateExecutor}. + * @param <T> The type of object that the handler returns + * @return A <code>Future</code> which returns the result of the query call. + * @throws SQLException if a database access error occurs + */ + public Future<Integer> execute(final UpdateExecutor executor) throws SQLException { + return executorService.submit(new Callable<Integer>() { + + @Override + public Integer call() throws Exception { + return executor.execute(); + } + + }); + } + + /** + * Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler. + * @param <T> The type of object that the handler returns + * @param handler The handler that converts the results into an object. + * @return A <code>Future</code> which returns the result of the query call. + * @throws SQLException if a database access error occurs + */ + public <T> Future<T> execute(final InsertExecutor executor, final ResultSetHandler<T> handler) throws SQLException { + return executorService.submit(new Callable<T>() { + + @Override + public T call() throws Exception { + return executor.execute(handler); + } + + }); + } + + /** + * Execute a {@link org.apache.commons.dbutils2.InsertExecutor} given a handler. + * @return A <code>Future</code> which returns the number of rows inserted. + * @throws SQLException if a database access error occurs + */ + public Future<Integer> execute(final InsertExecutor executor) throws SQLException { + return executorService.submit(new Callable<Integer>() { + + @Override + public Integer call() throws Exception { + return executor.execute(); + } + + }); + } + +} http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java new file mode 100644 index 0000000..361f9fa --- /dev/null +++ b/src/main/java/org/apache/commons/dbutils2/BaseResultSetHandler.java @@ -0,0 +1,1923 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.dbutils2; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Map; + +/** + * Extensions of this class convert ResultSets into other objects. + * + * According to the <i>DRY</i> principle (Don't Repeat Yourself), repeating <code>resultSet</code> + * variable inside the {@link ResultSetHandler#handle(ResultSet)} over and over for each iteration + * can get a little tedious, <code>AbstractResultSetHandler</code> implicitly gives users access to + * <code>ResultSet</code>'s methods. + * + * <b>NOTE</b> This class is <i>NOT</i> thread safe! + * + * @param <T> the target type the input ResultSet will be converted to. + * @since 1.6 + */ +public abstract class BaseResultSetHandler<T> implements ResultSetHandler<T> { + + /** + * The adapted ResultSet. + */ + private ResultSet rs; + + /** + * {@inheritDoc} + */ + @Override + public final T handle(ResultSet rs) throws SQLException { + if (this.rs != null) { + throw new IllegalStateException("Re-entry not allowed!"); + } + + this.rs = rs; + + try { + return handle(); + } finally { + this.rs = null; + } + } + + /** + * Turn the <code>ResultSet</code> into an Object. + * + * @return An Object initialized with <code>ResultSet</code> data + * @throws SQLException if a database access error occurs + * @see {@link ResultSetHandler#handle(ResultSet)} + */ + protected abstract T handle() throws SQLException; + + /** + * @param row + * @return + * @throws SQLException + * @see java.sql.ResultSet#absolute(int) + */ + protected final boolean absolute(int row) throws SQLException { + return rs.absolute(row); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#afterLast() + */ + protected final void afterLast() throws SQLException { + rs.afterLast(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#beforeFirst() + */ + protected final void beforeFirst() throws SQLException { + rs.beforeFirst(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#cancelRowUpdates() + */ + protected final void cancelRowUpdates() throws SQLException { + rs.cancelRowUpdates(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#clearWarnings() + */ + protected final void clearWarnings() throws SQLException { + rs.clearWarnings(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#close() + */ + protected final void close() throws SQLException { + rs.close(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#deleteRow() + */ + protected final void deleteRow() throws SQLException { + rs.deleteRow(); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#findColumn(java.lang.String) + */ + protected final int findColumn(String columnLabel) throws SQLException { + return rs.findColumn(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#first() + */ + protected final boolean first() throws SQLException { + return rs.first(); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getArray(int) + */ + protected final Array getArray(int columnIndex) throws SQLException { + return rs.getArray(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getArray(java.lang.String) + */ + protected final Array getArray(String columnLabel) throws SQLException { + return rs.getArray(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getAsciiStream(int) + */ + protected final InputStream getAsciiStream(int columnIndex) throws SQLException { + return rs.getAsciiStream(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getAsciiStream(java.lang.String) + */ + protected final InputStream getAsciiStream(String columnLabel) throws SQLException { + return rs.getAsciiStream(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBigDecimal(int) + */ + protected final BigDecimal getBigDecimal(int columnIndex) throws SQLException { + return rs.getBigDecimal(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBigDecimal(java.lang.String) + */ + protected final BigDecimal getBigDecimal(String columnLabel) throws SQLException { + return rs.getBigDecimal(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBinaryStream(int) + */ + protected final InputStream getBinaryStream(int columnIndex) throws SQLException { + return rs.getBinaryStream(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBinaryStream(java.lang.String) + */ + protected final InputStream getBinaryStream(String columnLabel) throws SQLException { + return rs.getBinaryStream(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBlob(int) + */ + protected final Blob getBlob(int columnIndex) throws SQLException { + return rs.getBlob(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBlob(java.lang.String) + */ + protected final Blob getBlob(String columnLabel) throws SQLException { + return rs.getBlob(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBoolean(int) + */ + protected final boolean getBoolean(int columnIndex) throws SQLException { + return rs.getBoolean(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBoolean(java.lang.String) + */ + protected final boolean getBoolean(String columnLabel) throws SQLException { + return rs.getBoolean(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getByte(int) + */ + protected final byte getByte(int columnIndex) throws SQLException { + return rs.getByte(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getByte(java.lang.String) + */ + protected final byte getByte(String columnLabel) throws SQLException { + return rs.getByte(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBytes(int) + */ + protected final byte[] getBytes(int columnIndex) throws SQLException { + return rs.getBytes(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getBytes(java.lang.String) + */ + protected final byte[] getBytes(String columnLabel) throws SQLException { + return rs.getBytes(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getCharacterStream(int) + */ + protected final Reader getCharacterStream(int columnIndex) throws SQLException { + return rs.getCharacterStream(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getCharacterStream(java.lang.String) + */ + protected final Reader getCharacterStream(String columnLabel) throws SQLException { + return rs.getCharacterStream(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getClob(int) + */ + protected final Clob getClob(int columnIndex) throws SQLException { + return rs.getClob(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getClob(java.lang.String) + */ + protected final Clob getClob(String columnLabel) throws SQLException { + return rs.getClob(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getConcurrency() + */ + protected final int getConcurrency() throws SQLException { + return rs.getConcurrency(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getCursorName() + */ + protected final String getCursorName() throws SQLException { + return rs.getCursorName(); + } + + /** + * @param columnIndex + * @param cal + * @return + * @throws SQLException + * @see java.sql.ResultSet#getDate(int, java.util.Calendar) + */ + protected final Date getDate(int columnIndex, Calendar cal) throws SQLException { + return rs.getDate(columnIndex, cal); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getDate(int) + */ + protected final Date getDate(int columnIndex) throws SQLException { + return rs.getDate(columnIndex); + } + + /** + * @param columnLabel + * @param cal + * @return + * @throws SQLException + * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar) + */ + protected final Date getDate(String columnLabel, Calendar cal) throws SQLException { + return rs.getDate(columnLabel, cal); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getDate(java.lang.String) + */ + protected final Date getDate(String columnLabel) throws SQLException { + return rs.getDate(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getDouble(int) + */ + protected final double getDouble(int columnIndex) throws SQLException { + return rs.getDouble(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getDouble(java.lang.String) + */ + protected final double getDouble(String columnLabel) throws SQLException { + return rs.getDouble(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getFetchDirection() + */ + protected final int getFetchDirection() throws SQLException { + return rs.getFetchDirection(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getFetchSize() + */ + protected final int getFetchSize() throws SQLException { + return rs.getFetchSize(); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getFloat(int) + */ + protected final float getFloat(int columnIndex) throws SQLException { + return rs.getFloat(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getFloat(java.lang.String) + */ + protected final float getFloat(String columnLabel) throws SQLException { + return rs.getFloat(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getHoldability() + */ + protected final int getHoldability() throws SQLException { + return rs.getHoldability(); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getInt(int) + */ + protected final int getInt(int columnIndex) throws SQLException { + return rs.getInt(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getInt(java.lang.String) + */ + protected final int getInt(String columnLabel) throws SQLException { + return rs.getInt(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getLong(int) + */ + protected final long getLong(int columnIndex) throws SQLException { + return rs.getLong(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getLong(java.lang.String) + */ + protected final long getLong(String columnLabel) throws SQLException { + return rs.getLong(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getMetaData() + */ + protected final ResultSetMetaData getMetaData() throws SQLException { + return rs.getMetaData(); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getNCharacterStream(int) + */ + protected final Reader getNCharacterStream(int columnIndex) throws SQLException { + return rs.getNCharacterStream(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getNCharacterStream(java.lang.String) + */ + protected final Reader getNCharacterStream(String columnLabel) throws SQLException { + return rs.getNCharacterStream(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getNClob(int) + */ + protected final NClob getNClob(int columnIndex) throws SQLException { + return rs.getNClob(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getNClob(java.lang.String) + */ + protected final NClob getNClob(String columnLabel) throws SQLException { + return rs.getNClob(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getNString(int) + */ + protected final String getNString(int columnIndex) throws SQLException { + return rs.getNString(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getNString(java.lang.String) + */ + protected final String getNString(String columnLabel) throws SQLException { + return rs.getNString(columnLabel); + } + + /** + * @param columnIndex + * @param map + * @return + * @throws SQLException + * @see java.sql.ResultSet#getObject(int, java.util.Map) + */ + protected final Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException { + return rs.getObject(columnIndex, map); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getObject(int) + */ + protected final Object getObject(int columnIndex) throws SQLException { + return rs.getObject(columnIndex); + } + + /** + * @param columnLabel + * @param map + * @return + * @throws SQLException + * @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map) + */ + protected final Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException { + return rs.getObject(columnLabel, map); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getObject(java.lang.String) + */ + protected final Object getObject(String columnLabel) throws SQLException { + return rs.getObject(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getRef(int) + */ + protected final Ref getRef(int columnIndex) throws SQLException { + return rs.getRef(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getRef(java.lang.String) + */ + protected final Ref getRef(String columnLabel) throws SQLException { + return rs.getRef(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getRow() + */ + protected final int getRow() throws SQLException { + return rs.getRow(); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getRowId(int) + */ + protected final RowId getRowId(int columnIndex) throws SQLException { + return rs.getRowId(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getRowId(java.lang.String) + */ + protected final RowId getRowId(String columnLabel) throws SQLException { + return rs.getRowId(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getSQLXML(int) + */ + protected final SQLXML getSQLXML(int columnIndex) throws SQLException { + return rs.getSQLXML(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getSQLXML(java.lang.String) + */ + protected final SQLXML getSQLXML(String columnLabel) throws SQLException { + return rs.getSQLXML(columnLabel); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getShort(int) + */ + protected final short getShort(int columnIndex) throws SQLException { + return rs.getShort(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getShort(java.lang.String) + */ + protected final short getShort(String columnLabel) throws SQLException { + return rs.getShort(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getStatement() + */ + protected final Statement getStatement() throws SQLException { + return rs.getStatement(); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getString(int) + */ + protected final String getString(int columnIndex) throws SQLException { + return rs.getString(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getString(java.lang.String) + */ + protected final String getString(String columnLabel) throws SQLException { + return rs.getString(columnLabel); + } + + /** + * @param columnIndex + * @param cal + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTime(int, java.util.Calendar) + */ + protected final Time getTime(int columnIndex, Calendar cal) throws SQLException { + return rs.getTime(columnIndex, cal); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTime(int) + */ + protected final Time getTime(int columnIndex) throws SQLException { + return rs.getTime(columnIndex); + } + + /** + * @param columnLabel + * @param cal + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar) + */ + protected final Time getTime(String columnLabel, Calendar cal) throws SQLException { + return rs.getTime(columnLabel, cal); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTime(java.lang.String) + */ + protected final Time getTime(String columnLabel) throws SQLException { + return rs.getTime(columnLabel); + } + + /** + * @param columnIndex + * @param cal + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar) + */ + protected final Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + return rs.getTimestamp(columnIndex, cal); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTimestamp(int) + */ + protected final Timestamp getTimestamp(int columnIndex) throws SQLException { + return rs.getTimestamp(columnIndex); + } + + /** + * @param columnLabel + * @param cal + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTimestamp(java.lang.String, java.util.Calendar) + */ + protected final Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + return rs.getTimestamp(columnLabel, cal); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getTimestamp(java.lang.String) + */ + protected final Timestamp getTimestamp(String columnLabel) throws SQLException { + return rs.getTimestamp(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getType() + */ + protected final int getType() throws SQLException { + return rs.getType(); + } + + /** + * @param columnIndex + * @return + * @throws SQLException + * @see java.sql.ResultSet#getURL(int) + */ + protected final URL getURL(int columnIndex) throws SQLException { + return rs.getURL(columnIndex); + } + + /** + * @param columnLabel + * @return + * @throws SQLException + * @see java.sql.ResultSet#getURL(java.lang.String) + */ + protected final URL getURL(String columnLabel) throws SQLException { + return rs.getURL(columnLabel); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#getWarnings() + */ + protected final SQLWarning getWarnings() throws SQLException { + return rs.getWarnings(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#insertRow() + */ + protected final void insertRow() throws SQLException { + rs.insertRow(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#isAfterLast() + */ + protected final boolean isAfterLast() throws SQLException { + return rs.isAfterLast(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#isBeforeFirst() + */ + protected final boolean isBeforeFirst() throws SQLException { + return rs.isBeforeFirst(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#isClosed() + */ + protected final boolean isClosed() throws SQLException { + return rs.isClosed(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#isFirst() + */ + protected final boolean isFirst() throws SQLException { + return rs.isFirst(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#isLast() + */ + protected final boolean isLast() throws SQLException { + return rs.isLast(); + } + + /** + * @param iface + * @return + * @throws SQLException + * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) + */ + protected final boolean isWrapperFor(Class<?> iface) throws SQLException { + return rs.isWrapperFor(iface); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#last() + */ + protected final boolean last() throws SQLException { + return rs.last(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#moveToCurrentRow() + */ + protected final void moveToCurrentRow() throws SQLException { + rs.moveToCurrentRow(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#moveToInsertRow() + */ + protected final void moveToInsertRow() throws SQLException { + rs.moveToInsertRow(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#next() + */ + protected final boolean next() throws SQLException { + return rs.next(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#previous() + */ + protected final boolean previous() throws SQLException { + return rs.previous(); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#refreshRow() + */ + protected final void refreshRow() throws SQLException { + rs.refreshRow(); + } + + /** + * @param rows + * @return + * @throws SQLException + * @see java.sql.ResultSet#relative(int) + */ + protected final boolean relative(int rows) throws SQLException { + return rs.relative(rows); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#rowDeleted() + */ + protected final boolean rowDeleted() throws SQLException { + return rs.rowDeleted(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#rowInserted() + */ + protected final boolean rowInserted() throws SQLException { + return rs.rowInserted(); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#rowUpdated() + */ + protected final boolean rowUpdated() throws SQLException { + return rs.rowUpdated(); + } + + /** + * @param direction + * @throws SQLException + * @see java.sql.ResultSet#setFetchDirection(int) + */ + protected final void setFetchDirection(int direction) throws SQLException { + rs.setFetchDirection(direction); + } + + /** + * @param rows + * @throws SQLException + * @see java.sql.ResultSet#setFetchSize(int) + */ + protected final void setFetchSize(int rows) throws SQLException { + rs.setFetchSize(rows); + } + + /** + * @param iface + * @return + * @throws SQLException + * @see java.sql.Wrapper#unwrap(java.lang.Class) + */ + protected final <E> E unwrap(Class<E> iface) throws SQLException { + return rs.unwrap(iface); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateArray(int, java.sql.Array) + */ + protected final void updateArray(int columnIndex, Array x) throws SQLException { + rs.updateArray(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array) + */ + protected final void updateArray(String columnLabel, Array x) throws SQLException { + rs.updateArray(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int) + */ + protected final void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + rs.updateAsciiStream(columnIndex, x, length); + } + + /** + * @param columnIndex + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, long) + */ + protected final void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + rs.updateAsciiStream(columnIndex, x, length); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream) + */ + protected final void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + rs.updateAsciiStream(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, int) + */ + protected final void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + rs.updateAsciiStream(columnLabel, x, length); + } + + /** + * @param columnLabel + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, long) + */ + protected final void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + rs.updateAsciiStream(columnLabel, x, length); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream) + */ + protected final void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + rs.updateAsciiStream(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal) + */ + protected final void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + rs.updateBigDecimal(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBigDecimal(java.lang.String, java.math.BigDecimal) + */ + protected final void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + rs.updateBigDecimal(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int) + */ + protected final void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + rs.updateBinaryStream(columnIndex, x, length); + } + + /** + * @param columnIndex + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, long) + */ + protected final void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + rs.updateBinaryStream(columnIndex, x, length); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream) + */ + protected final void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + rs.updateBinaryStream(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, int) + */ + protected final void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + rs.updateBinaryStream(columnLabel, x, length); + } + + /** + * @param columnLabel + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, long) + */ + protected final void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + rs.updateBinaryStream(columnLabel, x, length); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream) + */ + protected final void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + rs.updateBinaryStream(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBlob(int, java.sql.Blob) + */ + protected final void updateBlob(int columnIndex, Blob x) throws SQLException { + rs.updateBlob(columnIndex, x); + } + + /** + * @param columnIndex + * @param inputStream + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream, long) + */ + protected final void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + rs.updateBlob(columnIndex, inputStream, length); + } + + /** + * @param columnIndex + * @param inputStream + * @throws SQLException + * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream) + */ + protected final void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + rs.updateBlob(columnIndex, inputStream); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob) + */ + protected final void updateBlob(String columnLabel, Blob x) throws SQLException { + rs.updateBlob(columnLabel, x); + } + + /** + * @param columnLabel + * @param inputStream + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream, long) + */ + protected final void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + rs.updateBlob(columnLabel, inputStream, length); + } + + /** + * @param columnLabel + * @param inputStream + * @throws SQLException + * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream) + */ + protected final void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + rs.updateBlob(columnLabel, inputStream); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBoolean(int, boolean) + */ + protected final void updateBoolean(int columnIndex, boolean x) throws SQLException { + rs.updateBoolean(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean) + */ + protected final void updateBoolean(String columnLabel, boolean x) throws SQLException { + rs.updateBoolean(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateByte(int, byte) + */ + protected final void updateByte(int columnIndex, byte x) throws SQLException { + rs.updateByte(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateByte(java.lang.String, byte) + */ + protected final void updateByte(String columnLabel, byte x) throws SQLException { + rs.updateByte(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBytes(int, byte[]) + */ + protected final void updateBytes(int columnIndex, byte[] x) throws SQLException { + rs.updateBytes(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateBytes(java.lang.String, byte[]) + */ + protected final void updateBytes(String columnLabel, byte[] x) throws SQLException { + rs.updateBytes(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int) + */ + protected final void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + rs.updateCharacterStream(columnIndex, x, length); + } + + /** + * @param columnIndex + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, long) + */ + protected final void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + rs.updateCharacterStream(columnIndex, x, length); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader) + */ + protected final void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + rs.updateCharacterStream(columnIndex, x); + } + + /** + * @param columnLabel + * @param reader + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, int) + */ + protected final void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + rs.updateCharacterStream(columnLabel, reader, length); + } + + /** + * @param columnLabel + * @param reader + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, long) + */ + protected final void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + rs.updateCharacterStream(columnLabel, reader, length); + } + + /** + * @param columnLabel + * @param reader + * @throws SQLException + * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader) + */ + protected final void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + rs.updateCharacterStream(columnLabel, reader); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateClob(int, java.sql.Clob) + */ + protected final void updateClob(int columnIndex, Clob x) throws SQLException { + rs.updateClob(columnIndex, x); + } + + /** + * @param columnIndex + * @param reader + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateClob(int, java.io.Reader, long) + */ + protected final void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + rs.updateClob(columnIndex, reader, length); + } + + /** + * @param columnIndex + * @param reader + * @throws SQLException + * @see java.sql.ResultSet#updateClob(int, java.io.Reader) + */ + protected final void updateClob(int columnIndex, Reader reader) throws SQLException { + rs.updateClob(columnIndex, reader); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob) + */ + protected final void updateClob(String columnLabel, Clob x) throws SQLException { + rs.updateClob(columnLabel, x); + } + + /** + * @param columnLabel + * @param reader + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader, long) + */ + protected final void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + rs.updateClob(columnLabel, reader, length); + } + + /** + * @param columnLabel + * @param reader + * @throws SQLException + * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader) + */ + protected final void updateClob(String columnLabel, Reader reader) throws SQLException { + rs.updateClob(columnLabel, reader); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateDate(int, java.sql.Date) + */ + protected final void updateDate(int columnIndex, Date x) throws SQLException { + rs.updateDate(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date) + */ + protected final void updateDate(String columnLabel, Date x) throws SQLException { + rs.updateDate(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateDouble(int, double) + */ + protected final void updateDouble(int columnIndex, double x) throws SQLException { + rs.updateDouble(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateDouble(java.lang.String, double) + */ + protected final void updateDouble(String columnLabel, double x) throws SQLException { + rs.updateDouble(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateFloat(int, float) + */ + protected final void updateFloat(int columnIndex, float x) throws SQLException { + rs.updateFloat(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateFloat(java.lang.String, float) + */ + protected final void updateFloat(String columnLabel, float x) throws SQLException { + rs.updateFloat(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateInt(int, int) + */ + protected final void updateInt(int columnIndex, int x) throws SQLException { + rs.updateInt(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateInt(java.lang.String, int) + */ + protected final void updateInt(String columnLabel, int x) throws SQLException { + rs.updateInt(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateLong(int, long) + */ + protected final void updateLong(int columnIndex, long x) throws SQLException { + rs.updateLong(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateLong(java.lang.String, long) + */ + protected final void updateLong(String columnLabel, long x) throws SQLException { + rs.updateLong(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader, long) + */ + protected final void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + rs.updateNCharacterStream(columnIndex, x, length); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader) + */ + protected final void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + rs.updateNCharacterStream(columnIndex, x); + } + + /** + * @param columnLabel + * @param reader + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader, long) + */ + protected final void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + rs.updateNCharacterStream(columnLabel, reader, length); + } + + /** + * @param columnLabel + * @param reader + * @throws SQLException + * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader) + */ + protected final void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + rs.updateNCharacterStream(columnLabel, reader); + } + + /** + * @param columnIndex + * @param nClob + * @throws SQLException + * @see java.sql.ResultSet#updateNClob(int, java.sql.NClob) + */ + protected final void updateNClob(int columnIndex, NClob nClob) throws SQLException { + rs.updateNClob(columnIndex, nClob); + } + + /** + * @param columnIndex + * @param reader + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateNClob(int, java.io.Reader, long) + */ + protected final void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + rs.updateNClob(columnIndex, reader, length); + } + + /** + * @param columnIndex + * @param reader + * @throws SQLException + * @see java.sql.ResultSet#updateNClob(int, java.io.Reader) + */ + protected final void updateNClob(int columnIndex, Reader reader) throws SQLException { + rs.updateNClob(columnIndex, reader); + } + + /** + * @param columnLabel + * @param nClob + * @throws SQLException + * @see java.sql.ResultSet#updateNClob(java.lang.String, java.sql.NClob) + */ + protected final void updateNClob(String columnLabel, NClob nClob) throws SQLException { + rs.updateNClob(columnLabel, nClob); + } + + /** + * @param columnLabel + * @param reader + * @param length + * @throws SQLException + * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader, long) + */ + protected final void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + rs.updateNClob(columnLabel, reader, length); + } + + /** + * @param columnLabel + * @param reader + * @throws SQLException + * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader) + */ + protected final void updateNClob(String columnLabel, Reader reader) throws SQLException { + rs.updateNClob(columnLabel, reader); + } + + /** + * @param columnIndex + * @param nString + * @throws SQLException + * @see java.sql.ResultSet#updateNString(int, java.lang.String) + */ + protected final void updateNString(int columnIndex, String nString) throws SQLException { + rs.updateNString(columnIndex, nString); + } + + /** + * @param columnLabel + * @param nString + * @throws SQLException + * @see java.sql.ResultSet#updateNString(java.lang.String, java.lang.String) + */ + protected final void updateNString(String columnLabel, String nString) throws SQLException { + rs.updateNString(columnLabel, nString); + } + + /** + * @param columnIndex + * @throws SQLException + * @see java.sql.ResultSet#updateNull(int) + */ + protected final void updateNull(int columnIndex) throws SQLException { + rs.updateNull(columnIndex); + } + + /** + * @param columnLabel + * @throws SQLException + * @see java.sql.ResultSet#updateNull(java.lang.String) + */ + protected final void updateNull(String columnLabel) throws SQLException { + rs.updateNull(columnLabel); + } + + /** + * @param columnIndex + * @param x + * @param scaleOrLength + * @throws SQLException + * @see java.sql.ResultSet#updateObject(int, java.lang.Object, int) + */ + protected final void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + rs.updateObject(columnIndex, x, scaleOrLength); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateObject(int, java.lang.Object) + */ + protected final void updateObject(int columnIndex, Object x) throws SQLException { + rs.updateObject(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @param scaleOrLength + * @throws SQLException + * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, int) + */ + protected final void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + rs.updateObject(columnLabel, x, scaleOrLength); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object) + */ + protected final void updateObject(String columnLabel, Object x) throws SQLException { + rs.updateObject(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateRef(int, java.sql.Ref) + */ + protected final void updateRef(int columnIndex, Ref x) throws SQLException { + rs.updateRef(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref) + */ + protected final void updateRef(String columnLabel, Ref x) throws SQLException { + rs.updateRef(columnLabel, x); + } + + /** + * @throws SQLException + * @see java.sql.ResultSet#updateRow() + */ + protected final void updateRow() throws SQLException { + rs.updateRow(); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateRowId(int, java.sql.RowId) + */ + protected final void updateRowId(int columnIndex, RowId x) throws SQLException { + rs.updateRowId(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateRowId(java.lang.String, java.sql.RowId) + */ + protected final void updateRowId(String columnLabel, RowId x) throws SQLException { + rs.updateRowId(columnLabel, x); + } + + /** + * @param columnIndex + * @param xmlObject + * @throws SQLException + * @see java.sql.ResultSet#updateSQLXML(int, java.sql.SQLXML) + */ + protected final void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + rs.updateSQLXML(columnIndex, xmlObject); + } + + /** + * @param columnLabel + * @param xmlObject + * @throws SQLException + * @see java.sql.ResultSet#updateSQLXML(java.lang.String, java.sql.SQLXML) + */ + protected final void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + rs.updateSQLXML(columnLabel, xmlObject); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateShort(int, short) + */ + protected final void updateShort(int columnIndex, short x) throws SQLException { + rs.updateShort(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateShort(java.lang.String, short) + */ + protected final void updateShort(String columnLabel, short x) throws SQLException { + rs.updateShort(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateString(int, java.lang.String) + */ + protected final void updateString(int columnIndex, String x) throws SQLException { + rs.updateString(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String) + */ + protected final void updateString(String columnLabel, String x) throws SQLException { + rs.updateString(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateTime(int, java.sql.Time) + */ + protected final void updateTime(int columnIndex, Time x) throws SQLException { + rs.updateTime(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time) + */ + protected final void updateTime(String columnLabel, Time x) throws SQLException { + rs.updateTime(columnLabel, x); + } + + /** + * @param columnIndex + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp) + */ + protected final void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + rs.updateTimestamp(columnIndex, x); + } + + /** + * @param columnLabel + * @param x + * @throws SQLException + * @see java.sql.ResultSet#updateTimestamp(java.lang.String, java.sql.Timestamp) + */ + protected final void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + rs.updateTimestamp(columnLabel, x); + } + + /** + * @return + * @throws SQLException + * @see java.sql.ResultSet#wasNull() + */ + protected final boolean wasNull() throws SQLException { + return rs.wasNull(); + } + + protected final ResultSet getAdaptedResultSet() { + return rs; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java new file mode 100644 index 0000000..51129f9 --- /dev/null +++ b/src/main/java/org/apache/commons/dbutils2/BasicRowProcessor.java @@ -0,0 +1,239 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.dbutils2; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * Basic implementation of the <code>RowProcessor</code> interface. + * + * <p> + * This class is thread-safe. + * </p> + * + * @see RowProcessor + */ +public class BasicRowProcessor implements RowProcessor { + + /** + * The default BeanProcessor instance to use if not supplied in the + * constructor. + */ + private static final BeanProcessor defaultConvert = new BeanProcessor(); + + /** + * Use this to process beans. + */ + private final BeanProcessor convert; + + /** + * BasicRowProcessor constructor. Bean processing defaults to a + * BeanProcessor instance. + */ + public BasicRowProcessor() { + this(defaultConvert); + } + + /** + * BasicRowProcessor constructor. + * @param convert The BeanProcessor to use when converting columns to + * bean properties. + * @since DbUtils 1.1 + */ + public BasicRowProcessor(BeanProcessor convert) { + super(); + this.convert = convert; + } + + /** + * Convert a <code>ResultSet</code> row into an <code>Object[]</code>. + * This implementation copies column values into the array in the same + * order they're returned from the <code>ResultSet</code>. Array elements + * will be set to <code>null</code> if the column was SQL NULL. + * + * @see org.apache.commons.dbutils2.RowProcessor#toArray(java.sql.ResultSet) + * @param rs ResultSet that supplies the array data + * @throws SQLException if a database access error occurs + * @return the newly created array + */ + @Override + public Object[] toArray(ResultSet rs) throws SQLException { + ResultSetMetaData meta = rs.getMetaData(); + int cols = meta.getColumnCount(); + Object[] result = new Object[cols]; + + for (int i = 0; i < cols; i++) { + result[i] = rs.getObject(i + 1); + } + + return result; + } + + /** + * Convert a <code>ResultSet</code> row into a JavaBean. This + * implementation delegates to a BeanProcessor instance. + * @see org.apache.commons.dbutils2.RowProcessor#toBean(java.sql.ResultSet, java.lang.Class) + * @see org.apache.commons.dbutils2.BeanProcessor#toBean(java.sql.ResultSet, java.lang.Class) + * @param <T> The type of bean to create + * @param rs ResultSet that supplies the bean data + * @param type Class from which to create the bean instance + * @throws SQLException if a database access error occurs + * @return the newly created bean + */ + @Override + public <T> T toBean(ResultSet rs, Class<T> type) throws SQLException { + return this.convert.toBean(rs, type); + } + + /** + * Convert a <code>ResultSet</code> into a <code>List</code> of JavaBeans. + * This implementation delegates to a BeanProcessor instance. + * @see org.apache.commons.dbutils2.RowProcessor#toBeanList(java.sql.ResultSet, java.lang.Class) + * @see org.apache.commons.dbutils2.BeanProcessor#toBeanList(java.sql.ResultSet, java.lang.Class) + * @param <T> The type of bean to create + * @param rs ResultSet that supplies the bean data + * @param type Class from which to create the bean instance + * @throws SQLException if a database access error occurs + * @return A <code>List</code> of beans with the given type in the order + * they were returned by the <code>ResultSet</code>. + */ + @Override + public <T> List<T> toBeanList(ResultSet rs, Class<T> type) throws SQLException { + return this.convert.toBeanList(rs, type); + } + + /** + * Convert a <code>ResultSet</code> row into a <code>Map</code>. This + * implementation returns a <code>Map</code> with case insensitive column + * names as keys. Calls to <code>map.get("COL")</code> and + * <code>map.get("col")</code> return the same value. + * @see org.apache.commons.dbutils2.RowProcessor#toMap(java.sql.ResultSet) + * @param rs ResultSet that supplies the map data + * @throws SQLException if a database access error occurs + * @return the newly created Map + */ + @Override + public Map<String, Object> toMap(ResultSet rs) throws SQLException { + Map<String, Object> result = new CaseInsensitiveHashMap(); + ResultSetMetaData rsmd = rs.getMetaData(); + int cols = rsmd.getColumnCount(); + + for (int i = 1; i <= cols; i++) { + result.put(rsmd.getColumnName(i), rs.getObject(i)); + } + + return result; + } + + /** + * A Map that converts all keys to lowercase Strings for case insensitive + * lookups. This is needed for the toMap() implementation because + * databases don't consistently handle the casing of column names. + * + * <p>The keys are stored as they are given [BUG #DBUTILS-34], so we maintain + * an internal mapping from lowercase keys to the real keys in order to + * achieve the case insensitive lookup. + * + * <p>Note: This implementation does not allow <tt>null</tt> + * for key, whereas {@link HashMap} does, because of the code: + * <pre> + * key.toString().toLowerCase() + * </pre> + */ + private static class CaseInsensitiveHashMap extends HashMap<String, Object> { + /** + * The internal mapping from lowercase keys to the real keys. + * + * <p> + * Any query operation using the key + * ({@link #get(Object)}, {@link #containsKey(Object)}) + * is done in three steps: + * <ul> + * <li>convert the parameter key to lower case</li> + * <li>get the actual key that corresponds to the lower case key</li> + * <li>query the map with the actual key</li> + * </ul> + * </p> + */ + private final Map<String, String> lowerCaseMap = new HashMap<String, String>(); + + /** + * Required for serialization support. + * + * @see java.io.Serializable + */ + private static final long serialVersionUID = -2848100435296897392L; + + /** {@inheritDoc} */ + @Override + public boolean containsKey(Object key) { + Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); + return super.containsKey(realKey); + // Possible optimisation here: + // Since the lowerCaseMap contains a mapping for all the keys, + // we could just do this: + // return lowerCaseMap.containsKey(key.toString().toLowerCase()); + } + + /** {@inheritDoc} */ + @Override + public Object get(Object key) { + Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); + return super.get(realKey); + } + + /** {@inheritDoc} */ + @Override + public Object put(String key, Object value) { + /* + * In order to keep the map and lowerCaseMap synchronized, + * we have to remove the old mapping before putting the + * new one. Indeed, oldKey and key are not necessaliry equals. + * (That's why we call super.remove(oldKey) and not just + * super.put(key, value)) + */ + Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key); + Object oldValue = super.remove(oldKey); + super.put(key, value); + return oldValue; + } + + /** {@inheritDoc} */ + @Override + public void putAll(Map<? extends String, ?> m) { + for (Map.Entry<? extends String, ?> entry : m.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + this.put(key, value); + } + } + + /** {@inheritDoc} */ + @Override + public Object remove(Object key) { + Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH)); + return super.remove(realKey); + } + } + +} http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/41d6d58c/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java new file mode 100644 index 0000000..cb1773e --- /dev/null +++ b/src/main/java/org/apache/commons/dbutils2/BatchExecutor.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.dbutils2; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Types; + +/** + * This class provides the ability to execute a batch of statements. + * + * It is really just a facade to an array of UpdateExecutors. + * + * @author William Speirs <[email protected]> + */ +public class BatchExecutor extends AbstractExecutor<BatchExecutor> { + + private final boolean closeConn; + + public BatchExecutor(final Connection conn, final String sql, final boolean closeConnection) throws SQLException { + super(conn, sql); + this.closeConn = closeConnection; + } + + /** + * Binds a parameter name to a value for a given statement. + * @param statement the statement number to operate on. + * @param name the name of the parameter. + * @param value the value to bind to the parameter. + * @return this object. + * @throws SQLException thrown if the statement number does not exist, or any other SQLException. + * @see org.apache.commons.dbutils.UpdateExecutor.bind(String, Object) + */ + @Override + public BatchExecutor bind(final String name, final Object value) throws SQLException { + return bind(name, value, false); + } + + /** + * Binds null to a parameter. + * Types.VARCHAR is used as the type's parameter. + * This usually works, but fails with some Oracle and MS SQL drivers. + * @param name the name of the parameter. + * @return this execution object to provide the fluent style. + * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null. + */ + @Override + public BatchExecutor bindNull(final String name) throws SQLException { + return bindNull(name, Types.VARCHAR, false); + } + + /** + * Binds null to a parameter, specifying the parameter's type. + * @param name the name of the parameter. + * @param sqlType the type of the parameter. + * @return this execution object to provide the fluent style. + * @throws SQLException throw if the parameter is not found, already bound, or there is an issue binding null. + */ + @Override + public BatchExecutor bindNull(final String name, final int sqlType) throws SQLException { + return bindNull(name, sqlType, false); + } + + /** + * Adds the statement to the batch after binding all of the parameters. + * @return this object. + * @throws SQLException if a SQLException is thrown during the addBatch() call. + * @see java.sql.PreparedStatement.addBatch() + */ + public BatchExecutor addBatch() throws SQLException { + try { + getStatement().addBatch(); + clearValueMap(); + } catch(SQLException e) { + rethrow(e); + } + + return this; + } + + /** + * Calls batch after checking the parameters to ensure nothing is null. + * @return an array containing the number of rows updated for each statement. + * @throws SQLException If there are database or parameter errors. + * @see org.apache.commons.dbutils.UpdateExecutor.update() + */ + public int[] execute() throws SQLException { + try { + return getStatement().executeBatch(); + } catch (SQLException e) { + rethrow(e); + } finally { + close(getStatement()); + if (closeConn) { + close(getConnection()); + } + } + + // we get here only if something is thrown + return null; + } + +}
