01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.anttasks;
18:
19: import org.apache.tools.ant.BuildException;
20: import org.apache.tools.ant.Task;
21: import java.sql.SQLException;
22: import java.util.Properties;
23:
24: public class StopDerby extends Task {
25:
26: public void execute() throws BuildException {
27: if (StartDerby.getDriver(getProject()) == null) {
28: System.out
29: .println("Derby Driver has NOT BEEN ESTABLISHED!");
30: return; // already closed;
31: }
32: if (StartDerby.getConnection(getProject()) != null) {
33: try {
34: StartDerby.getConnection(getProject()).close();
35: System.out
36: .println("Derby Connection successfully closed!");
37: } catch (SQLException e) {
38: throw new BuildException(e, getLocation());
39: }
40: StartDerby.setConnection(getProject(), null);
41:
42: } else
43: System.out
44: .println("Derby Connection has already been closed!");
45:
46: // getConnection("jdbc:derby:;shutdown=true");
47: Properties info = new Properties();
48: info.put("shutdown", Boolean.TRUE);
49: System.out.println("Derby Driver sutting down!");
50: try {
51: StartDerby.getDriver(getProject()).connect("jdbc:derby:",
52: info);
53: } catch (Exception e) {
54: System.out.println("Derby has been shutdown!");
55: }
56:
57: StartDerby.setDriver(getProject(), null);
58: System.out.println("Derby Driver has been shutdown!");
59: }
60:
61: }
|