BatchPreparedStatementSetter.java
Upload User: jiancairen
Upload Date: 2007-08-27
Package Size: 26458k
Code Size: 2k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright 2002-2004 the original author or authors.
  3.  * 
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  * 
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  * 
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */ 
  16. package org.springframework.jdbc.core;
  17. import java.sql.PreparedStatement;
  18. import java.sql.SQLException;
  19. /**
  20.  * Callback interface used by the JdbcTemplate class.
  21.  *
  22.  * <p>This interface sets values on a PreparedStatement provided by the
  23.  * JdbcTemplate class for each of a number of updates in a batch using the
  24.  * same SQL. Implementations are responsible for setting any necessary
  25.  * parameters. SQL with placeholders will already have been supplied.
  26.  *
  27.  * <p>Implementations <i>do not</i> need to concern themselves with
  28.  * SQLExceptions that may be thrown from operations they attempt.
  29.  * The JdbcTemplate class will catch and handle SQLExceptions appropriately.
  30.  *
  31.  * @author Rod Johnson
  32.  * @since March 2, 2003
  33.  * @see JdbcTemplate#batchUpdate(String, BatchPreparedStatementSetter)
  34.  */
  35. public interface BatchPreparedStatementSetter {
  36. /** 
  37. * Set values on the given PreparedStatement.
  38. * @param ps PreparedStatement we'll invoke setter methods on
  39. * @param i index of the statement we're issuing in the batch, starting from 0
  40. * @throws SQLException there is no need to catch SQLExceptions
  41. * that may be thrown in the implementation of this method.
  42. * The JdbcTemplate class will handle them.
  43. */
  44. void setValues(PreparedStatement ps, int i) throws SQLException;
  45. /** 
  46.  * Return the size of the batch.
  47.  */ 
  48. int getBatchSize();
  49. }