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);
}
}
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);
}
}
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);
}
}
Aggregations