Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.PreparedStatementSetter


        logger.debug("Adding authority '" + authority + "' to group '" + groupName + "'");
        Assert.hasText(groupName);
        Assert.notNull(authority);

        final int id = findGroupId(groupName);
        getJdbcTemplate().update(insertGroupAuthoritySql, new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                ps.setInt(1, id);
                ps.setString(2, authority.getAuthority());
            }
        });
View Full Code Here


public class ContactDaoSpring extends JdbcDaoSupport implements ContactDao {

    //~ Methods ========================================================================================================

    public void create(final Contact contact) {
        getJdbcTemplate().update("insert into contacts values (?, ?, ?)", new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                ps.setLong(1, contact.getId());
                ps.setString(2, contact.getName());
                ps.setString(3, contact.getEmail());
            }
View Full Code Here

            }
        });
    }

    public void delete(final Long contactId) {
        getJdbcTemplate().update("delete from contacts where id = ?", new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                ps.setLong(1, contactId);
            }
        });
    }
View Full Code Here

            }
        });
    }

    public void update(final Contact contact) {
        getJdbcTemplate().update("update contacts set contact_name = ?, address = ? where id = ?", new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                ps.setString(1, contact.getName());
                ps.setString(2, contact.getEmail());
                ps.setLong(3, contact.getId());
            }
View Full Code Here

        // (including markers to each parent in the hierarchy)
        String sql = computeRepeatingSql("(ACL_OBJECT_IDENTITY.OBJECT_ID_IDENTITY = ? and ACL_CLASS.CLASS = ?)",
                objectIdentities.length);

        jdbcTemplate.query(sql,
            new PreparedStatementSetter() {
                public void setValues(PreparedStatement ps)
                    throws SQLException {
                    for (int i = 0; i < objectIdentities.length; i++) {
                        // Determine prepared statement values for this iteration
                        String javaType = objectIdentities[i].getJavaType().getName();
View Full Code Here

        Assert.notEmpty(findNow, "Items to find now required");

        String sql = computeRepeatingSql("(ACL_OBJECT_IDENTITY.ID = ?)", findNow.size());

        jdbcTemplate.query(sql,
            new PreparedStatementSetter() {
                public void setValues(PreparedStatement ps)
                    throws SQLException {
                    Iterator iter = findNow.iterator();
                    int i = 0;
View Full Code Here

                                    try {
                                        failedDatas.clear(); // 先清理
                                        processedDatas.clear();
                                        interceptor.transactionBegin(context, Arrays.asList(data), dbDialect);
                                        JdbcTemplate template = dbDialect.getJdbcTemplate();
                                        int affect = template.update(data.getSql(), new PreparedStatementSetter() {

                                            public void setValues(PreparedStatement ps) throws SQLException {
                                                doPreparedStatement(ps, dbDialect, lobCreator, data);
                                            }
                                        });
View Full Code Here

  public boolean revokeApprovals(Collection<Approval> approvals) {
    logger.debug(String.format("Revoking approvals: [%s]", approvals));
    boolean success = true;
    for (final Approval approval : approvals) {
      if (handleRevocationsAsExpiry) {
        int refreshed = jdbcTemplate.update(expireApprovalStatement, new PreparedStatementSetter() {
          @Override
          public void setValues(PreparedStatement ps) throws SQLException {
            ps.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
            ps.setString(2, approval.getUserId());
            ps.setString(3, approval.getClientId());
            ps.setString(4, approval.getScope());
          }
        });
        if (refreshed != 1) {
          success = false;
        }
      }
      else {
        int refreshed = jdbcTemplate.update(deleteApprovalStatment, new PreparedStatementSetter() {
          @Override
          public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, approval.getUserId());
            ps.setString(2, approval.getClientId());
            ps.setString(3, approval.getScope());
View Full Code Here

  public boolean purgeExpiredApprovals() {
    logger.debug("Purging expired approvals from database");
    try {
      int deleted = jdbcTemplate.update(deleteApprovalStatment + " where expiresAt <= ?",
          new PreparedStatementSetter() {
            @Override
            public void setValues(PreparedStatement ps) throws SQLException {
              ps.setTimestamp(1, new Timestamp(new Date().getTime()));
            }
          });
View Full Code Here

    return jdbcTemplate.query(findApprovalStatement, rowMapper, userName, clientId);
  }

  private boolean updateApproval(final String sql, final Approval approval) {
    logger.debug(String.format("refreshing approval: [%s]", approval));
    int refreshed = jdbcTemplate.update(sql, new PreparedStatementSetter() {
      @Override
      public void setValues(PreparedStatement ps) throws SQLException {
        ps.setTimestamp(1, new Timestamp(approval.getExpiresAt().getTime()));
        ps.setString(2, (approval.getStatus() == null ? APPROVED : approval.getStatus()).toString());
        ps.setTimestamp(3, new Timestamp(approval.getLastUpdatedAt().getTime()));
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.PreparedStatementSetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.