01: /*
02: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: * [See end of file]
04: */
05:
06: package jena;
07:
08: import jena.util.DBcmd;
09:
10: import com.hp.hpl.jena.util.FileUtils;
11:
12: /** Load data files into a Jena model in a database.
13: *
14: * <p>
15: * Usage:<pre>
16: * jena.dbload [db spec] file [file ...]
17: * where [db spec] is:
18: * --spec file Contains an RDF description of the model
19: * --db JDBC_url --dbUser userId --dbPassword password --dbType [--model modelName]
20: * </pre>
21: * The syntax of a file is determimed by its extension (.n3, .nt) and defaults to RDF/XML.
22: * </p>
23: *
24: * @author Andy Seaborne
25: * @version $Id: dbload.java,v 1.12 2008/01/02 12:08:16 andy_seaborne Exp $
26: */
27:
28: public class dbload extends DBcmd {
29: public static final String[] usage = new String[] {
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: public static void main(String[] args) {
36: dbload db = new dbload();
37: db.setUsage(usage);
38:
39: // add any new args
40: db.init(args);
41: // do any additional test here
42:
43: // Action!
44: db.exec();
45: }
46:
47: String filename = null;
48:
49: public dbload() {
50: super ("dbload", true);
51: }
52:
53: protected void exec0() {
54: return;
55: }
56:
57: protected boolean exec1(String arg) {
58: if (verbose)
59: System.out.println("Start load: " + arg);
60: // Crude but convenient
61: if (arg.indexOf(':') == -1)
62: arg = "file:" + arg;
63:
64: String lang = FileUtils.guessLang(arg);
65: getRDBModel().read(arg, lang);
66: return true;
67: }
68: }
69:
70: /*
71: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
72: * All rights reserved.
73: *
74: * Redistribution and use in source and binary forms, with or without
75: * modification, are permitted provided that the following conditions
76: * are met:
77: * 1. Redistributions of source code must retain the above copyright
78: * notice, this list of conditions and the following disclaimer.
79: * 2. Redistributions in binary form must reproduce the above copyright
80: * notice, this list of conditions and the following disclaimer in the
81: * documentation and/or other materials provided with the distribution.
82: * 3. The name of the author may not be used to endorse or promote products
83: * derived from this software without specific prior written permission.
84: *
85: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
86: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
87: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
88: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
89: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
90: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
91: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
92: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
93: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
94: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95: */
|