KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > procedure > SystemBackup


1 /**
2  * com.mckoi.database.procedure.SystemBackup 27 Feb 2003
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database.procedure;
26
27 import com.mckoi.database.ProcedureConnection;
28 import com.mckoi.database.ProcedureException;
29 import java.io.File JavaDoc;
30 import java.io.IOException JavaDoc;
31
32 /**
33  * A stored procedure that backs up the entire database to the given directory
34  * in the file system. Requires one parameter, the locate to back up the
35  * database to.
36  *
37  * @author Tobias Downer
38  */

39
40 public class SystemBackup {
41
42   /**
43    * The stored procedure invokation method.
44    */

45   public static String JavaDoc invoke(ProcedureConnection db_connection,
46                               String JavaDoc path) {
47
48     File JavaDoc f = new File JavaDoc(path);
49     if (!f.exists() || !f.isDirectory()) {
50       throw new ProcedureException("Path '" + path +
51                                    "' doesn't exist or is not a directory.");
52     }
53
54     try {
55       db_connection.getDatabase().liveCopyTo(f);
56       return path;
57     }
58     catch (IOException JavaDoc e) {
59       e.printStackTrace();
60       throw new ProcedureException("IO Error: " + e.getMessage());
61     }
62
63   }
64
65 }
66
67
Popular Tags