Fork me on GitHub
#sql
<
2018-02-16
>
Drew Verlee12:02:00

@seancorfield Sorry i wasn’t being clear, i’m taking about boiler plate in java: We have this code everywhere. its not a huge deal but when you pile it on top of all the other things we can’t compose or dry up it adds up fast:

Type fun(Some param) {

    final String sql = "some sql stmt";

    try (Connection conn = dataSource.getConnection();
        PreparedStatement stmt = conn.prepareStatement(sql)) {
      stmt.setSomeType(n, value)
      stmt.setSomeType(n, value)
      stmt.setSomeType(n, value)

      try (ResultSet resultSet = stmt.executeQuery()) {
        if (resultSet.next()) {
          return resultSet.getInt("number_of_children_with_that_name");
        }
      }
    } catch (SQLException e) {
      throw new DataAccessException(
          "some error msg", e);
    }
  }

seancorfield16:02:38

Haha... yeah, that's like the internals of clojure.java.jdbc only worse... I'm surprised your team hasn't already wrapped that in some sort of abstraction...

Drew Verlee18:02:48

Our CTO put together something in like 3 hours that were supposed to be using now. I’m worried its going to have lots of holes in it, but i really have no idea. I was hoping to jump on to JDBI as its trying to do the same thing as what he put together. Apprently they tried that 3 years ago and thought it wasn’t helping.

seancorfield18:02:24

It's been years since I've used Java itself in anger and pretty much every time I have to read through Java library source code or examples, I weep over the incidental complexity. It reminds me every time why I moved on to Groovy (then Scala, then Clojure).

seancorfield18:02:57

And the irony is that I moved to Java from C++ and initially loved the cleanliness and simplicity that Java seemed to have...