Search in sources :

Example 36 with SDBException

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

the class FormatterSimpleDB2 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)",
        ") CCSID UNICODE"));
    } catch (SQLException ex) {
        log.warn("Exception resetting table 'Triples'");
        throw new SDBException("SQLException resetting table 'Triples'", ex);
    }
}
Also used : SQLException(java.sql.SQLException) SDBException(org.apache.jena.sdb.SDBException)

Example 37 with SDBException

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

the class FormatterSimpleDB2 method addIndexes.

@Override
public void addIndexes() {
    try {
        connection().exec("CREATE INDEX SubjPred ON " + TableDescSPO.name() + " (s,p)");
        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)

Example 38 with SDBException

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

the class TupleLoaderOneIndex method getIndex.

/// ----------
private static int getIndex(SDBConnection conn, Node node, boolean create) throws SQLException {
    long hash = NodeLayout2.hash(node);
    String lex = NodeLayout2.nodeToLex(node);
    String hashStr = Long.toString(hash);
    String sqlStmt = "SELECT id FROM Nodes WHERE hash = " + hashStr;
    ResultSetJDBC rsx = null;
    try {
        rsx = conn.execQuery(sqlStmt);
        ResultSet rs = rsx.get();
        if (!rs.next()) {
            if (!create)
                throw new SDBException("No such node in table: " + node);
            insertNode(conn, lex, node);
            // And get it again to find the auto-allocate ID.
            return getIndex(conn, node, false);
        }
        int id = rs.getInt("id");
        if (rs.next())
            log.warn("More than one hit for : " + sqlStmt + " (ignored)");
        return id;
    } catch (SQLException ex) {
        log.warn("SQLException: " + ex.getMessage());
        throw ex;
    } finally {
        RS.close(rsx);
    }
}
Also used : SQLException(java.sql.SQLException) ResultSetJDBC(org.apache.jena.sdb.sql.ResultSetJDBC) SDBException(org.apache.jena.sdb.SDBException) ResultSet(java.sql.ResultSet)

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