@Test void prepareThatThrows() throws SQLException { String sql = RandomStringUtils.randomAlphabetic(30); when(connection.prepareStatement(sql)).thenThrow(new SQLException("Syntax error")); calling(() -> ConnectionUtil.prepare(connection, sql)) .shouldThrow(RuntimeSqlException.class) .withCause(SQLException.class) .withMessage(is("Syntax error")); verify(connection).prepareStatement(sql); }
public static PreparedStatement prepare(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } }
ConnectionUtil extends UtilityClass { public static PreparedStatement prepare(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } } }
ConnectionUtil extends UtilityClass { public static PreparedStatement prepare(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeSqlException(e); } }  }
ConnectionUtil extends UtilityClass { public static PreparedStatement prepare(Connection connection, String sql) { try { return connection.prepareStatement(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 PreparedStatement prepare(Connection connection, String sql) { try { return connection.prepareStatement(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);  }