org.apache.lucene.store.jdbc.support
Class JdbcTemplate

java.lang.Object
  extended by org.apache.lucene.store.jdbc.support.JdbcTemplate

public class JdbcTemplate
extends Object

Helper class that isused to encapsulate resource and transaction handling related to DataSource, Statement, and ResultSet. DataSourceUtils is used to open/cose relevant resources.

Author:
kimchy
See Also:
DataSourceUtils

Nested Class Summary
static interface JdbcTemplate.CallableStatementCallback
          A callback used to work with CallableStatement.
static interface JdbcTemplate.ExecuteSelectCallback
          A callback used to retrieve data from a ResultSet.
static interface JdbcTemplate.PrepateStatementAwareCallback
          A callback interface used to initialize a Jdbc PreparedStatement.
 
Constructor Summary
JdbcTemplate(DataSource dataSource, JdbcDirectorySettings settings)
          Creates a new JdbcTemplate.
 
Method Summary
 int[] executeBatch(String[] sqls)
          A template method to execute a set of sqls in batch.
 int[] executeBatch(String sql, JdbcTemplate.PrepateStatementAwareCallback callback)
          A template method to execute that can execute the same sql several times using different values set to it (in the fillPrepareStatement) callback).
 Object executeCallable(String sql, JdbcTemplate.CallableStatementCallback callback)
          A template method to execute a simple sql callable statement.
 Object executeSelect(String sql, JdbcTemplate.ExecuteSelectCallback callback)
          A template method to execute a simple sql select statement.
 void executeUpdate(String sql)
          A template method to execute a simpel sql update (with no need for data initialization).
 void executeUpdate(String sql, JdbcTemplate.PrepateStatementAwareCallback callback)
          A template method to execute a simple sql update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcTemplate

public JdbcTemplate(DataSource dataSource,
                    JdbcDirectorySettings settings)
Creates a new JdbcTemplate.

Method Detail

executeSelect

public Object executeSelect(String sql,
                            JdbcTemplate.ExecuteSelectCallback callback)
                     throws JdbcStoreException
A template method to execute a simple sql select statement. The jdbc Connection, PreparedStatement, and ResultSet are managed by the template.

Throws:
JdbcStoreException

executeCallable

public Object executeCallable(String sql,
                              JdbcTemplate.CallableStatementCallback callback)
                       throws JdbcStoreException
A template method to execute a simple sql callable statement. The jdbc Connection, and CallableStatement are managed by the template.

Throws:
JdbcStoreException

executeUpdate

public void executeUpdate(String sql,
                          JdbcTemplate.PrepateStatementAwareCallback callback)
                   throws JdbcStoreException
A template method to execute a simple sql update. The jdbc Connection, and PreparedStatement are managed by the template. A PreparedStatement can be used to set values to the given sql.

Throws:
JdbcStoreException

executeUpdate

public void executeUpdate(String sql)
                   throws JdbcStoreException
A template method to execute a simpel sql update (with no need for data initialization).

Throws:
JdbcStoreException

executeBatch

public int[] executeBatch(String[] sqls)
                   throws JdbcStoreException
A template method to execute a set of sqls in batch.

Throws:
JdbcStoreException

executeBatch

public int[] executeBatch(String sql,
                          JdbcTemplate.PrepateStatementAwareCallback callback)
                   throws JdbcStoreException
A template method to execute that can execute the same sql several times using different values set to it (in the fillPrepareStatement) callback).

Throws:
JdbcStoreException


Copyright (c) 2004-2009 The Compass Project.