Search in sources :

Example 21 with SDBException

use of org.apache.jena.sdb.SDBException in project jena by apache.

the class LoaderTuplesNodes method updateOneTuple.

// Queue up a triple, committing if we have enough chunks
private void updateOneTuple(TupleChange tuple) {
    if (currentLoader == null || !currentLoader.getTableDesc().getTableName().equals(tuple.table.getTableName())) {
        // mode is changing, so commit
        commitTuples();
        currentLoader = tupleLoaders.get(tuple.table.getTableName());
        if (currentLoader == null) {
            // make a new loader
            try {
                currentLoader = tupleLoaderClass.getConstructor(SDBConnection.class, TableDesc.class, Integer.TYPE).newInstance(connection(), tuple.table, chunkSize);
            } catch (Exception e) {
                throw new SDBException("Problem making new tupleloader", e);
            }
            currentLoader.start();
            tupleLoaders.put(tuple.table.getTableName(), currentLoader);
        }
    }
    if (tuple.toAdd)
        currentLoader.load(tuple.tuple);
    else
        currentLoader.unload(tuple.tuple);
}
Also used : SDBException(org.apache.jena.sdb.SDBException) SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Example 22 with SDBException

use of org.apache.jena.sdb.SDBException in project jena by apache.

the class NodeLayout2 method hash.

public static long hash(Node n) {
    // Get the bits and pieces for a value
    String lexForm = null;
    if (n.isURI())
        lexForm = n.getURI();
    else if (n.isLiteral())
        lexForm = n.getLiteralLexicalForm();
    else if (n.isBlank())
        lexForm = n.getBlankNodeLabel();
    else
        throw new SDBException("Attempt to hash a variable");
    String datatypeStr = "";
    if (n.isLiteral()) {
        datatypeStr = n.getLiteralDatatypeURI();
        if (NodeUtils.isSimpleString(n) || NodeUtils.isLangString(n))
            datatypeStr = null;
    }
    String langStr = "";
    if (n.isLiteral())
        langStr = n.getLiteralLanguage();
    ValueType vType = ValueType.lookup(n);
    return hash(lexForm, langStr, datatypeStr, vType.getTypeId());
}
Also used : SDBException(org.apache.jena.sdb.SDBException)

Example 23 with SDBException

use of org.apache.jena.sdb.SDBException in project jena by apache.

the class QueryEngineSDB method init.

//    @Override
//    protected Op modifyOp(Op op)
//    { 
//        return op ;
//    }
private void init(DatasetGraphSDB dsg, Query query, Binding initialBinding, Context context) {
    if (context == null)
        context = ARQ.getContext().copy();
    // See "DynamicDatasets" -- this could be enabled.
    if (query != null) {
        if (query.hasDatasetDescription())
            throw new SDBException("Queries with dataset descriptions (FROM/FROM NAMED) not supported");
    }
    if (context.isDefined(ARQConstants.sysDatasetDescription))
        throw new SDBException("Queries with dataset descriptions set in the context not supported");
    this.store = dsg.getStore();
    this.request = new SDBRequest(store, query, context);
    this.originalOp = getOp();
    // Enable transformations : use own choice of transformations.
    // e.g. don't place filters
    // Op op = Algebra.optimize(originalOp, context) ;
    Op op = originalOp;
    // Do property functions.
    op = Transformer.transform(new TransformPropertyFunction(context), op);
    op = Transformer.transform(new TransformFilterEquality(), op);
    // Quad it now so it can be passed to Compile.compile
    op = Algebra.toQuadForm(op);
    // Compile to SQL / extract parts to execute as SQL.
    op = SDBCompile.compile(store, op, initialBinding, context, request);
    setOp(op);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) TransformFilterEquality(org.apache.jena.sparql.algebra.optimize.TransformFilterEquality) SDBException(org.apache.jena.sdb.SDBException) SDBRequest(org.apache.jena.sdb.core.SDBRequest) TransformPropertyFunction(org.apache.jena.sparql.algebra.optimize.TransformPropertyFunction)

Example 24 with SDBException

use of org.apache.jena.sdb.SDBException in project jena by apache.

the class FormatterSimpleSQLServer method reformatPrefixesWorker.

private void reformatPrefixesWorker(boolean loadPrefixes) {
    try {
        dropTable("Prefixes");
        connection().exec(sqlStr("CREATE TABLE Prefixes (", "    prefix NVARCHAR(" + UriWidth + ") NOT NULL ,", "    uri    NVARCHAR(" + UriWidth + ") NOT NULL ,", "  PRIMARY KEY(prefix)", ")"));
        if (loadPrefixes) {
            connection().execUpdate("INSERT INTO Prefixes VALUES ('x',       'http://example/')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('ex',      'http://example.org/')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('rdf',     'http://www.w3.org/1999/02/22-rdf-syntax-ns#')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('rdfs',    'http://www.w3.org/2000/01/rdf-schema#')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('xsd',     'http://www.w3.org/2001/XMLSchema#')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('owl' ,    'http://www.w3.org/2002/07/owl#')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('foaf',    'http://xmlns.com/foaf/0.1/')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('dc',      'http://purl.org/dc/elements/1.1/')");
            connection().execUpdate("INSERT INTO Prefixes VALUES ('dcterms', 'http://purl.org/dc/terms/')");
        }
    } catch (SQLException ex) {
        log.warn("Exception resetting table 'Prefixes'");
        throw new SDBException("SQLException resetting table 'Prefixes'", ex);
    }
}
Also used : SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Example 25 with SDBException

use of org.apache.jena.sdb.SDBException in project jena by apache.

the class FormatterSimpleSQLServer method addIndexes.

@Override
public void addIndexes() {
    try {
        connection().exec("CREATE INDEX PredObj ON " + TableDescSPO.name() + " (p,o)");
        connection().exec("CREATE INDEX ObjSubj ON " + TableDescSPO.name() + " (o,s)");
    } catch (SQLException ex) {
        throw new SDBException("SQLException indexing 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