Search in sources :

Example 31 with SDBExceptionSQL

use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.

the class PrefixMappingSDB method readPrefixMapping.

// Super class implementation loops and calls setNsPrefix calls set() for each entry.
//@Override
//public PrefixMapping setNsPrefixes(PrefixMapping arg0)
// Super class implementation will suffice.
// It (creates a map copy and) loops on each entry.
//@Override
//public PrefixMapping setNsPrefixes(Map arg0)
// -------- Worker implementations
private void readPrefixMapping() {
    ResultSetJDBC rsx = null;
    try {
        String sqlStmt = "SELECT prefix, uri FROM " + prefixTableName;
        rsx = connection.execSilent(sqlStmt);
        if (rsx == null || rsx.get() == null)
            return;
        ResultSet rs = rsx.get();
        while (rs.next()) {
            String p = rs.getString("prefix");
            p = decode(p);
            String v = rs.getString("uri");
            // Load in-memory copy.
            super.set(p, v);
        }
    } catch (SQLException ex) {
        throw new SDBExceptionSQL("Failed to get prefixes", ex);
    } finally {
        RS.close(rsx);
    }
}
Also used : SDBExceptionSQL(org.apache.jena.sdb.sql.SDBExceptionSQL) SQLException(java.sql.SQLException) ResultSetJDBC(org.apache.jena.sdb.sql.ResultSetJDBC) ResultSet(java.sql.ResultSet)

Example 32 with SDBExceptionSQL

use of org.apache.jena.sdb.sql.SDBExceptionSQL 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 33 with SDBExceptionSQL

use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.

the class TransactionHandlerSDB method abort.

@Override
public synchronized void abort() {
    if (!inTransaction) {
        log.warn("abort: Not in a transaction");
        return;
    }
    try {
        sqlConnection.rollback();
        sqlConnection.setAutoCommit(true);
        inTransaction = false;
    } catch (SQLException ex) {
        new SDBExceptionSQL("abort", ex);
    }
}
Also used : SDBExceptionSQL(org.apache.jena.sdb.sql.SDBExceptionSQL) SQLException(java.sql.SQLException)

Example 34 with SDBExceptionSQL

use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.

the class FmtLayout2HashH2 method formatTablePrefixes.

@Override
protected void formatTablePrefixes() {
    String tname = TablePrefixes.name();
    dropTable(tname);
    try {
        connection().exec(sqlStr("CREATE TABLE " + tname + " (", "    prefix VARCHAR(" + TablePrefixes.prefixColWidth + ") NOT NULL ,", "    uri VARCHAR(" + TablePrefixes.uriColWidth + ") NOT NULL ,", "    CONSTRAINT " + tname + "_PK PRIMARY KEY  (prefix)", ")"));
    } catch (SQLException ex) {
        throw new SDBExceptionSQL("SQLException resetting table '" + TablePrefixes.name() + "'", ex);
    }
}
Also used : SDBExceptionSQL(org.apache.jena.sdb.sql.SDBExceptionSQL) SQLException(java.sql.SQLException)

Example 35 with SDBExceptionSQL

use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.

the class FmtLayout2HashH2 method formatTableTriples.

@Override
protected void formatTableTriples() {
    String tname = TableDescTriples.name();
    dropTable(tname);
    try {
        connection().exec(sqlStr("CREATE TABLE " + tname + " (", "    s BIGINT NOT NULL,", "    p BIGINT NOT NULL,", "    o BIGINT NOT NULL,", "    PRIMARY KEY (s, p, o)", ")"));
    } catch (SQLException ex) {
        throw new SDBExceptionSQL("SQLException formatting table '" + TableDescTriples.name() + "'", ex);
    }
}
Also used : SDBExceptionSQL(org.apache.jena.sdb.sql.SDBExceptionSQL) SQLException(java.sql.SQLException)

Aggregations

SQLException (java.sql.SQLException)47 SDBExceptionSQL (org.apache.jena.sdb.sql.SDBExceptionSQL)47 ResultSetJDBC (org.apache.jena.sdb.sql.ResultSetJDBC)8 ResultSet (java.sql.ResultSet)4 ArrayList (java.util.ArrayList)1 SDBException (org.apache.jena.sdb.SDBException)1 SDBRequest (org.apache.jena.sdb.core.SDBRequest)1 TableDescQuads (org.apache.jena.sdb.layout2.TableDescQuads)1 TableDescTriples (org.apache.jena.sdb.layout2.TableDescTriples)1 ExecutionContext (org.apache.jena.sparql.engine.ExecutionContext)1 Context (org.apache.jena.sparql.util.Context)1