View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.database.util;
17  
18  import java.sql.Connection;
19  import java.sql.PreparedStatement;
20  
21  import org.seasar.extension.jdbc.impl.BasicBatchHandler;
22  import org.seasar.extension.jdbc.util.ConnectionUtil;
23  import org.seasar.framework.exception.SQLRuntimeException;
24  import org.seasar.framework.util.PreparedStatementUtil;
25  import org.seasar.framework.util.StatementUtil;
26  
27  /***
28   * @author someda
29   */
30  public class BasicDynaBatchHandler extends BasicBatchHandler implements
31  		DynaBatchHandler {
32  
33  	// for delete sql 
34  	public int execute() throws SQLRuntimeException {		
35  		Connection connection = getConnection();
36  		try {
37  			return execute(connection);
38  		} finally {
39  			ConnectionUtil.close(connection);
40  		}		
41  	}
42  	
43  	protected int execute(Connection connection){
44  		PreparedStatement ps = prepareStatement(connection);
45  		try {
46  			return PreparedStatementUtil.executeUpdate(ps);
47  		} finally {
48  			StatementUtil.close(ps);
49  		}
50  	}
51  	
52  }