1 package org.roller.ant; 2 3 import java.sql.Connection ; 4 import java.sql.DriverManager ; 5 import java.sql.SQLException ; 6 7 import org.apache.tools.ant.BuildException; 8 import org.apache.tools.ant.Task; 9 10 14 public class StopHsqldbTask extends Task 15 { 16 private String 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 con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost:"+port); 27 con.createStatement().execute("SHUTDOWN"); 28 } 29 catch (SQLException e) 30 { 31 throw new BuildException(e.getMessage()); 32 } 33 } 34 37 public String getPort() 38 { 39 return port; 40 } 41 44 public void setPort(String port) 45 { 46 this.port = port; 47 } 48 } 49 | Popular Tags |