|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DatabaseAdaptor
The main high-level interface for working with a triplestore.
With a DatabaseAdaptor
, you can add and delete triples
and perform interpreted queries against the triplestore.
Note that each method takes an existing JDBC Connection
as a
parameter. Client applications are expected to open/close or
borrow/release connections as needed. In addition, transaction
boundaries are expected to be managed externally.
Method Summary | |
---|---|
void |
addTriples(java.sql.Connection conn,
java.util.Iterator<Triple> triples)
Add the given triples. |
void |
deleteAllTriples(java.sql.Connection conn)
Delete all triples. |
void |
deleteTriples(java.sql.Connection conn,
java.util.Iterator<Triple> triples)
Delete the given triples. |
QueryResults |
query(java.sql.Connection connection,
QueryLanguage lang,
int fetchSize,
boolean autoReleaseConnection,
java.lang.String queryText)
Evaluate the given query in the specified language and return the results. |
Method Detail |
---|
void addTriples(java.sql.Connection conn, java.util.Iterator<Triple> triples) throws ModificationException
conn
- The database connection to use.triples
- The triples to add.
ModificationException
- if the operation failed for any reason.void deleteTriples(java.sql.Connection conn, java.util.Iterator<Triple> triples) throws ModificationException
conn
- The database connection to use.triples
- The triples to delete.
ModificationException
- if the operation failed for any reason.void deleteAllTriples(java.sql.Connection conn) throws ModificationException
conn
- The database connection to use.
ModificationException
- if the operation failed for any reason.QueryResults query(java.sql.Connection connection, QueryLanguage lang, int fetchSize, boolean autoReleaseConnection, java.lang.String queryText) throws QueryException
That depends. If autoReleaseConnection
is
true
, the caller is guaranteed that if the query
fails or the results are closed at any time, the connection
will be restored to auto-commit mode and released. This
can greatly simplify the caller's job as it can forget about
the connection and just make sure the QueryResults
object is closed.
On the other hand, if autoReleaseConnection
is false
, the caller is entirely responsible
for the connection. This is useful in cases where the
query is only part of an as-yet incomplete transaction.
The fetchSize
parameter can be used to avoid
memory exhaustion when the number of expected results may be
very large. The parameter acts as a hint to the JDBC driver
as to the number of rows that should be retrieved from the
database at a time.
If specified as 0
, the hint is ignored and the
database will likely send all results at once for each
ResultSet
. On very large result sets, this can
result in memory exhaustion.
If you don't want to accept the default behavior, you should also be aware of how the underlying RDBMS handles fetch sizes. For example:
0
and Integer.MIN_VALUE
.
The latter actually provides one result at a time
and has table locking consequences.
connection
- the database connection to use.lang
- the language of the query.fetchSize
- gives the JDBC driver a hint as to the number of rows
that should be fetched from the database when more
rows are needed. If zero, the hint is ignored and the
database may send all results to the driver at once.autoReleaseConnection
- whether to automatically release/close
the connection if the query fails or the results
are closed.queryText
- The query.
QueryException
- if the query failed for any reason.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |