KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > ant > StopHsqldbTask


1 package org.roller.ant;
2
3 import java.sql.Connection JavaDoc;
4 import java.sql.DriverManager JavaDoc;
5 import java.sql.SQLException JavaDoc;
6
7 import org.apache.tools.ant.BuildException;
8 import org.apache.tools.ant.Task;
9
10 /**
11  * Ant Task to stop HSQLDB
12  * @author Dave Johnson
13  */

14 public class StopHsqldbTask extends Task
15 {
16     private String JavaDoc port = null;
17     public void execute() throws BuildException
18     {
19         try
20         {
21             if (port==null)
22             {
23                 throw new BuildException("missing port attribute");
24             }
25             System.out.println("Stopping HSQLDB at port " + port);
26             final Connection JavaDoc con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost:"+port);
27             con.createStatement().execute("SHUTDOWN");
28         }
29         catch (SQLException JavaDoc e)
30         {
31             throw new BuildException(e.getMessage());
32         }
33     }
34     /**
35      * @return Returns the port.
36      */

37     public String JavaDoc getPort()
38     {
39         return port;
40     }
41     /**
42      * @param port The port to set.
43      */

44     public void setPort(String JavaDoc port)
45     {
46         this.port = port;
47     }
48 }
49
Popular Tags