001: /*
002: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * [See end of file]
004: */
005:
006: package jena;
007:
008: import jena.cmdline.*;
009: import jena.util.DBcmd;
010:
011: /** Write out the data from a database.
012: * Currently broken <code>:-(</code>
013: *
014: * <p>
015: * Usage:<pre>
016: * jena.dbdump [db spec]
017: * where [db spec] is:
018: * --spec file Contains an RDF description of the model
019: * --db JDBC_url --dbUser userId --dbPassword password --dbType [--model modelName]
020: * </pre>
021: * </p>
022:
023: *
024: * @author Andy Seaborne
025: * @version $Id: dbdump.java,v 1.11 2008/01/02 12:08:16 andy_seaborne Exp $
026: */
027:
028: public class dbdump extends DBcmd {
029: public static final String[] usage = new String[] {
030: "dbdump [--spec spec] | [db_description] [--model name] [--format syntax]",
031: " where db_description is",
032: " --db JDBC URL --dbType type",
033: " --dbUser user --dbPassword password" };
034:
035: static ArgDecl argDeclFormat = new ArgDecl(true, "format", "fmt");
036:
037: public static void main(String[] args) {
038: dbdump db = new dbdump();
039: db.setUsage(usage);
040: db.getCommandLine().add(argDeclFormat);
041:
042: // add any new args
043: db.init(args);
044: // do any additional test here
045:
046: // Action!
047: db.exec();
048: }
049:
050: String filename = null;
051:
052: public dbdump() {
053: super ("dbdump", false);
054: }
055:
056: protected void exec0() {
057: // This is a streaming syntax.
058: String syntax = "N-TRIPLES";
059: if (getCommandLine().contains(argDeclFormat))
060: syntax = getCommandLine().getArg(argDeclFormat).getValue();
061: if (debug)
062: System.out.println("Debug: syntax is " + syntax);
063:
064: try {
065: getRDBModel().write(System.out, syntax);
066: } catch (Exception ex) {
067: System.err.println("Exception: " + ex + " :: "
068: + ex.getMessage());
069: ex.printStackTrace(System.out);
070: }
071:
072: }
073:
074: protected boolean exec1(String arg) {
075: return false;
076: }
077: }
078:
079: /*
080: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
081: * All rights reserved.
082: *
083: * Redistribution and use in source and binary forms, with or without
084: * modification, are permitted provided that the following conditions
085: * are met:
086: * 1. Redistributions of source code must retain the above copyright
087: * notice, this list of conditions and the following disclaimer.
088: * 2. Redistributions in binary form must reproduce the above copyright
089: * notice, this list of conditions and the following disclaimer in the
090: * documentation and/or other materials provided with the distribution.
091: * 3. The name of the author may not be used to endorse or promote products
092: * derived from this software without specific prior written permission.
093: *
094: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
095: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
096: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
097: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
098: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
099: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
100: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
101: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
102: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
103: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104: */
|