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: * CreateDatabaseOperation.java Aug 30, 2002
24: * Author: 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: * Creates new database using sql command (CREATE DATABASE) or specified loader job.
40: *
41: * @author Sinisa Milosevic
42: * @version $Revision: 1.1 $
43: */
44: public class CreateDatabaseOperation extends DatabaseOperation {
45:
46: private String databaseName = null;
47:
48: CreateDatabaseOperation() {
49: }
50:
51: public CreateDatabaseOperation(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: if (databaseName != null) {
68: try {
69: stmt.execute("CREATE DATABASE " + databaseName);
70: } finally {
71: stmt.close();
72: }
73: }
74: }
75:
76: /**
77: * Returns type of database operation
78: *
79: */
80: public String getDatabaseOperationType() {
81: return DatabaseOperation.CREATE;
82: }
83:
84: }
|