KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > server > tools > UpdatePlugins


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package org.lucane.server.tools;
20
21 import java.sql.Connection JavaDoc;
22 import java.sql.PreparedStatement JavaDoc;
23 import java.util.logging.Level JavaDoc;
24
25 import org.lucane.common.Logging;
26 import org.lucane.server.ServerConfig;
27 import org.lucane.server.database.DatabaseAbstractionLayer;
28
29 public class UpdatePlugins
30 {
31     public static void main(String JavaDoc [] args)
32     throws Exception JavaDoc
33     {
34         Logging.getLogger().setLevel(Level.OFF);
35
36         ServerConfig config = new ServerConfig("etc/server-config.xml");
37         if(!config.getStoreBackend().equals("database"))
38         {
39             System.err.println("not using database backend, sorry.");
40             System.exit(1);
41         }
42         
43         if(args.length != 2)
44         {
45             System.out.println("usage: UpdatePlugins <old-version> <new-version>");
46             System.exit(1);
47         }
48         
49         String JavaDoc oldV = args[0];
50         String JavaDoc newV = args[1];
51
52         DatabaseAbstractionLayer dbLayer = DatabaseAbstractionLayer.createLayer(config);
53         Connection JavaDoc c = dbLayer.getConnection();
54         PreparedStatement JavaDoc update = c.prepareStatement(
55                 "UPDATE plugins SET version=? WHERE version=?");
56         update.setString(1, newV);
57         update.setString(2, oldV);
58         int number = update.executeUpdate();
59         update.close();
60         c.close();
61         
62         System.out.println("updated " + number + " plugins from " + oldV + " to " + newV + " !");
63     }
64 }
Popular Tags