O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Problems with core JDBC

The following illustrates the problems that we have to face when we work with the core JDBC API:

    String query = "SELECT COUNT(*) FROM ACCOUNT";        try (Connection conn = dataSource.getConnection();        Statement statement = conn.createStatement();         ResultSet rsltSet = statement.executeQuery(query))         {        if(rsltSet.next()){             int count = rsltSet.getInt(1);            System.out.println("count : " + count);        }      } catch (SQLException e) {        // TODO Auto-generated catch block            e.printStackTrace();      }        }

In the preceding example, I have highlighted some code. Only the code in bold format is important; the rest is plumbing code. So, we have to write that redundant code every time, to perform a database operation.

Let's see some other problems with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required