source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/usersDB2txt.java

Last change on this file was 38769, checked in by anupama, 2 months ago

Following Dr Bainbridge's task description and with his fixes: changes to get the Networked Derby Driver that we now use to use the shorter URL to the usersDB of the form jdbc:derby://derbyserver:derbyport/usersDB, instead of the full path to usersDB after the protocol. It needed setting derby.system.home JAVA_OPT when starting up the derby server in build.xml, then the tomcat greenstone3.xml file needed to refer to the shorter URL. Then classes that used to pass the full path need to pass the shorter form. And those classes called from the comandline with full usersDB path, like ModifyUsersDB, needed to now pass the shorter path. So build.xml needed further updating when calling ModifyUsersDB. The full path still works (for example, you can connect to both the original jdbc:derby URL and the shorter URL now from Squirrel SQL Client now), but the code now uses the shorter path.

File size: 2.5 KB
Line 
1/*
2 * usersDB2txt.java
3 * Copyright (C) 2008 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19package org.greenstone.gsdl3.util;
20
21import javax.swing.*;
22import java.io.File;
23import java.sql.Connection;
24import java.sql.DriverManager;
25import java.sql.ResultSet;
26import java.sql.SQLException;
27import java.sql.SQLWarning;
28import java.sql.Statement;
29import java.util.Properties;
30
31/**
32 To run this from the command-line, first make sure that the networked derby server is running (ant start-derby)
33 then run:
34
35 java -Dgsdl3.writablehome=/full/path/to/GS3/web -cp ./web/WEB-INF/lib/gsdl3.jar:./web/WEB-INF/lib/gutil.jar:./web/WEB-INF/lib/derby.jar:./web/WEB-INF/lib/derbyclient.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.gsdl3.util.usersDB2txt usersDB
36
37 Now just pass in "usersDB" for networked derby server, previously web/etc/usersDB/ was needed.
38
39 if redirecting to a file append ">& filename.txt" to the above command
40 since the usersDB2txt program output goes to System.err and needs to be redirected to the file too
41
42 Don't forget to stop the networked derby server again at the end, if you had started it: ant stop-derby
43
44 Or if using embedded derby, ensure that tomcat is stopped, then run:
45 java -cp /full/path/to/GS3/web/WEB-INF/lib/gsdl3.jar:/full/path/to/GS3/web/WEB-INF/lib/derby.jar org.greenstone.gsdl3.util.usersDB2txt web/etc/usersDB/ [>& <output file>]
46*/
47public class usersDB2txt
48{
49 public static void main(String[] args) throws SQLException{
50 if (args.length!=1){
51 System.out.println("Set parameter to \"usersDB\" for a derby networked server or usersDB path if using an embedded derby server");
52 System.exit(0);
53 }
54 DerbyWrapper derbyWrapper=new DerbyWrapper(args[0]);
55 derbyWrapper.db2txt();
56 }
57}
Note: See TracBrowser for help on using the repository browser.