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(); }