1 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 { 31 public static void main(String [] args) 32 throws Exception 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 oldV = args[0]; 50 String newV = args[1]; 51 52 DatabaseAbstractionLayer dbLayer = DatabaseAbstractionLayer.createLayer(config); 53 Connection c = dbLayer.getConnection(); 54 PreparedStatement 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 |