use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class FmtLayout2IndexPGSQL method formatTableNodes.
@Override
protected void formatTableNodes() {
dropTable(TableDescNodes.name());
try {
connection().exec(sqlStr("CREATE TABLE " + TableDescNodes.name() + " (", " id SERIAL,", " hash BIGINT NOT NULL,", " lex TEXT NOT NULL,", " lang varchar NOT NULL default '',", " datatype varchar(" + TableDescNodes.DatatypeUriLength + ") NOT NULL default '',", " type integer NOT NULL default '0',", " PRIMARY KEY (id)", ")"));
connection().exec("CREATE UNIQUE INDEX Hash ON " + TableDescNodes.name() + " (hash)");
} catch (SQLException ex) {
throw new SDBExceptionSQL("SQLException formatting table '" + TableDescNodes.name() + "'", ex);
}
}
use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class FmtLayout2IndexSAP method formatTableTriples.
@Override
protected void formatTableTriples() {
dropTable(TableDescTriples.name());
try {
connection().exec(sqlStr("CREATE " + storageType.getStorageName() + " TABLE " + TableDescTriples.name() + " (", " s integer NOT NULL,", " p integer NOT NULL,", " o integer NOT NULL", ")"));
connection().exec(sqlStr("ALTER TABLE " + TableDescTriples.name() + " ADD PRIMARY KEY (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 FmtLayout2IndexSAP method formatTableNodes.
@Override
protected void formatTableNodes() {
dropTable(TableDescNodes.name());
try {
connection().exec(sqlStr("CREATE " + storageType.getStorageName() + " TABLE " + TableDescNodes.name() + " (", " id INTEGER NOT NULL,", " hash BIGINT NOT NULL,", " lex nvarchar(5000) NOT NULL,", " lang nvarchar(10) NOT NULL default '',", " datatype nvarchar(" + TableDescNodes.DatatypeUriLength + ") NOT NULL default '',", " type integer NOT NULL default '0'", ")"));
connection().exec(sqlStr("ALTER TABLE " + TableDescNodes.name() + " ADD PRIMARY KEY (id)"));
// Urgh. How do we find out if a sequence exists?
connection().execSilent("DROP SEQUENCE nodeid");
connection().exec(sqlStr("CREATE SEQUENCE nodeid", "START WITH 1", "INCREMENT BY 1", "NO CYCLE"));
connection().exec("CREATE UNIQUE INDEX Hash ON " + TableDescNodes.name() + " (hash)");
} catch (SQLException ex) {
throw new SDBExceptionSQL("SQLException formatting table '" + TableDescNodes.name() + "'", ex);
}
}
use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class TupleTable method getDesc.
private static TableDesc getDesc(Store store, String tableName) {
ResultSetJDBC tableData = null;
List<String> colVars = new ArrayList<String>();
try {
// Need to portable get the column names.
tableData = store.getConnection().execQuery("SELECT * FROM " + tableName);
java.sql.ResultSetMetaData meta = tableData.get().getMetaData();
int N = meta.getColumnCount();
for (int i = 1; i <= N; i++) {
String colName = meta.getColumnName(i);
colVars.add(colName);
}
return new TableDesc(tableName, colVars);
} catch (SQLException ex) {
throw new SDBExceptionSQL(ex);
} finally {
RS.close(tableData);
}
}
use of org.apache.jena.sdb.sql.SDBExceptionSQL in project jena by apache.
the class TupleTable method iterator.
public QueryIterator iterator() {
SDBRequest request = new SDBRequest(store, null);
String tableName = desc.getTableName();
SQLBridge b = store.getSQLBridgeFactory().create(request, sqlTable, vars);
b.build();
try {
String sqlStr = store.getSQLGenerator().generateSQL(request, b.getSqlNode());
//System.out.println(sqlStr) ;
ResultSetJDBC tableData = store.getConnection().execQuery(sqlStr);
ExecutionContext execCxt = new ExecutionContext(new Context(), null, null, null);
return b.assembleResults(tableData, BindingRoot.create(), execCxt);
} catch (SQLException ex) {
throw new SDBExceptionSQL(ex);
}
}
Aggregations