|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.flyway.core.util.jdbc.JdbcTemplate
public abstract class JdbcTemplate
Collection of utility methods for querying the DB. Inspired by Spring's JdbcTemplate.
| Constructor Summary | |
|---|---|
JdbcTemplate(java.sql.Connection connection)
Creates a new JdbcTemplate. |
|
| Method Summary | ||
|---|---|---|
void |
execute(java.lang.String sql,
java.lang.Object... params)
Executes this sql statement using a PreparedStatement. |
|
void |
executeStatement(java.lang.String sql)
Executes this sql statement using an ordinary Statement. |
|
java.sql.Connection |
getConnection()
|
|
java.sql.DatabaseMetaData |
getMetaData()
Retrieves the database metadata for the connection associated with this JdbcTemplate. |
|
boolean |
hasTables(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String... tableTypes)
Checks whether the database contains tables matching these criteria. |
|
|
query(java.lang.String query,
RowMapper<T> rowMapper)
Executes this query and map the results using this row mapper. |
|
int |
queryForInt(java.lang.String query,
java.lang.String... params)
Executes this query with these parameters against this connection. |
|
java.util.List<java.util.Map<java.lang.String,java.lang.String>> |
queryForList(java.lang.String query,
java.lang.String... params)
Executes this query with these parameters against this connection. |
|
java.lang.String |
queryForString(java.lang.String query,
java.lang.String... params)
Executes this query with these parameters against this connection. |
|
java.util.List<java.lang.String> |
queryForStringList(java.lang.String query,
java.lang.String... params)
Executes this query with these parameters against this connection. |
|
protected abstract void |
setNull(java.sql.PreparedStatement preparedStatement,
int parameterIndex)
Sets the value of the parameter with this index to null in this PreparedStatement. |
|
void |
update(java.lang.String sql,
java.lang.Object... params)
Executes this update sql statement. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JdbcTemplate(java.sql.Connection connection)
connection - The DB connection to use.| Method Detail |
|---|
public java.sql.Connection getConnection()
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> queryForList(java.lang.String query,
java.lang.String... params)
throws java.sql.SQLException
query - The query to execute.params - The query parameters.
java.sql.SQLException - when the query execution failed.
public java.util.List<java.lang.String> queryForStringList(java.lang.String query,
java.lang.String... params)
throws java.sql.SQLException
query - The query to execute.params - The query parameters.
java.sql.SQLException - when the query execution failed.
public int queryForInt(java.lang.String query,
java.lang.String... params)
throws java.sql.SQLException
query - The query to execute.params - The query parameters.
java.sql.SQLException - when the query execution failed.
public java.lang.String queryForString(java.lang.String query,
java.lang.String... params)
throws java.sql.SQLException
query - The query to execute.params - The query parameters.
java.sql.SQLException - when the query execution failed.
public java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
java.sql.SQLException - when the database metadata could not be retrieved.
public boolean hasTables(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String... tableTypes)
throws java.sql.SQLException
catalog - The catalog where the table resides. (optional)schema - The schema where the table resides. (optional)table - The name of the table. (optional)tableTypes - The types of table to look for (ex.: TABLE). (optional)
true if matching tables have been found, false if not.
java.sql.SQLException - when the check failed.
public void execute(java.lang.String sql,
java.lang.Object... params)
throws java.sql.SQLException
sql - The statement to execute.params - The statement parameters.
java.sql.SQLException - when the execution failed.
public void executeStatement(java.lang.String sql)
throws java.sql.SQLException
sql - The statement to execute.
java.sql.SQLException - when the execution failed.
public void update(java.lang.String sql,
java.lang.Object... params)
throws java.sql.SQLException
sql - The statement to execute.params - The statement parameters.
java.sql.SQLException - when the execution failed.
protected abstract void setNull(java.sql.PreparedStatement preparedStatement,
int parameterIndex)
throws java.sql.SQLException
null in this PreparedStatement.
preparedStatement - The prepared statement whose parameter to set.parameterIndex - The index of the parameter to set.
java.sql.SQLException - when the value could not be set.
public <T> java.util.List<T> query(java.lang.String query,
RowMapper<T> rowMapper)
throws java.sql.SQLException
T - The type of the result objects.query - The query to execute.rowMapper - The row mapper to use.
java.sql.SQLException - when the query failed to execute.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||