Class JenaConnection
- All Implemented Interfaces:
AutoCloseable
,Connection
,Wrapper
- Direct Known Subclasses:
DatasetConnection
,RemoteEndpointConnection
Generally speaking this is a faithful implementation of a JDBC connection but it also provides a couple of Jena JDBC specific features:
- JDBC compatibility level
- Command pre-processors
The JDBC compatibility level allows the API to behave slightly differently
depending on how JDBC like you need it to be, see JdbcCompatibility
for more discussion on this.
Command pre-processors are an extension mechanism designed to allow Jena JDBC connections to cope with the fact that the tools consuming the API may be completely unaware that we speak SPARQL rather than SQL. They allow for manipulation of incoming command text as well as manipulation of the parsed SPARQL queries and updates as desired.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Constant for default auto-commit for Jena JDBC connectionsstatic final int
Constant for default cursor holdability for Jena JDBC connectionsstatic final int
Constant for default transaction isolation level for Jena JDBC connectionsFields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
-
Constructor Summary
ConstructorsConstructorDescriptionJenaConnection
(int holdability, boolean autoCommit, int transactionLevel, int compatibilityLevel) Creates a new connection -
Method Summary
Modifier and TypeMethodDescriptionvoid
final void
addPostProcessor
(ResultsPostProcessor postProcessor) Adds a results post-processor to the connectionfinal void
addPreProcessor
(CommandPreProcessor preProcessor) Adds a command pre-processor to the connectionfinal boolean
applyPostProcessors
(boolean result) Applies registered post-processors to the given resultsapplyPostProcessors
(Iterator<Triple> triples) Applies registered post-processors to the given resultsfinal AskResultsMetadata
applyPostProcessors
(AskResultsMetadata metadata) Applies registered post-processors to the given results metadatafinal SelectResultsMetadata
applyPostProcessors
(SelectResultsMetadata metadata) Applies registered post-processors to the given results metadatafinal TripleResultsMetadata
applyPostProcessors
(TripleResultsMetadata metadata) Applies registered post-processors to the given results metadatafinal ResultSet
applyPostProcessors
(ResultSet results) Applies registered post-processors to the given resultsfinal String
applyPreProcessors
(String text) Apply registered pre-processors to the given command textfinal Query
Applies registered pre-processors to the given queryfinal UpdateRequest
Applies registered pre-processors to the given updatefinal void
Clears all command post-processors from the connectionfinal void
Clears all command pre-processor from the connectionvoid
final void
close()
void
commit()
createArrayOf
(String typeName, Object[] elements) final Statement
final Statement
createStatement
(int resultSetType, int resultSetConcurrency) final Statement
createStatement
(int resultSetType, int resultSetConcurrency, int resultSetHoldability) createStruct
(String typeName, Object[] attributes) boolean
getClientInfo
(String name) int
int
Gets the JDBC compatibility level that is in use, seeJdbcCompatibility
for explanationsabstract DatabaseMetaData
int
final Iterator<ResultsPostProcessor>
Gets the currently registered post-processors for the connectionfinal Iterator<CommandPreProcessor>
Gets the currently registered pre-processors for the connectionint
final void
insertPostProcessor
(int index, ResultsPostProcessor postProcessor) Inserts a results post-processor for the connectionfinal void
insertPreProcessor
(int index, CommandPreProcessor preProcessor) Inserts a command pre-processor for the connectionabstract boolean
isClosed()
abstract boolean
abstract boolean
isValid
(int timeout) boolean
isWrapperFor
(Class<?> arg0) prepareCall
(String sql) prepareCall
(String sql, int resultSetType, int resultSetConcurrency) prepareCall
(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement
(String sql) prepareStatement
(String sql, int autoGeneratedKeys) prepareStatement
(String sql, int[] columnIndexes) prepareStatement
(String sql, int resultSetType, int resultSetConcurrency) prepareStatement
(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement
(String sql, String[] columnNames) void
releaseSavepoint
(Savepoint savepoint) final void
removePostProcessor
(int index) Removes a results post-processor from the connectionfinal void
removePostProcessor
(ResultsPostProcessor postProcessor) Removes a results post-processor from the connectionfinal void
removePreProcessor
(int index) Removes a command pre-processor from the connectionfinal void
removePreProcessor
(CommandPreProcessor preProcessor) Removes a command pre-processor from the connectionvoid
rollback()
void
void
setAutoCommit
(boolean autoCommit) void
setCatalog
(String catalog) void
setClientInfo
(String name, String value) void
setClientInfo
(Properties properties) void
setHoldability
(int holdability) void
setJdbcCompatibilityLevel
(int level) Sets the JDBC compatibility level that is in use, seeJdbcCompatibility
for explanations.void
setNetworkTimeout
(Executor executor, int milliseconds) abstract void
setReadOnly
(boolean readOnly) setSavepoint
(String name) void
void
setTransactionIsolation
(int level) void
setTypeMap
(Map<String, Class<?>> map) <T> T
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
Field Details
-
DEFAULT_HOLDABILITY
public static final int DEFAULT_HOLDABILITYConstant for default cursor holdability for Jena JDBC connections- See Also:
-
DEFAULT_AUTO_COMMIT
public static final boolean DEFAULT_AUTO_COMMITConstant for default auto-commit for Jena JDBC connections- See Also:
-
DEFAULT_ISOLATION_LEVEL
public static final int DEFAULT_ISOLATION_LEVELConstant for default transaction isolation level for Jena JDBC connections- See Also:
-
-
Constructor Details
-
JenaConnection
public JenaConnection(int holdability, boolean autoCommit, int transactionLevel, int compatibilityLevel) throws SQLException Creates a new connection- Parameters:
holdability
- Cursor holdabilityautoCommit
- Sets auto-commit behaviour for the connectiontransactionLevel
- Sets transaction isolation level for the connectioncompatibilityLevel
- Sets JDBC compatibility level for the connection, seeJdbcCompatibility
- Throws:
SQLException
- Thrown if the arguments are invalid
-
-
Method Details
-
getJdbcCompatibilityLevel
public int getJdbcCompatibilityLevel()Gets the JDBC compatibility level that is in use, seeJdbcCompatibility
for explanations- Returns:
- Compatibility level
-
setJdbcCompatibilityLevel
public void setJdbcCompatibilityLevel(int level) Sets the JDBC compatibility level that is in use, seeJdbcCompatibility
for explanations.Changing the level may not effect existing open objects, behaviour in this case will be implementation specific.
- Parameters:
level
- Compatibility level
-
addPreProcessor
Adds a command pre-processor to the connection- Parameters:
preProcessor
- Pre-processor to add
-
addPostProcessor
Adds a results post-processor to the connection- Parameters:
postProcessor
- Post-processor to add
-
insertPreProcessor
Inserts a command pre-processor for the connection- Parameters:
index
- Index to insert atpreProcessor
- Pre-processor
-
insertPostProcessor
Inserts a results post-processor for the connection- Parameters:
index
- Index to insert atpostProcessor
- Post-processor
-
removePreProcessor
Removes a command pre-processor from the connection- Parameters:
preProcessor
- Pre-processor to remove
-
removePostProcessor
Removes a results post-processor from the connection- Parameters:
postProcessor
- Post-processor to remove
-
removePreProcessor
public final void removePreProcessor(int index) Removes a command pre-processor from the connection- Parameters:
index
- Index to remove at
-
removePostProcessor
public final void removePostProcessor(int index) Removes a results post-processor from the connection- Parameters:
index
- Index to remove at
-
clearPreProcessors
public final void clearPreProcessors()Clears all command pre-processor from the connection -
clearPostProcessors
public final void clearPostProcessors()Clears all command post-processors from the connection -
getPreProcessors
Gets the currently registered pre-processors for the connection- Returns:
- Iterator of pre-processors
-
getPostProcessors
Gets the currently registered post-processors for the connection- Returns:
- Iterator of post-processors
-
applyPreProcessors
Apply registered pre-processors to the given command text- Parameters:
text
- Command Text- Returns:
- Command Text after processing by registered pre-processors
- Throws:
SQLException
-
applyPreProcessors
Applies registered pre-processors to the given query- Parameters:
q
- Query- Returns:
- Query after processing by registered pre-processors
- Throws:
SQLException
-
applyPreProcessors
Applies registered pre-processors to the given update- Parameters:
u
- Update- Returns:
- Update after processing by registered pre-processors
- Throws:
SQLException
-
applyPostProcessors
Applies registered post-processors to the given results- Parameters:
results
- Results- Returns:
- Results after processing by registered post-processors
- Throws:
SQLException
-
applyPostProcessors
Applies registered post-processors to the given results- Parameters:
triples
- Results- Returns:
- Results after processing by registered post-processors
- Throws:
SQLException
-
applyPostProcessors
Applies registered post-processors to the given results- Parameters:
result
- Result- Returns:
- Result after processing by registered post-processors
- Throws:
SQLException
-
applyPostProcessors
public final SelectResultsMetadata applyPostProcessors(SelectResultsMetadata metadata) throws SQLException Applies registered post-processors to the given results metadata- Parameters:
metadata
- Results metadata- Returns:
- Results metadata after processing by registered post-processors
- Throws:
SQLException
-
applyPostProcessors
public final TripleResultsMetadata applyPostProcessors(TripleResultsMetadata metadata) throws SQLException Applies registered post-processors to the given results metadata- Parameters:
metadata
- Results metadata- Returns:
- Results metadata after processing by registered post-processors
- Throws:
SQLException
-
applyPostProcessors
public final AskResultsMetadata applyPostProcessors(AskResultsMetadata metadata) throws SQLException Applies registered post-processors to the given results metadata- Parameters:
metadata
- Results metadata- Returns:
- Results metadata after processing by registered post-processors
- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
clearWarnings
public void clearWarnings()- Specified by:
clearWarnings
in interfaceConnection
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Throws:
SQLException
-
commit
- Specified by:
commit
in interfaceConnection
- Throws:
SQLException
-
createArrayOf
- Specified by:
createArrayOf
in interfaceConnection
- Throws:
SQLException
-
createBlob
- Specified by:
createBlob
in interfaceConnection
- Throws:
SQLException
-
createClob
- Specified by:
createClob
in interfaceConnection
- Throws:
SQLException
-
createNClob
- Specified by:
createNClob
in interfaceConnection
- Throws:
SQLException
-
createSQLXML
- Specified by:
createSQLXML
in interfaceConnection
- Throws:
SQLException
-
createStatement
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
createStatement
public final Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
createStatement
public final Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
createStruct
- Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit()- Specified by:
getAutoCommit
in interfaceConnection
-
getCatalog
- Specified by:
getCatalog
in interfaceConnection
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
-
getHoldability
public int getHoldability()- Specified by:
getHoldability
in interfaceConnection
-
getMetaData
- Specified by:
getMetaData
in interfaceConnection
- Throws:
SQLException
-
getTransactionIsolation
public int getTransactionIsolation()- Specified by:
getTransactionIsolation
in interfaceConnection
-
getTypeMap
- Specified by:
getTypeMap
in interfaceConnection
- Throws:
SQLException
-
getWarnings
- Specified by:
getWarnings
in interfaceConnection
-
isClosed
- Specified by:
isClosed
in interfaceConnection
- Throws:
SQLException
-
isReadOnly
- Specified by:
isReadOnly
in interfaceConnection
- Throws:
SQLException
-
isValid
- Specified by:
isValid
in interfaceConnection
- Throws:
SQLException
-
nativeSQL
- Specified by:
nativeSQL
in interfaceConnection
- Throws:
SQLException
-
prepareCall
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
releaseSavepoint
- Specified by:
releaseSavepoint
in interfaceConnection
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) - Specified by:
setAutoCommit
in interfaceConnection
-
setCatalog
- Specified by:
setCatalog
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
-
setHoldability
- Specified by:
setHoldability
in interfaceConnection
- Throws:
SQLException
-
setReadOnly
- Specified by:
setReadOnly
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
setTypeMap
- Specified by:
setTypeMap
in interfaceConnection
- Throws:
SQLException
-
setSchema
- Specified by:
setSchema
in interfaceConnection
- Throws:
SQLException
-
getSchema
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
abort
- Specified by:
abort
in interfaceConnection
- Throws:
SQLException
-
getNetworkTimeout
- Specified by:
getNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
setNetworkTimeout
- Specified by:
setNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-