|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.nsdl.mptstore.core.GenericDatabaseAdaptor
public class GenericDatabaseAdaptor
A DatabaseAdaptor
designed to work with any database.
This implementation uses only a subset of standard SQL92 syntax and
thus should be compatible with most RDBMS.
Constructor Summary | |
---|---|
GenericDatabaseAdaptor(TableManager tableManager,
boolean backslashIsEscape)
Get an instance supporting the built-in query languages. |
|
GenericDatabaseAdaptor(TableManager tableManager,
java.util.Map<QueryLanguage,QueryCompiler> compilerMap)
Get an instance supporting the specified query languages. |
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 language,
int fetchSize,
boolean autoReleaseConnection,
java.lang.String query)
Evaluate the given query in the specified language and return the results. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GenericDatabaseAdaptor(TableManager tableManager, boolean backslashIsEscape)
tableManager
- The TableManager
this instance
should use.backslashIsEscape
- A database vendor-specific specific value
indicating whether the backslash character in a string is
considered to be an escape character.public GenericDatabaseAdaptor(TableManager tableManager, java.util.Map<QueryLanguage,QueryCompiler> compilerMap)
tableManager
- The TableManager
this instance
should use.compilerMap
- A map of query language to query compiler.Method Detail |
---|
public void addTriples(java.sql.Connection conn, java.util.Iterator<Triple> triples) throws ModificationException
addTriples
in interface DatabaseAdaptor
conn
- The database connection to use.triples
- The triples to add.
ModificationException
- if the operation failed for any reason.public void deleteTriples(java.sql.Connection conn, java.util.Iterator<Triple> triples) throws ModificationException
deleteTriples
in interface DatabaseAdaptor
conn
- The database connection to use.triples
- The triples to delete.
ModificationException
- if the operation failed for any reason.public void deleteAllTriples(java.sql.Connection conn) throws ModificationException
deleteAllTriples
in interface DatabaseAdaptor
conn
- The database connection to use.
ModificationException
- if the operation failed for any reason.public QueryResults query(java.sql.Connection connection, QueryLanguage language, int fetchSize, boolean autoReleaseConnection, java.lang.String query) 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.
query
in interface DatabaseAdaptor
connection
- the database connection to use.language
- 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.query
- 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 |