the most frequently used operations of JdbcTemplate and
NamedParameterJdbcTemplate.</para>
</listitem>
<listitem>
<para><emphasisrole="bold">SimpleJdbcInsert and
SimpleJdbcCall</emphasis> optimize database metadata to limit the
amount of necessary configuration. This approach simplifies coding
so that you only need to provide the name of the table or procedure
and provide a map of parameters matching the column names. <!--Revise preceding to clarify: You *must* use this approach w/ SimpleJdbcTemplate, it is *recommended*, or you *can*?
TR: OK. I removed the sentence since it isn;t entirely accurate. The implementation uses a plain JdbcTemplate internally.-->
and provide a map of parameters matching the column names.
This only works if the database provides adequate metadata. If the
database doesn't provide this metadata, you will have to provide
explicit configuration of the parameters.</para>
@ -201,8 +194,7 @@ TR: OK. I removed the sentence since it isn;t entirely accurate. The implementat
@@ -201,8 +194,7 @@ TR: OK. I removed the sentence since it isn;t entirely accurate. The implementat
contains the <classname>JdbcTemplate</classname> class and its various
callback interfaces, plus a variety of related classes. A subpackage
named <literal>org.springframework.jdbc.core.simple</literal> contains
the <classname>SimpleJdbcTemplate</classname> class and the related
<classname>SimpleJdbcInsert</classname> and
the <classname>SimpleJdbcInsert</classname> and
<classname>SimpleJdbcCall</classname> classes. Another subpackage named
<literal>org.springframework.jdbc.core.namedparam</literal> contains the
<classname>NamedParameterJdbcTemplate</classname> class and the related
@ -434,8 +426,6 @@ private static final class ActorMapper implements RowMapper<Actor> {
@@ -434,8 +426,6 @@ private static final class ActorMapper implements RowMapper<Actor> {
<para>A common practice when using the
<classname>JdbcTemplate</classname> class (and the associated <link
<para>Most JDBC drivers provide improved performance if you batch multiple
calls to the same prepared statement. By grouping updates into batches you
limit the number of round trips to the database. This section covers batch
processing using both the <classname>JdbcTemplate</classname> and the
<classname>SimpleJdbcTemplate</classname>.</para>
limit the number of round trips to the database.</para>
<sectionxml:id="jdbc-batch-classic">
<title>Basic batch operations with the JdbcTemplate</title>
@ -1579,11 +1466,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
@@ -1579,11 +1466,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
you will see examples of multiple ones later.</para>
<programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
private SimpleJdbcInsert insertActor;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.insertActor =
new SimpleJdbcInsert(dataSource).withTableName("t_actor");
}
@ -1618,11 +1505,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
@@ -1618,11 +1505,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
<para><programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
private SimpleJdbcInsert insertActor;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.insertActor =
new SimpleJdbcInsert(dataSource)
.withTableName("t_actor")
@ -1658,11 +1545,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
@@ -1658,11 +1545,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
column names with the <classname>usingColumns</classname> method:</para>
<para><programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
private SimpleJdbcInsert insertActor;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.insertActor =
new SimpleJdbcInsert(dataSource)
.withTableName("t_actor")
@ -1697,11 +1584,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
@@ -1697,11 +1584,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
to extract the parameter values. Here is an example:</para>
<para><programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
private SimpleJdbcInsert insertActor;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.insertActor =
new SimpleJdbcInsert(dataSource)
.withTableName("t_actor")
@ -1721,11 +1608,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
@@ -1721,11 +1608,11 @@ TR: Revised, please review.-->For this example, the initializing method is the
can be chained.</para>
<para><programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
private SimpleJdbcInsert insertActor;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.insertActor =
new SimpleJdbcInsert(dataSource)
.withTableName("t_actor")
@ -1786,11 +1673,11 @@ END;</programlisting>The <code>in_id</code> parameter contains the
@@ -1786,11 +1673,11 @@ END;</programlisting>The <code>in_id</code> parameter contains the
procedure.<!--Indicate what the purpose of this example is (what it does) and identify the name of procedure. Also see next query. TR: Revised, please review.--></para>
<para><programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
private SimpleJdbcCall procReadActor;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
<para><programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
private SimpleJdbcCall funcGetActorName;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.setResultsMapCaseInsensitive(true);
this.funcGetActorName =
@ -2062,11 +1949,9 @@ END;</programlisting>To call this procedure you declare the
@@ -2062,11 +1949,9 @@ END;</programlisting>To call this procedure you declare the
<classname>newInstance</classname> method.</para>
<para><programlistinglanguage="java">public class JdbcActorDao implements ActorDao {
private SimpleJdbcTemplate simpleJdbcTemplate;
private SimpleJdbcCall procReadAllActors;
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);