use of org.apache.jena.sdb.SDBException in project jena by apache.
the class LoaderTuplesNodes method close.
/**
* Close this loader and finish the thread (if required)
*
*/
@Override
public void close() {
if (!initialized)
return;
try {
if (threading && commitThread.isAlive()) {
queue.put(finishSignal);
commitThread.join();
} else {
flushTriples();
}
} catch (Exception e) {
log.error("Problem closing loader: " + e.getMessage());
throw new SDBException("Problem closing loader", e);
} finally {
for (TupleLoader loader : this.tupleLoaders.values()) loader.close();
this.initialized = false;
this.commitThread = null;
this.queue = null;
this.tupleLoaderClass = null;
this.tupleLoaders = null;
}
}
use of org.apache.jena.sdb.SDBException in project jena by apache.
the class TupleLoaderBase method load.
@Override
public void load(Node... row) {
if (!amLoading) {
flush();
amLoading = true;
}
if (row.length != this.getTableWidth())
throw new IllegalArgumentException("Tuple size mismatch");
try {
for (int i = 0; i < row.length; i++) {
PreparedNode pNode = new PreparedNode(row[i]);
if (// if true, this is new...
seenNodes.add(pNode.hash))
pNode.addToStatement(insertNodeLoader);
insertTupleLoader.setLong(i + 1, pNode.hash);
}
insertTupleLoader.addBatch();
} catch (SQLException e) {
throw new SDBException("Problem adding to prepared loader statements", e);
}
tupleNum++;
if (tupleNum >= chunkSize)
flush();
}
use of org.apache.jena.sdb.SDBException in project jena by apache.
the class TupleLoaderBase method massDelete.
private void massDelete(Node... row) {
flush();
boolean handleT = startTransaction(connection());
try {
if (row.length == 0)
deleteAllTuples.execute();
else {
PreparedNode pNode = new PreparedNode(row[0]);
deleteAllTuples.setLong(1, pNode.hash);
deleteAllTuples.addBatch();
deleteAllTuples.executeBatch();
deleteAllTuples.clearBatch();
}
endTransaction(connection(), handleT);
} catch (SQLException e) {
if (handleT) {
try {
connection().getSqlConnection().rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
throw new SDBException("Exception mass deleting", e);
}
}
use of org.apache.jena.sdb.SDBException in project jena by apache.
the class TransactionHandlerSDB method begin.
// Simplistic
@Override
public synchronized void begin() {
if (inTransaction) {
log.warn("beginTransaction: Already in a transaction");
throw new SDBException("Already in transaction");
}
try {
sqlConnection.setAutoCommit(false);
inTransaction = true;
} catch (SQLException ex) {
new SDBExceptionSQL("begin", ex);
}
}
use of org.apache.jena.sdb.SDBException in project jena by apache.
the class FormatterSimpleDerby method reformatDataWorker.
private void reformatDataWorker() {
try {
dropTable("Triples");
connection().exec(sqlStr("CREATE TABLE Triples", "(", " s " + colDecl + " ,", " p " + colDecl + " ,", " o " + colDecl + " ,", " PRIMARY KEY (s,p,o)", ")"));
} catch (SQLException ex) {
throw new SDBException("SQLException resetting table 'Triples'", ex);
}
}
Aggregations