private SqlQueryResult executeQuery(final Domain domain, final String sql) throws SQLException, Exception { final SqlConnection connection = dataBaseManager.getConnectionProvider().obtainConnection(); try (final SqlPreparedStatement preparedStatement = dataBaseManager.createPreparedStatement(connection, sql, false)) { preparedStatement.init(); return preparedStatement.executeQuery(domain); } finally { connection.commit(); } }
public void createDatas() throws Exception { final SqlConnection connection = dataBaseManager.getConnectionProvider().obtainConnection(); try { execCallableStatement(connection, "insert into movie values (1, 'citizen kane')"); // ----- execCallableStatement(connection, "insert into movie values (2, 'vertigo')"); // ----- // On passe par une requête bindée insert(connection, 3, TITLE_MOVIE_3); } finally { connection.commit(); } }
@Test public void testConnection() throws Exception { final SqlConnection connection = dataBaseManager.getConnectionProvider().obtainConnection(); Assert.assertNotNull(connection); connection.commit(); }
@Override protected void doTearDown() throws Exception { // A chaque fin de test on arrête la base. final SqlConnection connection = dataBaseManager.getConnectionProvider().obtainConnection(); execCallableStatement(connection, "shutdown;"); }
@Override protected void doSetUp() throws Exception { // A chaque test on recrée la table famille final SqlConnection connection = dataBaseManager.getConnectionProvider().obtainConnection(); execCallableStatement(connection, "create table movie(id BIGINT , title varchar(255));"); }