@Test void execute() throws SQLException { String sql = RandomStringUtils.randomAlphabetic(30); when(connection.createStatement()).thenReturn(statement); when(statement.execute(sql)).thenReturn(true); boolean result = ConnectionUtil.execute(connection, sql); verify(connection).createStatement(); verify(statement).execute(sql); verify(statement).close(); verifyNoMoreInteractions(connection, statement); assertThat(result, is(true)); }
public static boolean execute(Connection connection, String sql) { try (Statement statement = connection.createStatement()) { LOG.debug(sql); return statement.execute(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } }
ConnectionUtil extends UtilityClass { public static boolean execute(Connection connection, String sql) { try (Statement statement = connection.createStatement()) { LOG.debug(sql); return statement.execute(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } } }
ConnectionUtil extends UtilityClass { public static boolean execute(Connection connection, String sql) { try (Statement statement = connection.createStatement()) { LOG.debug(sql); return statement.execute(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  }
ConnectionUtil extends UtilityClass { public static boolean execute(Connection connection, String sql) { try (Statement statement = connection.createStatement()) { LOG.debug(sql); return statement.execute(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static DatabaseMetaData getMetaData(Connection connection); static void commit(Connection connection); static void rollback(Connection connection); static boolean execute(Connection connection, String sql); static PreparedStatement prepare(Connection connection, String sql); }
ConnectionUtil extends UtilityClass { public static boolean execute(Connection connection, String sql) { try (Statement statement = connection.createStatement()) { LOG.debug(sql); return statement.execute(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  static DatabaseMetaData getMetaData(Connection connection); static void commit(Connection connection); static void rollback(Connection connection); static boolean execute(Connection connection, String sql); static PreparedStatement prepare(Connection connection, String sql);  }