public final class VirtuosoConnectionWrapper extends Object
Connection
to a Virtuoso database.
Wraps SQLException
an ODCleanStoreException and serves as a factory class
for WrappedResultSet
.
Non-static methods are not thread-safe.Modifier and Type | Field and Description |
---|---|
static int |
TTL_FLAGS
Flags for TTL import.
|
Modifier and Type | Method and Description |
---|---|
void |
adjustTransactionIsolationLevel(int level)
Adjust transaction isolation level.
|
EnumLogLevel |
adjustTransactionLevel(EnumLogLevel logLevel)
Adjust transaction logging level and auto commit.
|
void |
close()
Closes the wrapped connection.
|
void |
closeQuietly()
Closes the wrapped connection without throwing an exception.
|
void |
commit()
Commit changes to the database.
|
static VirtuosoConnectionWrapper |
createConnection(JDBCConnectionCredentials connectionCredentials)
Create a new connection and return its wrapper.
|
void |
dropGraph(String graphName)
Drop graph from the database.
|
int |
execute(String query)
Executes a general SQL/SPARQL query.
|
int |
execute(String query,
Object... objects)
Executes a general SQL/SPARQL query.
|
boolean |
executeAsk(String query)
Executes a SPARQL ASK query and returns the result.
|
int |
executeNullsAllowed(String query,
Object... objects)
Executes a general SQL/SPARQL query with nulls object allowed.
|
WrappedResultSet |
executeSelect(String query)
Executes an SQL/SPARQL SELECT query and returns a wrapper for the result.
|
WrappedResultSet |
executeSelect(String query,
Object... objects)
Executes an SQL/SPARQL SELECT query and returns a wrapper for the result.
|
void |
exportToTTL(File exportFile,
String graphName)
Exports a named graph to the given file in TTL format.
|
protected void |
finalize()
Close connection on finalize().
|
String |
getServerRoot()
Returns Virtuoso server working directory.
|
void |
insertN3FromFile(File ttlFile,
String graphName,
String relativeBase)
Insert RDF data from file in N3 format to the database.
|
void |
insertRdfXmlFromFile(File rdfXmlFile,
String graphName,
String relativeBase)
Insert RDF data from file in rdfXml format to the database.
|
void |
renameGraph(String srcGraphName,
String dstGraphName)
Rename graph in DB.DBA.RDF_QUAD.
|
void |
rollback()
Revert changes to the last commit.
|
void |
setQueryTimeout(int queryTimeout)
Sets query timeout for all queries executed through this wrapper.
|
public static final int TTL_FLAGS
public static VirtuosoConnectionWrapper createConnection(JDBCConnectionCredentials connectionCredentials) throws ConnectionException
connectionCredentials
- connection settings for the SPARQL endpointConnectionException
- database connection errorpublic void setQueryTimeout(int queryTimeout)
queryTimeout
- the new query timeout limit in seconds; zero means there is no limitpublic WrappedResultSet executeSelect(String query) throws QueryException
query
- SQL/SPARQL queryQueryException
- query errorpublic WrappedResultSet executeSelect(String query, Object... objects) throws QueryException
query
- SQL/SPARQL queryobjects
- query bindingsQueryException
- query errorpublic boolean executeAsk(String query) throws QueryException
query
- SQL/SPARQL queryQueryException
- query errorpublic int execute(String query) throws QueryException
query
- SQL/SPARQL queryQueryException
- query errorpublic int execute(String query, Object... objects) throws QueryException
query
- SQL/SPARQL queryobjects
- query bindingsQueryException
- query errorpublic int executeNullsAllowed(String query, Object... objects) throws QueryException
query
- SQL/SPARQL queryobjects
- query bindingsQueryException
- query errorpublic void commit() throws SQLException
SQLException
- if a database access error occurs, this method is called while participating in a
distributed transaction, if this method is called on a closed connection or this Connection object is in
auto-commit modepublic void rollback() throws SQLException
SQLException
- if a database access error occurs, this method is called while participating in a
distributed transaction, if this method is called on a closed conection or this Connection object is in
auto-commit modepublic EnumLogLevel adjustTransactionLevel(EnumLogLevel logLevel) throws ConnectionException
logLevel
- Virtuoso transaction logging level and auto-commit settingsConnectionException
- database errorpublic void adjustTransactionIsolationLevel(int level) throws ConnectionException
level
- - one of the following Connection constants:ConnectionException
- database errorpublic void close() throws ConnectionException
ConnectionException
- connection errorpublic void closeQuietly()
protected void finalize()
public void renameGraph(String srcGraphName, String dstGraphName) throws QueryException
srcGraphName
- graphdstGraphName
- graphQueryException
- query errorSQLException
public void dropGraph(String graphName) throws QueryException
graphName
- name of the graph to clearQueryException
- query errorpublic void insertRdfXmlFromFile(File rdfXmlFile, String graphName, String relativeBase) throws QueryException, ConnectionException
rdfXmlFile
- file with payload in RdfXml formatgraphName
- name of the graph to insertrelativeBase
- relative URI base for payloadQueryException
- query errorConnectionException
public void insertN3FromFile(File ttlFile, String graphName, String relativeBase) throws QueryException, ConnectionException
ttlFile
- file with payload in N3 formatgraphName
- name of the graph to insertrelativeBase
- relative URI base for payloadQueryException
- query errorConnectionException
public void exportToTTL(File exportFile, String graphName) throws QueryException
exportFile
- file to export tographName
- name of the graph to insertQueryException
- query errorpublic String getServerRoot() throws QueryException
QueryException
- exceptionCopyright © 2013. All Rights Reserved.