SesameConnection implements Connection { @Override public PreparedStatement prepareStatement(String sparql) { ensureOpen(); Objects.requireNonNull(sparql); if (sparql.isEmpty()) { throw new IllegalArgumentException("The value for prepared statement cannot be empty."); } return new SesamePreparedStatement(adapter.getQueryExecutor(), sparql); } SesameConnection(SesameAdapter adapter); void setProperties(Properties properties); @Override void close(); @Override boolean isOpen(); @Override void commit(); @Override void rollback(); @Override void setAutoCommit(boolean autoCommit); @Override boolean isAutoCommit(); @Override Statement createStatement(); @Override PreparedStatement prepareStatement(String sparql); @Override boolean isConsistent(URI context); @Override List<URI> getContexts(); @Override URI generateIdentifier(URI classUri); @Override boolean contains(Axiom<?> axiom, URI context); @Override Collection<Axiom<?>> find(AxiomDescriptor descriptor); @Override void persist(AxiomValueDescriptor descriptor); @Override void update(AxiomValueDescriptor descriptor); @Override void remove(AxiomDescriptor descriptor); @Override Lists lists(); @Override Types types(); @Override Properties properties(); @Override T unwrap(Class<T> cls);  }
@Test public void testPrepareStatement() throws Exception { final PreparedStatement res = connection .prepareStatement("SELECT ?x ? y ?z WHERE { ?x ?y ?z . }"); assertNotNull(res); assertTrue(res instanceof SesamePreparedStatement); }
@Test(expected = IllegalArgumentException.class) public void testPrepareStatementEmpty() throws Exception { final PreparedStatement res = connection.prepareStatement(""); fail("This line should not have been reached."); assert res == null; }