01: /*
02: * Lucane - a collaborative platform
03: * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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;
22: import java.sql.PreparedStatement;
23: import java.util.logging.Level;
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: public static void main(String[] args) throws Exception {
31: Logging.getLogger().setLevel(Level.OFF);
32:
33: ServerConfig config = new ServerConfig("etc/server-config.xml");
34: if (!config.getStoreBackend().equals("database")) {
35: System.err.println("not using database backend, sorry.");
36: System.exit(1);
37: }
38:
39: if (args.length != 2) {
40: System.out
41: .println("usage: UpdatePlugins <old-version> <new-version>");
42: System.exit(1);
43: }
44:
45: String oldV = args[0];
46: String newV = args[1];
47:
48: DatabaseAbstractionLayer dbLayer = DatabaseAbstractionLayer
49: .createLayer(config);
50: Connection c = dbLayer.getConnection();
51: PreparedStatement update = c
52: .prepareStatement("UPDATE plugins SET version=? WHERE version=?");
53: update.setString(1, newV);
54: update.setString(2, oldV);
55: int number = update.executeUpdate();
56: update.close();
57: c.close();
58:
59: System.out.println("updated " + number + " plugins from "
60: + oldV + " to " + newV + " !");
61: }
62: }
|