Search in sources :

Example 26 with SDBException

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;
    }
}
Also used : TupleLoader(org.apache.jena.sdb.store.TupleLoader) SDBException(org.apache.jena.sdb.SDBException) SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Example 27 with SDBException

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();
}
Also used : SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Example 28 with SDBException

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);
    }
}
Also used : SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Example 29 with SDBException

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);
    }
}
Also used : SDBExceptionSQL(org.apache.jena.sdb.sql.SDBExceptionSQL) SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Example 30 with SDBException

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);
    }
}
Also used : SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Aggregations

SDBException (org.apache.jena.sdb.SDBException)38 SQLException (java.sql.SQLException)30 Resource (org.apache.jena.rdf.model.Resource)2 ActionMatchString (org.apache.jena.sdb.exprmatch.ActionMatchString)2 ActionMatchVar (org.apache.jena.sdb.exprmatch.ActionMatchVar)2 MapResult (org.apache.jena.sdb.exprmatch.MapResult)2 Var (org.apache.jena.sparql.core.Var)2 ResultSet (java.sql.ResultSet)1 TerminationException (jena.cmd.TerminationException)1 StoreDesc (org.apache.jena.sdb.StoreDesc)1 SDBRequest (org.apache.jena.sdb.core.SDBRequest)1 ResultSetJDBC (org.apache.jena.sdb.sql.ResultSetJDBC)1 SDBConnectionDesc (org.apache.jena.sdb.sql.SDBConnectionDesc)1 SDBExceptionSQL (org.apache.jena.sdb.sql.SDBExceptionSQL)1 Feature (org.apache.jena.sdb.store.Feature)1 FeatureSet (org.apache.jena.sdb.store.FeatureSet)1 TupleLoader (org.apache.jena.sdb.store.TupleLoader)1 NotFoundException (org.apache.jena.shared.NotFoundException)1 Op (org.apache.jena.sparql.algebra.Op)1 TransformFilterEquality (org.apache.jena.sparql.algebra.optimize.TransformFilterEquality)1