use of org.apache.jena.jdbc.mem.connections.MemConnection in project jena by apache.
the class TestDatasetConnectionMetadata method getConnection.
@Override
protected JenaConnection getConnection() throws SQLException {
Dataset ds = supportsSerializable ? DatasetFactory.createTxnMem() : DatasetFactory.create();
int transactionLevelSupported = supportsSerializable ? JenaConnection.TRANSACTION_SERIALIZABLE : JenaConnection.TRANSACTION_NONE;
return new MemConnection(ds, JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, transactionLevelSupported, JdbcCompatibility.DEFAULT);
}
use of org.apache.jena.jdbc.mem.connections.MemConnection in project jena by apache.
the class MemDriver method connect.
@Override
protected JenaConnection connect(Properties props, int compatibilityLevel) throws SQLException {
Object dsObj = props.get(PARAM_DATASET);
String empty = props.getProperty(PARAM_EMPTY);
if (dsObj == null && empty == null)
throw new SQLException("Neither one of the " + PARAM_DATASET + " or " + PARAM_EMPTY + " connection parameters is present in the JDBC Connection URL or the provided Properties object");
if (dsObj != null) {
if (dsObj instanceof Dataset) {
// Dataset provided directly
return new MemConnection((Dataset) dsObj, JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
} else {
// Load dataset from a file
try {
Dataset ds = DatasetFactory.createMem();
RDFDataMgr.read(ds, dsObj.toString());
return new MemConnection(ds, JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
} catch (Exception e) {
throw new SQLException("Error occurred while reading from the specified RDF dataset file - " + dsObj.toString(), e);
}
}
} else if (this.isTrue(props, PARAM_EMPTY)) {
// Use an empty dataset
return new MemConnection(DatasetFactory.createMem(), JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
} else {
throw new SQLException("Insufficient parameters to create a Jena JDBC in-memory connection, please supply a Dataset file/instance via the " + PARAM_DATASET + " parameter or supply " + PARAM_EMPTY + "=true to connect to a new empty dataset");
}
}
Aggregations