KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > db > IDBConnection


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

5
6 package com.hp.hpl.jena.db;
7
8 import java.sql.*;
9
10 import com.hp.hpl.jena.db.impl.*;
11 import com.hp.hpl.jena.rdf.model.Model;
12 import com.hp.hpl.jena.util.iterator.ExtendedIterator;
13
14 /**
15 * Encapsulate the specification of a jdbc connection, mostly used to
16 * simplify the calling pattern for ModelRDB factory methods.
17 *
18 * @author csayers (based on earlier code by der)
19 * @version $Revision: 1.5 $ on $Date: 2005/02/21 12:02:39 $
20 */

21
22 public interface IDBConnection {
23
24     /**
25      * Return the jdbc connection or null if we no longer have access to a connection.
26      */

27     public Connection getConnection() throws SQLException;
28
29     /**
30      * Close the jdbc connection
31      */

32     public void close() throws SQLException;
33
34     /**
35      * Clear all RDF information from the database.
36      *
37      * This wipes all the information stored by Jena from the database.
38      * Obviously should be used with care.
39      */

40     public void cleanDB() throws SQLException;
41
42     /**
43      * Return true if the database seems to be formated for RDF storage.
44      * This is <em>not</em> an integrity check this is simply a flag
45      * recording that a base level table exists.
46      * Any access errors are treated as the database not being formated.
47      */

48     public boolean isFormatOK() throws RDFRDBException;
49
50     /**
51      * Sets database-specific properties.
52      *
53      * <p>
54      * These properties may only be set before the first Model has been
55      * stored in the database. After that point, the database structure
56      * is frozen.</p>
57      *
58      * <p>
59      * Use these properties to optionally customize the database - this
60      * won't change the results you see when using the graph interface,
61      * but it may alter the speed with which you get them or the space
62      * required by the database.</p>
63      *
64      * <p>
65      * The properties must form a complete and consistent set.
66      * The easist way to get a complete and consistent set is to call
67      * getDatabaseProperties, modify the returned model, and then use
68      * that as an argument in the call to setDatabaseProperties.</p>
69      *
70      * <p>
71      * Note that some implementations may choose to delay actually peforming
72      * the formatting operation until at least one Graph is constructed in
73      * the database. Consequently, a successful return from this call
74      * does not necessarily guarantee that the database properties
75      * were set correctly.</p>
76      *
77      * @param propertyModel is a Model describing the database parameters
78      * @since Jena 2.0
79      *
80      */

81     public void setDatabaseProperties(Model propertyModel) throws RDFRDBException;
82     
83     /**
84      * Returns a Jena Model containing database properties.
85      * <p>
86      * These describe the optimization/layout for the database.</p>
87      *
88      * <p>
89      * If the database has not been formatted, then a default
90      * set of properties is returned. Otherwise the actual properties
91      * are returned.</p>
92      *
93      * <p>
94      * The returned Model is a copy, modifying it will have no
95      * effect on the database. (Use setDatabaseProperties to
96      * make changes).</p>
97      *
98      * @since Jena 2.0
99      */

100     public Model getDatabaseProperties() throws RDFRDBException;
101     
102     /** Set the database type manually.
103      * <p>
104      * This is not for public use (it is preferable to
105      * specify it in the constructor) - included here to handle
106      * older code, which didn't use the new constructor.</p>
107      *
108      * @since Jena 2.0
109      */

110
111     public void setDatabaseType( String JavaDoc databaseType );
112     
113     /**
114      * Retrieve a default set of model customization properties.
115      *
116      * The returned default set of properties is suitable for use in a call to
117      * ModelRDB.create(..., modelProperties);
118      *
119      * @return Model containing default properties
120      */

121     
122     public Model getDefaultModelProperties() throws RDFRDBException;
123
124     /** Get the database type.
125      * @return String database type, or null if unset
126      *
127      * @since Jena 2.0
128      */

129     public String JavaDoc getDatabaseType();
130     
131     /*
132      * Returns a property value for the database at the end of the
133      * connection. This is used to retrieve appropriate formating and
134      * driver information from a standard RDF_LAYOUT_INFO table.
135      * For a database that has not been formatted all calls will
136      * return null.
137      * Any access errors are treated as the database not being formated.
138      * Throws an exception if the database is not even openable.
139      *
140      * This is no longer supported in Jena2 - use the property model instead.
141      * (The database implementation in Jena 2 is quite different and there
142      * are no analogous properties for most of the Jena 1 properties.)
143      */

144     //public String getProperty(String propname) throws SQLException;
145

146     /*
147      * Returns a set of property values for the database at the end of the
148      * connection. This is used to retrieve appropriate formating and
149      * driver information from a standard RDF_LAYOUT_INFO table.
150      * For a database that has not been formatted all calls will
151      * return null.
152      * Any access errors are treated as the database not being formated.
153      *
154      * This is no longer supported in Jena2 - use the property model instead.
155      * (The database implementation in Jena 2 is quite different and there
156      * are no analogous properties for most of the Jena 1 properties.)
157      */

158     //public Properties getProperties() throws SQLException;
159

160     /*
161      * Add a new property value to both RDF_LAYOUT_INFO table.
162      *
163      * This is no longer supported in Jena2 - use the property model instead.
164      * (The database implementation in Jena 2 is quite different and there
165      * are no analogous properties for most of the Jena 1 properties.)
166      */

167     //public void addProperty(String propname, String value) throws SQLException;
168

169     /** Retrieve a list of all models in the database
170      *
171      * @return Iterator over String names for graphs.
172      * @throws RDFDBException
173      * @since Jena 2.0
174      */

175     public ExtendedIterator getAllModelNames() throws RDFRDBException;
176
177     /**
178      * Test if a given model is contained in the database.
179      *
180      * @param name the name of a model which may be in the database
181      * @return Boolean true if the model is contained in the database
182      * @throws RDFDBException
183      * @since Jena 2.0
184      */

185      public boolean containsModel(String JavaDoc name) throws RDFRDBException;
186      
187     /**
188      * Test if a default model is contained in the database.
189      *
190      * A default model is a model for which no specific name was specified.
191      * (One that was created by calling ModelRDB.createModel without specifying
192      * a name).
193      *
194      * @return Boolean true if the model is contained in the database
195      * @throws RDFDBException
196      * @since Jena 2.0
197      */

198      public boolean containsDefaultModel() throws RDFRDBException;
199
200     /** Get the database-specific driver
201      *
202      * For this to work, it needs to know the type of database being used.
203      * That may be specified in the constructor (preferred) or done later
204      * by using the setDatabaseType method (for backward compatability).
205      */

206     
207     public IRDBDriver getDriver() throws RDFRDBException;
208     
209     /**
210      * Set the IRDBDriver to use for this connection.
211      * Useful to enable external drivers to be registered outside of the
212      * standard driver package.
213      */

214     public void setDriver(IRDBDriver driver);
215
216     /**
217      * Helper function to locate and instantiate the driver class corresponding
218      * to a given layout and database name
219      * Throws an RDFRDBexception if the driver can't be instantiated
220      * @deprecated As of Jena 2.0 this call should not be used. Instead specify the database type
221      * when constructing a DBConnection and then pass that connection to the GraphRDB. There is
222      * no longer any need for applications to interact with the IRDBDriver. To customize the
223      * database configuration/layout use the formatDB(propertyModel) call.
224      */

225     public IRDBDriver getDriver(String JavaDoc layout, String JavaDoc database) throws RDFRDBException;
226
227 }
228
229 /*
230  * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
231  * All rights reserved.
232  *
233  * Redistribution and use in source and binary forms, with or without
234  * modification, are permitted provided that the following conditions
235  * are met:
236  * 1. Redistributions of source code must retain the above copyright
237  * notice, this list of conditions and the following disclaimer.
238  * 2. Redistributions in binary form must reproduce the above copyright
239  * notice, this list of conditions and the following disclaimer in the
240  * documentation and/or other materials provided with the distribution.
241  * 3. The name of the author may not be used to endorse or promote products
242  * derived from this software without specific prior written permission.
243
244  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
245  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
246  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
247  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
248  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
249  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
250  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
251  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
253  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
254  */
Popular Tags