KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jena > dbload


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

5
6 package jena;
7
8 import com.hp.hpl.jena.util.FileUtils;
9  
10  /** Load data files into a Jena model in a database.
11   *
12   * <p>
13   * Usage:<pre>
14   * jena.dbload [db spec] file [file ...]
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   * The syntax of a file is determimed by its extension (.n3, .nt) and defaults to RDF/XML.
20   * </p>
21   *
22   * @author Andy Seaborne
23   * @version $Id: dbload.java,v 1.6 2005/02/21 11:49:12 andy_seaborne Exp $
24   */

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

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

100
Popular Tags