use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class FormatterSimpleMySQL method dropIndexes.
// Need this if we need to limit the index lengths
// @Override
// public void addIndexes()
// {
// try {
// connection().exec("CREATE INDEX SubjObj ON "+TableTriples.tableName+" (s(100),o(100))") ;
// connection().exec("CREATE INDEX ObjPred ON "+TableTriples.tableName+" (o(100),p(100))") ;
// connection().exec("CREATE INDEX Pred ON "+TableTriples.tableName+" (p(100))") ;
// } catch (SQLException ex)
// {
// throw new SDBException("SQLException indexing table 'Triples'",ex) ;
// }
// }
@Override
public void dropIndexes() {
try {
connection().exec("DROP INDEX PredObj ON " + TableDescSPO.name());
connection().exec("DROP INDEX ObjSubj ON " + TableDescSPO.name());
} catch (SQLException ex) {
throw new SDBExceptionSQL("SQLException dropping indexes for table 'Triples'", ex);
}
}
use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class SDB_QC method exec.
// ---- Execute an OpSQL.
public static QueryIterator exec(OpSQL opSQL, SDBRequest request, Binding binding, ExecutionContext execCxt) {
String sqlStmtStr = toSqlString(opSQL, request);
if (PrintSQL)
System.out.println(sqlStmtStr);
String str = null;
if (execCxt != null)
str = execCxt.getContext().getAsString(SDB.jdbcFetchSize);
int fetchSize = SDBConstants.jdbcFetchSizeOff;
if (str != null)
try {
fetchSize = Integer.parseInt(str);
} catch (NumberFormatException ex) {
log.warn("Bad number for fetch size: " + str);
}
try {
ResultSetJDBC jdbcResultSet = request.getStore().getConnection().execQuery(sqlStmtStr, fetchSize);
try {
// And check this is called once per SQL.
if (opSQL.getBridge() == null)
log.error("Null bridge");
return opSQL.getBridge().assembleResults(jdbcResultSet, binding, execCxt);
} finally {
// ResultSet closed inside assembleResults or by the iterator returned.
jdbcResultSet = null;
}
} catch (SQLException ex) {
throw new SDBExceptionSQL("SQLException in executing SQL statement", ex);
}
}
use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class FmtLayout2HashPGSQL method formatTableQuads.
@Override
protected void formatTableQuads() {
String tname = TableDescQuads.name();
dropTable(tname);
try {
connection().exec(sqlStr("CREATE TABLE " + tname + " (", " g BIGINT NOT NULL,", " s BIGINT NOT NULL,", " p BIGINT NOT NULL,", " o BIGINT NOT NULL,", " PRIMARY KEY (g, s, p, o)", ")"));
} catch (SQLException ex) {
throw new SDBExceptionSQL("SQLException formatting table '" + TableDescTriples.name() + "'", ex);
}
}
use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class StoreBaseHash method getSize.
public static long getSize(SDBConnection connection, TableDescQuads tableDescQuads, Node node) {
String lex = NodeLayout2.nodeToLex(node);
int typeId = NodeLayout2.nodeToType(node);
String lang = "";
String datatype = "";
if (node.isLiteral()) {
lang = node.getLiteralLanguage();
datatype = node.getLiteralDatatypeURI();
if (NodeUtils.isSimpleString(node) || NodeUtils.isLangString(node))
datatype = "";
}
ResultSetJDBC rsx = null;
long hash = NodeLayout2.hash(lex, lang, datatype, typeId);
try {
rsx = connection.exec("SELECT COUNT(*) FROM " + tableDescQuads.getTableName() + " WHERE g = " + hash);
ResultSet res = rsx.get();
res.next();
long result = res.getLong(1);
return result;
} catch (SQLException e) {
throw new SDBExceptionSQL("Failed to get graph size", e);
} finally {
RS.close(rsx);
}
}
use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class PrefixMappingSDB method readFromPrefixMap.
private String readFromPrefixMap(String prefix) {
ResultSetJDBC rsx = null;
try {
String sqlStmt = sqlStr("SELECT uri FROM " + prefixTableName, " WHERE prefix = " + quoteStr(prefix));
rsx = connection.execQuery(sqlStmt);
ResultSet rs = rsx.get();
String uri = null;
while (rs.next()) {
String v = rs.getString("uri");
uri = v;
if (rs.next())
log.warn("Multiple prefix mappings for '" + prefix + "'");
break;
}
return uri;
} catch (SQLException ex) {
throw new SDBExceptionSQL(format("Failed to read prefix (%s)", prefix), ex);
} finally {
RS.close(rsx);
}
}
Aggregations