public void startRDF() throws RDFHandlerException {
if (ps == null)
try {
ps = prepareStatement(VirtuosoRepositoryConnection.S_INSERT);
} catch (java.sql.SQLException e) {
throw new RDFHandlerException("Problem PrepareStatement: ", e);
}
}
public void endRDF() throws RDFHandlerException {
try {
if (count > 0) {
ps.executeBatch();
ps.clearBatch();
count = 0;
}
if (ps != null) {
ps.close();
ps = null;
}
}
catch (SQLException e) {
throw new RDFHandlerException("Problem executing query: ", e);
}
}
public void handleNamespace(String prefix, String name) throws RDFHandlerException {
String query = "DB.DBA.XML_SET_NS_DECL(?, ?, 1)";
try {
PreparedStatement psn = prepareStatement(query);
psn.setString(1, prefix);
psn.setString(2, name);
psn.execute();
psn.close();
}
catch (SQLException e) {
throw new RDFHandlerException("Problem executing query: " + query, e);
}
}
public void handleStatement(Statement st) throws RDFHandlerException {
try {
Resource[] hcontexts;
if (st.getContext() != null && useStatementContext) {
hcontexts = new Resource[] {st.getContext()};
} else {
hcontexts = _contexts;
}
for (int i = 0; i < hcontexts.length; i++) {
ps.setString(1, hcontexts[i].stringValue());
bindResource(ps, 2, st.getSubject());
bindURI(ps, 3, st.getPredicate());
bindValue(ps, 4, st.getObject());
ps.addBatch();
count++;
}
if (count > BATCH_SIZE) {
ps.executeBatch();
ps.clearBatch();
count = 0;
}
}
catch(Exception e) {
throw new RDFHandlerException(e);
}
}
};
parser.setRDFHandler(rdfInserter);