01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18: package org.apache.roller.ant;
19:
20: import java.sql.Connection;
21: import java.sql.DriverManager;
22: import java.sql.SQLException;
23:
24: import org.apache.tools.ant.BuildException;
25: import org.apache.tools.ant.Task;
26:
27: /**
28: * Ant Task to stop HSQLDB
29: * @author Dave Johnson
30: */
31: public class StopHsqldbTask extends Task {
32: private String port = null;
33:
34: public void execute() throws BuildException {
35: try {
36: if (port == null) {
37: throw new BuildException("missing port attribute");
38: }
39: System.out.println("Stopping HSQLDB at port " + port);
40: final Connection con = DriverManager
41: .getConnection("jdbc:hsqldb:hsql://localhost:"
42: + port);
43: con.createStatement().execute("SHUTDOWN");
44: } catch (SQLException e) {
45: throw new BuildException(e.getMessage());
46: }
47: }
48:
49: /**
50: * @return Returns the port.
51: */
52: public String getPort() {
53: return port;
54: }
55:
56: /**
57: * @param port The port to set.
58: */
59: public void setPort(String port) {
60: this.port = port;
61: }
62: }
|