org.springframework.jdbc.core.SqlProvider Java Examples

The following examples show how to use org.springframework.jdbc.core.SqlProvider. 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 File: BatchJdbcTemplate.java    From buffer-slayer with 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 File: DbAdminManagerSupport.java    From jdal with 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());
}