|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hp.hpl.jena.db.DBConnection
Encapsulate the specification of a jdbc connection. This is mostly used to simplify the calling pattern for ModelRDB factory methods.
Constructor Summary | |
DBConnection(java.sql.Connection connection)
Deprecated. As of Jena 2.0, it is recommended to use one of the DBConnection constructors which takes a database type as an argument. (The DBConnection can operate more efficiently if it knows the database type). |
|
DBConnection(java.sql.Connection connection,
java.lang.String databaseType)
Create a connection specification that just wraps up an existing database connection. |
|
DBConnection(java.lang.String url,
java.lang.String user,
java.lang.String password)
Deprecated. As of Jena 2.0, it is recommended to use one of the DBConnection constructors which takes a database type as an argument. (The DBConnection can operate more efficiently if it knows the database type). |
|
DBConnection(java.lang.String url,
java.lang.String user,
java.lang.String password,
java.lang.String databaseType)
Create a connection specification based on jdbc address and appropriate authentication information. |
Method Summary | |
void |
cleanDB()
Clear all RDF information from the database. |
void |
close()
Close the jdbc connection. |
boolean |
containsDefaultModel()
Test if a default model is contained in the database. |
boolean |
containsModel(java.lang.String name)
Test if a given model is contained in the database. |
ExtendedIterator |
getAllModelNames()
Retrieve a list of all graphs in the database. |
java.sql.Connection |
getConnection()
Return the jdbc connection or null if we no longer have access to a connection. |
Model |
getDatabaseProperties()
Returns a Jena Model containing database-specific properties. |
java.lang.String |
getDatabaseType()
Get the database type. |
Model |
getDefaultModelProperties()
Retrieve a default set of model customization properties. |
com.hp.hpl.jena.db.impl.IRDBDriver |
getDriver()
Get the database-specific driver For this to work, it needs to know the type of database being used. |
com.hp.hpl.jena.db.impl.IRDBDriver |
getDriver(java.lang.String layout,
java.lang.String database)
Deprecated. As of Jena 2.0 this call should not be used. Instead specify the database type when constructing a DBConnection and then pass that connection to the ModelRDB. There is no longer any need for applications to interact directly with the IRDBDriver. To customize the database configuration/layout use the setDatabaseProperties method. |
boolean |
isFormatOK()
Return true if the database seems to be formated for RDF storage. |
void |
setDatabaseProperties(Model dbProperties)
Set the database-specific properties. |
void |
setDatabaseType(java.lang.String databaseType)
Set the database type manually. |
void |
setDriver(com.hp.hpl.jena.db.impl.IRDBDriver driver)
Set the IRDBDriver to use for this connection. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DBConnection(java.lang.String url, java.lang.String user, java.lang.String password)
url
- the jdbc url for the database, note that the format of this
is database dependent and that the appropriate jdbc driver will need to
be specified via the standard pattern
Class.forName("my.sql.driver");
user
- the user name to log on withpassword
- the password corresponding to this userpublic DBConnection(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String databaseType)
url
- the jdbc url for the database, note that the format of this
is database dependent and that the appropriate jdbc driver will need to
be specified via the standard pattern
Class.forName("my.sql.driver");
user
- the user name to log on withpassword
- the password corresponding to this userdatabaseType
- the type of database to which we are connecting.public DBConnection(java.sql.Connection connection)
connection
- the open jdbc connection to usepublic DBConnection(java.sql.Connection connection, java.lang.String databaseType)
connection
- the open jdbc connection to usedatabaseType
- the type of database to which we are connecting.Method Detail |
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface IDBConnection
java.sql.SQLException
public void close() throws java.sql.SQLException
close
in interface IDBConnection
java.sql.SQLException
public void cleanDB() throws java.sql.SQLException
cleanDB
in interface IDBConnection
java.sql.SQLException
public boolean isFormatOK()
isFormatOK
in interface IDBConnection
public void setDatabaseProperties(Model dbProperties) throws RDFRDBException
This call is only valid before the first Model is stored in the database. After that point, the database structure is frozen.
Use the properties to optionally customize the database - this won't change the results you see when using the Graph or Model interfaces, but it may alter the speed with which you get them or the space required by the database.
The properties must form a complete and consistent set.
The easist way to get a complete and consistent set is to call
getDatabaseProperties()
, modify it, and then use that as an argument
in the call to setDatbaseProperties()
. Remember that most properties
can only have a single value, so to change values you'll need to replace the
appropriate statements (rather than just adding additional ones).
May throw an exception if the database cannot be suitably formatted with the new parameters. Note that some implementations may delay processing the parameters until the first Model is constructed. Thus a successful return from this call does not guarantee the properties are correct and consistent.
setDatabaseProperties
in interface IDBConnection
dbProperties
- is a Jena Model describing the database parameters
RDFRDBException
public Model getDatabaseProperties() throws RDFRDBException
setDatabaseProperties
.
getDatabaseProperties
in interface IDBConnection
RDFRDBException
public Model getDefaultModelProperties() throws RDFRDBException
getDefaultModelProperties
in interface IDBConnection
RDFRDBException
public ExtendedIterator getAllModelNames() throws RDFRDBException
getAllModelNames
in interface IDBConnection
RDFDBException
RDFRDBException
public boolean containsModel(java.lang.String name) throws RDFRDBException
containsModel
in interface IDBConnection
name
- the name of a model which may be in the database
RDFDBException
RDFRDBException
public boolean containsDefaultModel() throws RDFRDBException
containsDefaultModel
in interface IDBConnection
RDFDBException
RDFRDBException
public void setDatabaseType(java.lang.String databaseType)
setDatabaseType
in interface IDBConnection
public java.lang.String getDatabaseType()
getDatabaseType
in interface IDBConnection
public com.hp.hpl.jena.db.impl.IRDBDriver getDriver() throws RDFRDBException
getDriver
in interface IDBConnection
RDFRDBException
public void setDriver(com.hp.hpl.jena.db.impl.IRDBDriver driver)
setDriver
in interface IDBConnection
public com.hp.hpl.jena.db.impl.IRDBDriver getDriver(java.lang.String layout, java.lang.String database) throws RDFRDBException
getDriver
in interface IDBConnection
RDFRDBException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |