virtuoso.sesame2.driver
Class VirtuosoRepository

java.lang.Object
  extended by virtuoso.sesame2.driver.VirtuosoRepository
All Implemented Interfaces:
org.openrdf.repository.Repository

public class VirtuosoRepository
extends java.lang.Object
implements org.openrdf.repository.Repository

A Sesame repository that contains RDF data that can be queried and updated. Access to the repository can be acquired by openening a connection to it. This connection can then be used to query and/or update the contents of the repository. Depending on the implementation of the repository, it may or may not support multiple concurrent connections.

Please note that a repository needs to be initialized before it can be used and that it should be shut down before it is discarded/garbage collected. Forgetting the latter can result in loss of data (depending on the Repository implementation)!


Constructor Summary
VirtuosoRepository(java.lang.String url_hostlist, java.lang.String user, java.lang.String password)
          Construct a VirtuosoRepository with a specified parameters.
VirtuosoRepository(java.lang.String url_hostlist, java.lang.String user, java.lang.String password, boolean useLazyAdd)
          Construct a VirtuosoRepository with a specified parameters defGraph will be set to "sesame:nil".
VirtuosoRepository(java.lang.String url_hostlist, java.lang.String user, java.lang.String password, java.lang.String defGraph)
          Construct a VirtuosoRepository with a specified parameters.
VirtuosoRepository(java.lang.String url_hostlist, java.lang.String user, java.lang.String password, java.lang.String defGraph, boolean useLazyAdd)
          Construct a VirtuosoRepository with a specified parameters
 
Method Summary
 void createRuleSet(java.lang.String ruleSetName, java.lang.String uriGraphRuleSet)
           
 org.openrdf.repository.RepositoryConnection getConnection()
          Opens a connection to this repository that can be used for querying and updating the contents of the repository.
 java.io.File getDataDir()
          Get the directory where data and logging for this repository is stored.
 int getFetchSize()
          Get the buffer fetch size
 int getResultsHandlerType()
           
 boolean getRoundrobin()
          Get the RoundRobin state for connection
 java.lang.String getRuleSet()
          Get the RoundRobin state for connection
 org.openrdf.model.ValueFactory getValueFactory()
          Gets a ValueFactory for this Repository.
 void initialize()
          Initializes this repository.
 boolean isWritable()
          Checks whether this repository is writable, i.e.
 void setDataDir(java.io.File dataDir)
          Set the directory where data and logging for this repository is stored.
 void setFetchSize(int sz)
          Set the buffer fetch size(default 200)
 void setResultsHandlerType(int handlerType)
           
 void setRoundrobin(boolean v)
          Set the RoundRobin state for connection(default false)
 void setRuleSet(java.lang.String name)
          Set inference RuleSet name
 void shutDown()
          Shuts the repository down, releasing any resources that it keeps hold of.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtuosoRepository

public VirtuosoRepository(java.lang.String url_hostlist,
                          java.lang.String user,
                          java.lang.String password,
                          java.lang.String defGraph,
                          boolean useLazyAdd)
Construct a VirtuosoRepository with a specified parameters

Parameters:
url_hostlist - the Virtuoso JDBC URL connection string or hostlist for poolled connection. Virtuoso database hostlist
        "hostone:1112,hosttwo:1113" 
     or "hostone,hosttwo" if default port=1111 is used on hosts
        
user - the database user on whose behalf the connection is being made
password - the user's password
defGraph - a default Graph name, used for Sesame calls, when contexts list is empty, exclude exportStatements, hasStatement, getStatements methods
useLazyAdd - set true to enable using batch optimization for sequence of
          add(Resource subject, URI predicate, Value object, Resource... contexts);
        add(Statement statement, Resource... contexts);
        
methods, when autoCommit mode is off. The triples will be sent to DBMS on commit call or when batch size become more than predefined batch max_size.

VirtuosoRepository

public VirtuosoRepository(java.lang.String url_hostlist,
                          java.lang.String user,
                          java.lang.String password,
                          boolean useLazyAdd)
Construct a VirtuosoRepository with a specified parameters defGraph will be set to "sesame:nil".

Parameters:
url_hostlist - the Virtuoso JDBC URL connection string or hostlist for poolled connection. Virtuoso database hostlist
        "hostone:1112,hosttwo:1113" 
     or "hostone,hosttwo" if default port=1111 is used on hosts
        
user - the database user on whose behalf the connection is being made
password - the user's password
useLazyAdd - set true to enable using batch optimization for sequence of
          add(Resource subject, URI predicate, Value object, Resource... contexts);
        add(Statement statement, Resource... contexts);
        
methods, when autoCommit mode is off. The triples will be sent to DBMS on commit call or when batch size become more than predefined batch max_size.

VirtuosoRepository

public VirtuosoRepository(java.lang.String url_hostlist,
                          java.lang.String user,
                          java.lang.String password,
                          java.lang.String defGraph)
Construct a VirtuosoRepository with a specified parameters. useLazyAdd will be set to false.

Parameters:
url_hostlist - the Virtuoso JDBC URL connection string or hostlist for poolled connection. Virtuoso database hostlist
        "hostone:1112,hosttwo:1113" 
     or "hostone,hosttwo" if the default port=1111 is used for hosts
        
user - the database user on whose behalf the connection is being made
password - the user's password
defGraph - a default Graph name, used for Sesame calls, when contexts list is empty, exclude exportStatements, hasStatement, getStatements methods

VirtuosoRepository

public VirtuosoRepository(java.lang.String url_hostlist,
                          java.lang.String user,
                          java.lang.String password)
Construct a VirtuosoRepository with a specified parameters. useLazyAdd will be set to false. defGraph will be set to "sesame:nil".

Parameters:
url_hostlist - the Virtuoso JDBC URL connection string or hostlist for poolled connection. Virtuoso database hostlist
        "hostone:1112,hosttwo:1113" 
     or "hostone,hosttwo" if the default port=1111 is used for hosts
        
user - the database user on whose behalf the connection is being made
password - the user's password
defGraph - a default Graph name, used for Sesame calls, when contexts list is empty, exclude exportStatements, hasStatement, getStatements methods
Method Detail

getConnection

public org.openrdf.repository.RepositoryConnection getConnection()
                                                          throws org.openrdf.repository.RepositoryException
Opens a connection to this repository that can be used for querying and updating the contents of the repository. Created connections need to be closed to make sure that any resources they keep hold of are released. The best way to do this is to use a try-finally-block as follows:
 Connection con = repository.getConnection();
 try {
        // perform operations on the connection
 }
 finally {
        con.close();
 }
 

Specified by:
getConnection in interface org.openrdf.repository.Repository
Returns:
A connection that allows operations on this repository.
Throws:
org.openrdf.repository.RepositoryException - If something went wrong during the creation of the Connection.

setFetchSize

public void setFetchSize(int sz)
Set the buffer fetch size(default 200)

Parameters:
sz - buffer fetch size.

getFetchSize

public int getFetchSize()
Get the buffer fetch size


setRoundrobin

public void setRoundrobin(boolean v)
Set the RoundRobin state for connection(default false)

Parameters:
sz - buffer fetch size.

getRoundrobin

public boolean getRoundrobin()
Get the RoundRobin state for connection


setRuleSet

public void setRuleSet(java.lang.String name)
Set inference RuleSet name

Parameters:
name - RuleSet name.

getRuleSet

public java.lang.String getRuleSet()
Get the RoundRobin state for connection


getDataDir

public java.io.File getDataDir()
Get the directory where data and logging for this repository is stored.

Specified by:
getDataDir in interface org.openrdf.repository.Repository
Returns:
the directory where data for this repository is stored.

getValueFactory

public org.openrdf.model.ValueFactory getValueFactory()
Gets a ValueFactory for this Repository.

Specified by:
getValueFactory in interface org.openrdf.repository.Repository
Returns:
A repository-specific ValueFactory.

initialize

public void initialize()
                throws org.openrdf.repository.RepositoryException
Initializes this repository. A repository needs to be initialized before it can be used.

Specified by:
initialize in interface org.openrdf.repository.Repository
Throws:
org.openrdf.repository.RepositoryException - If the initialization failed.

isWritable

public boolean isWritable()
                   throws org.openrdf.repository.RepositoryException
Checks whether this repository is writable, i.e. if the data contained in this repository can be changed. The writability of the repository is determined by the writability of the Sail that this repository operates on.

Specified by:
isWritable in interface org.openrdf.repository.Repository
Throws:
org.openrdf.repository.RepositoryException

setDataDir

public void setDataDir(java.io.File dataDir)
Set the directory where data and logging for this repository is stored.

Specified by:
setDataDir in interface org.openrdf.repository.Repository
Parameters:
dataDir - the directory where data for this repository is stored

shutDown

public void shutDown()
              throws org.openrdf.repository.RepositoryException
Shuts the repository down, releasing any resources that it keeps hold of. Once shut down, the repository can no longer be used until it is re-initialized.

Specified by:
shutDown in interface org.openrdf.repository.Repository
Throws:
org.openrdf.repository.RepositoryException

getResultsHandlerType

public int getResultsHandlerType()

setResultsHandlerType

public void setResultsHandlerType(int handlerType)

createRuleSet

public void createRuleSet(java.lang.String ruleSetName,
                          java.lang.String uriGraphRuleSet)
                   throws org.openrdf.repository.RepositoryException
Throws:
org.openrdf.repository.RepositoryException