KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jena > dbdump


1 /*
2  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6 package jena;
7 import jena.cmdline.* ;
8
9  /** Write out the data from a database.
10   * Currently broken <code>:-(</code>
11   *
12   * <p>
13   * Usage:<pre>
14   * jena.dbdump [db spec]
15   * where [db spec] is:
16   * --spec file Contains an RDF description of the model
17   * --db JDBC_url --dbUser userId --dbPassword password --dbType [--model modelName]
18   * </pre>
19   * </p>
20
21   *
22   * @author Andy Seaborne
23   * @version $Id: dbdump.java,v 1.5 2005/02/21 11:49:11 andy_seaborne Exp $
24   */

25  
26 public class dbdump extends DBcmd
27 {
28     public static final String JavaDoc[] usage = new String JavaDoc[]
29     {
30         "dbdump [--spec spec] | [db_description] [--model name] [--format syntax]" ,
31         " where db_description is" ,
32         " --db JDBC URL --dbType type" ,
33         " --dbUser user --dbPassword password"
34      } ;
35
36     static ArgDecl argDeclFormat = new ArgDecl(true, "format","fmt") ;
37
38     public static void main(String JavaDoc[] args)
39     {
40         dbdump db = new dbdump();
41         db.setUsage(usage) ;
42         db.cmdLine.add(argDeclFormat) ;
43         
44         // add any new args
45
db.init(args);
46         // do any additional test here
47

48         // Action!
49
db.exec();
50     }
51     
52     String JavaDoc filename = null ;
53
54     public dbdump()
55     {
56         super("dbdump", false);
57     }
58
59     void exec0()
60     {
61         // This is a streaming syntax.
62
String JavaDoc syntax = "N-TRIPLES" ;
63         if ( cmdLine.contains(argDeclFormat) )
64             syntax = cmdLine.getArg(argDeclFormat).getValue() ;
65         if ( debug )
66             System.out.println("Debug: syntax is "+syntax) ;
67         
68         try {
69             getRDBModel().write(System.out, syntax) ;
70         } catch (Exception JavaDoc ex)
71         {
72             System.err.println("Exception: "+ex+" :: "+ex.getMessage()) ;
73             ex.printStackTrace(System.out) ;
74         }
75         
76     }
77
78     boolean exec1(String JavaDoc arg) { return false ; }
79 }
80  
81
82
83 /*
84  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
85  * All rights reserved.
86  *
87  * Redistribution and use in source and binary forms, with or without
88  * modification, are permitted provided that the following conditions
89  * are met:
90  * 1. Redistributions of source code must retain the above copyright
91  * notice, this list of conditions and the following disclaimer.
92  * 2. Redistributions in binary form must reproduce the above copyright
93  * notice, this list of conditions and the following disclaimer in the
94  * documentation and/or other materials provided with the distribution.
95  * 3. The name of the author may not be used to endorse or promote products
96  * derived from this software without specific prior written permission.
97  *
98  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
99  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
100  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
101  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
102  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
103  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
104  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
105  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
106  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
107  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108  */

109
Popular Tags