01: /*
02:
03: Loader - tool for transfering data from one JDBC source to another and
04: doing transformations during copy.
05:
06: Copyright (C) 2002 Together
07:
08: This library is free software; you can redistribute it and/or
09: modify it under the terms of the GNU Lesser General Public
10: License as published by the Free Software Foundation; either
11: version 2.1 of the License, or (at your option) any later version.
12:
13: This library is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: Lesser General Public License for more details.
17:
18: You should have received a copy of the GNU Lesser General Public
19: License along with this library; if not, write to the Free Software
20: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21:
22: /*
23: * DropDatabaseOperation.java Aug 30, 2002
24: * Sinisa Milosevic sinisami@eunet.yu
25: *
26: */
27:
28: package org.webdocwf.util.loader.test;
29:
30: import java.sql.Connection;
31: import java.sql.Statement;
32: import org.webdocwf.util.loader.test.DatabaseOperation;
33: import org.webdocwf.util.loader.Loader;
34: import org.webdocwf.util.loader.LoaderException;
35:
36: import java.sql.SQLException;
37:
38: /**
39: * Deletes entire database using sql command (DROP DATABASE) or specified loader job.
40: *
41: * @author Sinisa Milosevic
42: * @version $Revision: 1.1 $
43: */
44: public class DropDatabaseOperation extends DatabaseOperation {
45:
46: private String databaseName = null;
47:
48: DropDatabaseOperation() {
49: }
50:
51: public DropDatabaseOperation(String name) {
52: databaseName = name;
53: }
54:
55: ////////////////////////////////////////////////////////////////////////////
56: // DatabaseOperation class
57:
58: /**
59: * Executes this operation on the specified database using the specified
60: * connection to the database.
61: *
62: * @param conn the database connection.
63: */
64:
65: public void execute(Connection conn) throws SQLException {
66: Statement stmt = conn.createStatement();
67:
68: if (databaseName != null) {
69: try {
70: stmt.execute("DROP DATABASE " + databaseName);
71: } finally {
72: stmt.close();
73: }
74: }
75:
76: }
77:
78: /**
79: * Returns type of database operation
80: *
81: */
82: public String getDatabaseOperationType() {
83: return DatabaseOperation.DROP;
84: }
85:
86: }
|