Java Code Examples for org.springframework.jdbc.core.SqlProvider

The following examples show how to use org.springframework.jdbc.core.SqlProvider. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: buffer-slayer   Source File: BatchJdbcTemplate.java    License: Apache License 2.0 5 votes vote down vote up
public MessageFuture<Integer> update(PreparedStatementCreator psc) throws DataAccessException {
  if (psc instanceof SqlProvider) {
    SqlProvider sqlProvider = (SqlProvider) psc;
    String sql = sqlProvider.getSql();

    Builder builder = Sql.builder().sql(sql);
    if (psc instanceof PreparedStatementSetter) {
      PreparedStatementSetter pss = (PreparedStatementSetter) psc;
      builder.preparedStatementSetter(pss);
    }
    return reporter.report(builder.build());
  }
  throw new UnsupportedOperationException("Must be instance of SqlProvider");
}
 
Example 2
Source Project: jdal   Source File: DbAdminManagerSupport.java    License: Apache License 2.0 5 votes vote down vote up
public boolean execute(final String sql) throws DataAccessException {
	if (log.isDebugEnabled()) {
		log.debug("Executing SQL statement [" + sql + "]");
	}
	class ExecuteStatementCallback implements StatementCallback<Boolean>, SqlProvider {
		public Boolean doInStatement(Statement stmt) throws SQLException {
			return stmt.execute(sql);
		}
		public String getSql() {
			return sql;
		}
	}
	
	return  template.execute(new ExecuteStatementCallback());
}