Spring JDBC Development — Using Spring

Luxoft Training
1 min readJun 19, 2019

--

In our first article we started talking about how to write DAOs with the help of Spring. Let’s continue.

Now using Spring JDBC, the code may look like this:

JdbcTemplate is the central class to support work with JDBC from Spring. Using it, we do not have to open/close connections or handle exceptions. The JdbcTemplate is configured into application-context.xml.

With Spring support, the work to be done is much shorter:

  • Specify the statement
  • Do the work for each iteration

As mentioned, JdbcTemplate is the central class in the package org.springframework.jdbc.core, having as purposes to:

  • Execute SQL queries
  • Iterate over results
  • Catch JDBC exceptions

The necessary parameters when executing an SQL query are:

  • The DataSource
  • The RowMapper
  • The SQL query row

Find out more at — http://bit.ly/2MV7TIM

--

--

No responses yet