1 //
2 // Copyright (c) 2004, International Decision Systems
3 // all rights reserved
4 /*
5 * Copyright (c) 2004 International Decision Systems, Inc. All Rights Reserved.
6 *
7 * By using this Software, You acknowledge that the Software is a valuable asset
8 * and trade secret of either International Decision Systems, Inc. ("IDSI") or a
9 * third party supplier of IDSI and constitutes confidential and proprietary
10 * information.
11 *
12 * NEITHER IDSI NOR ANY AGENT OR PERSON ACTING FOR OR WITH IDSI HAS MADE OR DOES
13 * MAKE ANY STATEMENTS, AFFIRMATIONS, REPRESENTATIONS OR WARRANTIES WHATSOEVER
14 * TO YOU, WHETHER EXPRESS OR IMPLIED, AS TO THE SOFTWARE, THE QUALITY OR
15 * CONDITION OF THE SOFTWARE, OR THE OPERATING CHARACTERISTICS OR RELIABILITY OF
16 * THE SOFTWARE, OR ITS SUITABILITY FOR ANY GENERAL OR PARTICULAR PURPOSE, OR AS
17 * TO ANY OTHER MATTER WHATSOEVER; ANY AND ALL OTHER WARRANTIES INCLUDING
18 * WITHOUT LIMITATION ANY WARRANTIES IMPLIED BY LAW, SUCH AS THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND TITLE,
20 * USE AND NON-INFRINGEMENT; ARE HEREBY EXPRESSLY DISCLAIMED AND EXCLUDED.
21 */
22 package net.sourceforge.addam.ddlrun.runners;
23
24 import java.sql.Connection;
25 import java.sql.SQLException;
26 import java.sql.Statement;
27 import java.util.regex.Pattern;
28 import java.util.regex.Matcher;
29 import java.util.ArrayList;
30 import java.util.Date;
31 import java.text.MessageFormat;
32
33 /**
34 * Executes a single SQL statement; this is separated out in order to simplify testing for JDBCScriptRunner
35 * and also to allow simplified external wiring of the connection object
36 *
37 * @author TIM3
38 * @since Mar 6, 2005
39 */
40 public class JDBCStatementRunner implements Runner {
41
42 public JDBCStatementRunner(Connection connection) {
43 this.connection = connection;
44 }
45
46 // in this case, the resource is a SQL statement
47 public void run(String resource) throws SQLException {
48 Statement statement = null;
49 try {
50 statement = connection.createStatement();
51 statement.execute(resource);
52 } finally {
53 statement.close();
54 }
55
56 }
57
58 private final Connection connection;
59 }