1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
25 public class StopDerby
26 extends Task {
27
28
29 public void execute()
30 throws BuildException
31 {
32 if (StartDerby.getDriver(getProject()) == null)
33 {
34 System.out.println("Derby Driver has NOT BEEN ESTABLISHED!");
35 return ;
36 }
37 if (StartDerby.getConnection(getProject()) != null)
38 {
39 try
40 {
41 StartDerby.getConnection(getProject()).close();
42 System.out.println("Derby Connection successfully closed!");
43 }
44 catch (SQLException e)
45 {
46 throw new BuildException(e, getLocation());
47 }
48 StartDerby.setConnection(getProject(),null);
49
50 }
51 else
52 System.out.println("Derby Connection has already been closed!");
53
54
55 Properties info = new Properties();
56 info.put("shutdown",Boolean.TRUE);
57 System.out.println("Derby Driver sutting down!");
58 try
59 {
60 StartDerby.getDriver(getProject()).connect("jdbc:derby:",info);
61 } catch (Exception e)
62 {
63 System.out.println("Derby has been shutdown!");
64 }
65
66 StartDerby.setDriver(getProject(),null);
67 System.out.println("Derby Driver has been shutdown!");
68 }
69
70 }