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

The following are top voted examples for showing how to use org.springframework.jdbc.core.PreparedStatementSetter. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: oauth2-shiro   File: OauthJdbcRepository.java   Source Code and License 7 votes vote down vote up
@Override
public int saveAccessToken(final AccessToken accessToken) {
    final String sql = "insert into oauth_access_token(token_id,token_expired_seconds,authentication_id," +
            "username,client_id,token_type,refresh_token_expired_seconds,refresh_token) values (?,?,?,?,?,?,?,?) ";

    return jdbcTemplate.update(sql, new PreparedStatementSetter() {
        @Override
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, accessToken.tokenId());
            ps.setInt(2, accessToken.tokenExpiredSeconds());
            ps.setString(3, accessToken.authenticationId());

            ps.setString(4, accessToken.username());
            ps.setString(5, accessToken.clientId());
            ps.setString(6, accessToken.tokenType());

            ps.setInt(7, accessToken.refreshTokenExpiredSeconds());
            ps.setString(8, accessToken.refreshToken());
        }
    });
}
 
Example 2
Project: helium   File: BasicLookupStrategy.java   Source Code and License 7 votes vote down vote up
/**
 * Locates the primary key IDs specified in "findNow", adding AclImpl instances with StubAclParents to the
 * "acls" Map.
 *
 * @param acls the AclImpls (with StubAclParents)
 * @param findNow Long-based primary keys to retrieve
 * @param sids
 */
private void lookupPrimaryKeys(final Map<Serializable, Acl> acls, final Set<Long> findNow, final List<Sid> sids) {
    Assert.notNull(acls, "ACLs are required");
    Assert.notEmpty(findNow, "Items to find now required");

    String sql = computeRepeatingSql(lookupPrimaryKeysWhereClause, findNow.size());

    Set<Long> parentsToLookup = jdbcTemplate.query(sql,
        new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                int i = 0;

                for (Long toFind : findNow) {
                    i++;
                    ps.setLong(i, toFind);
                }
            }
        }, new ProcessResultSet(acls, sids));

    // Lookup the parents, now that our JdbcTemplate has released the database connection (SEC-547)
    if (parentsToLookup.size() > 0) {
        lookupPrimaryKeys(acls, parentsToLookup, sids);
    }
}
 
Example 3
Project: oauth2-shiro   File: UsersJdbcAuthzRepository.java   Source Code and License 6 votes vote down vote up
@Override
public int saveUsers(final Users users) {
    String sql = " insert into users(guid,create_time, username,password) values (?,?,?,?) ";
    this.jdbcTemplate.update(sql, new PreparedStatementSetter() {
        @Override
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, users.guid());
            ps.setTimestamp(2, new Timestamp(users.createTime().getTime()));
            ps.setString(3, users.username());

            ps.setString(4, users.password());
        }
    });

    return this.jdbcTemplate.queryForObject("select id from users where guid = ?", new Object[]{users.guid()}, Integer.class);
}
 
Example 4
Project: graphium   File: PixelCutsDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void save(String graphName, String version, IPixelCut xInfo) throws GraphNotExistsException {
	Long graphVersionId = getGraphVersionId(graphName, version);
	getJdbcTemplate().update("INSERT INTO " + schema + TABLE_NAME + " (segment_id, graphversion_id, start_cut_right, start_cut_left, end_cut_right, end_cut_left) VALUES (?,?,?,?,?,?)",
		new PreparedStatementSetter() {

			@Override
			public void setValues(PreparedStatement ps) throws SQLException {
				int pos = 1;
				ps.setLong(pos++, xInfo.getSegmentId());
				ps.setLong(pos++, graphVersionId);
				ps.setDouble(pos++, xInfo.getStartCutRight());
				ps.setDouble(pos++, xInfo.getStartCutLeft());
				ps.setDouble(pos++, xInfo.getEndCutRight());
				ps.setDouble(pos++, xInfo.getEndCutLeft());
			}
			
		}
	);
}
 
Example 5
Project: graphium   File: PixelCutsDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void update(String graphName, String version, IPixelCut xInfo) throws GraphNotExistsException {
	Long graphVersionId = getGraphVersionId(graphName, version);
	getJdbcTemplate().update("UPDATE " + schema + TABLE_NAME + " SET start_cut_right=?, start_cut_left=?, end_cut_right=?, end_cut_left=? WHERE segment_id=? AND graphversion_id=?",
		new PreparedStatementSetter() {

			@Override
			public void setValues(PreparedStatement ps) throws SQLException {
				int pos = 1;
				ps.setDouble(pos++, xInfo.getStartCutRight());
				ps.setDouble(pos++, xInfo.getStartCutLeft());
				ps.setDouble(pos++, xInfo.getEndCutRight());
				ps.setDouble(pos++, xInfo.getEndCutLeft());
				ps.setLong(pos++, xInfo.getSegmentId());
				ps.setLong(pos++, graphVersionId);
			}
			
		}
	);
}
 
Example 6
Project: graphium   File: RoadDamageDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void save(String graphName, String version, IRoadDamage xInfo) throws GraphNotExistsException {
	Long graphVersionId = getGraphVersionId(graphName, version);
	getJdbcTemplate().update("INSERT INTO " + schema + TABLE_NAME + " (segment_id, graphversion_id, direction_tow, start_offset, end_offset, type) VALUES (?,?,?,?,?,?)",
		new PreparedStatementSetter() {

			@Override
			public void setValues(PreparedStatement ps) throws SQLException {
				int pos = 1;
				ps.setLong(pos++, xInfo.getSegmentId());
				ps.setLong(pos++, graphVersionId);
				ps.setBoolean(pos++, xInfo.isDirectionTow());
				ps.setDouble(pos++, xInfo.getStartOffset());
				ps.setDouble(pos++, xInfo.getEndOffset());
				ps.setString(pos++, xInfo.getType());
			}
			
		}
	);
}
 
Example 7
Project: graphium   File: RoadDamageDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void update(String graphName, String version, IRoadDamage xInfo) throws GraphNotExistsException {
	Long graphVersionId = getGraphVersionId(graphName, version);
	getJdbcTemplate().update("UPDATE " + schema + TABLE_NAME + " SET start_offset=?, end_offset=?, type=? WHERE segment_id=? AND direction_tow=? AND graphversion_id=?",
		new PreparedStatementSetter() {

			@Override
			public void setValues(PreparedStatement ps) throws SQLException {
				int pos = 1;
				ps.setDouble(pos++, xInfo.getStartOffset());
				ps.setDouble(pos++, xInfo.getEndOffset());
				ps.setString(pos++, xInfo.getType());
				ps.setLong(pos++, xInfo.getSegmentId());
				ps.setBoolean(pos++, xInfo.isDirectionTow());
				ps.setLong(pos++, graphVersionId);
			}
			
		}
	);
}
 
Example 8
Project: oauth2-shiro-redis   File: OauthJdbcRepository.java   Source Code and License 6 votes vote down vote up
@Override
public int saveAccessToken(final AccessToken accessToken) {
    final String sql = "insert into oauth_access_token(token_id,token_expired_seconds,authentication_id," +
            "username,client_id,token_type,refresh_token_expired_seconds,refresh_token) values (?,?,?,?,?,?,?,?) ";

    return jdbcTemplate.update(sql, new PreparedStatementSetter() {
        @Override
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, accessToken.tokenId());
            ps.setInt(2, accessToken.tokenExpiredSeconds());
            ps.setString(3, accessToken.authenticationId());

            ps.setString(4, accessToken.username());
            ps.setString(5, accessToken.clientId());
            ps.setString(6, accessToken.tokenType());

            ps.setInt(7, accessToken.refreshTokenExpiredSeconds());
            ps.setString(8, accessToken.refreshToken());
        }
    });
}
 
Example 9
Project: otter-G   File: DbLoadAction.java   Source Code and License 6 votes vote down vote up
public Object doInTransaction(TransactionStatus status) {
    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);
            }
        });
        interceptor.transactionEnd(context, Arrays.asList(data), dbDialect);
        return affect;
    } finally {
        lobCreator.close();
    }
}
 
Example 10
Project: leopard   File: StatementParameter.java   Source Code and License 6 votes vote down vote up
/**
 * 生成PreparedStatementSetter对象.
 * 
 * @return PreparedStatementSetter
 */
public PreparedStatementSetter getParameters() {
	if (list.size() == 0) {
		return null;
	}
	PreparedStatementSetter param = new PreparedStatementSetter() {
		@Override
		public void setValues(PreparedStatement pstmt) {
			try {
				StatementParameter.this.setValues(pstmt);
			}
			catch (SQLException e) {
				throw new InvalidParamDataAccessException(e);
			}
		}

	};
	return param;
}
 
Example 11
Project: diamond   File: PersistService.java   Source Code and License 6 votes vote down vote up
public void addConfigInfo(final ConfigInfo configInfo) {
    final Timestamp time = TimeUtils.getCurrentTime();

    this.jt.update(
        "insert into config_info (data_id,group_id,content,md5,gmt_create,gmt_modified) values(?,?,?,?,?,?)",
        new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                int index = 1;
                ps.setString(index++, configInfo.getDataId());
                ps.setString(index++, configInfo.getGroup());
                ps.setString(index++, configInfo.getContent());
                ps.setString(index++, configInfo.getMd5());
                ps.setTimestamp(index++, time);
                ps.setTimestamp(index++, time);
            }
        });
}
 
Example 12
Project: diamond   File: PersistService.java   Source Code and License 6 votes vote down vote up
public void updateConfigInfo(final ConfigInfo configInfo) {
    final Timestamp time = TimeUtils.getCurrentTime();

    this.jt.update("update config_info set content=?,md5=?,gmt_modified=? where data_id=? and group_id=?",
        new PreparedStatementSetter() {

            public void setValues(PreparedStatement ps) throws SQLException {
                int index = 1;
                ps.setString(index++, configInfo.getContent());
                ps.setString(index++, configInfo.getMd5());
                ps.setTimestamp(index++, time);
                ps.setString(index++, configInfo.getDataId());
                ps.setString(index++, configInfo.getGroup());
            }
        });
}
 
Example 13
Project: dtsopensource   File: LocalDTSSchedule.java   Source Code and License 6 votes vote down vote up
@Override
public void closeActivity(final String activityId, final Status orignStatus, final Status targetStatus) {
    log.info("--->start to closeActivity:{},turn status from:{} to:{}", activityId, orignStatus, targetStatus);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            jdbcTemplate.update(ActivitySqlConstance.commit_rollback_activity_by_activity_id,
                    new PreparedStatementSetter() {

                        @Override
                        public void setValues(PreparedStatement ps) throws SQLException {
                            ps.setString(1, targetStatus.name());
                            ps.setTimestamp(2, new Timestamp(new Date().getTime()));
                            ps.setString(3, activityId);
                            ps.setString(4, orignStatus.name());
                        }
                    });
        }
    });
}
 
Example 14
Project: spring-oauth-server   File: UserRepositoryJdbc.java   Source Code and License 6 votes vote down vote up
@Override
public void saveUser(final User user) {
    final String sql = " insert into user_(guid,archived,create_time,email,password,username,phone) " +
            " values (?,?,?,?,?,?,?) ";
    this.jdbcTemplate.update(sql, new PreparedStatementSetter() {

        @Override
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, user.guid());
            ps.setBoolean(2, user.archived());

            ps.setTimestamp(3, Timestamp.valueOf(user.createTime()));
            ps.setString(4, user.email());

            ps.setString(5, user.password());
            ps.setString(6, user.username());

            ps.setString(7, user.phone());
        }
    });
}
 
Example 15
Project: spring-oauth-server   File: UserRepositoryJdbc.java   Source Code and License 6 votes vote down vote up
@Override
public void updateUser(final User user) {
    final String sql = " update user_ set username = ?, password = ?, phone = ?,email = ? where guid = ? ";
    this.jdbcTemplate.update(sql, new PreparedStatementSetter() {
        @Override
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, user.username());
            ps.setString(2, user.password());

            ps.setString(3, user.phone());
            ps.setString(4, user.email());

            ps.setString(5, user.guid());
        }
    });
}
 
Example 16
Project: methodstats   File: VisitorDataDao.java   Source Code and License 6 votes vote down vote up
public void addVisitorData(final VisitorData visitorData)
  {
if(visitorData!=null){
	//sysId,erpId,menuPath,visitDate,type,remark			
	jdbcTemplate.update(getInsertSql(),   
               new PreparedStatementSetter() {
           	public void setValues(PreparedStatement ps) throws SQLException {   
                ps.setInt(1, visitorData.getSystemId());	                          
                ps.setString(2, visitorData.getMenuPath());
                ps.setString(3, visitorData.getErpId());  
                ps.setTimestamp(4, new Timestamp(visitorData.getVisitDate().getTime()));   
                ps.setInt(5, Integer.parseInt(sdfdate.format(visitorData.getVisitDate())));
                ps.setInt(6, Integer.parseInt(sdfhour.format(visitorData.getVisitDate())));
                ps.setInt(7, visitorData.getPathType());
            }   
       });			
}		
  }
 
Example 17
Project: diamond-v2.1.1   File: PersistService.java   Source Code and License 6 votes vote down vote up
public void addConfigInfo(final ConfigInfo configInfo, final String content) {
    final Timestamp time = TimeUtils.getCurrentTime();
    this.jt.update(
        "insert into config_info (data_id,group_id,content,md5,gmt_create,gmt_modified) values(?,?,?,?,?,?)",
        new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                int index = 1;
                ps.setString(index++, configInfo.getDataId());
                ps.setString(index++, configInfo.getGroup());
                ps.setString(index++, content);
                ps.setString(index++, configInfo.getMd5());
                ps.setTimestamp(index++, time);
                ps.setTimestamp(index++, time);
            }
        });
}
 
Example 18
Project: diamond-v2.1.1   File: PersistService.java   Source Code and License 6 votes vote down vote up
public void addConfigInfo(final ConfigInfo configInfo, final String content) {
    final Timestamp time = TimeUtils.getCurrentTime();
    this.jt.update(
        "insert into config_info (data_id,group_id,content,md5,gmt_create,gmt_modified) values(?,?,?,?,?,?)",
        new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                int index = 1;
                ps.setString(index++, configInfo.getDataId());
                ps.setString(index++, configInfo.getGroup());
                ps.setString(index++, content);
                ps.setString(index++, configInfo.getMd5());
                ps.setTimestamp(index++, time);
                ps.setTimestamp(index++, time);
            }
        });
}
 
Example 19
Project: cernunnos   File: QueryTask.java   Source Code and License 6 votes vote down vote up
public void perform(TaskRequest req, TaskResponse res) {
    final DataSource dataSource = DataSourceRetrievalUtil.getDataSource(dataSourcePhrase, connectionPhrase, req, res);
	
       final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

       //Setup the parameter setter and row callback handler for this task and the request/response
       final PreparedStatementSetter preparedStatementSetter = new PhraseParameterPreparedStatementSetter(this.parameters, req, res);
       final ResponseMappingRowCallbackHandler rowCallbackHandler = new ResponseMappingRowCallbackHandler(this, req, res);
       
       //Get the SQL and run the query
       final String finalSql = (String) sql.evaluate(req, res);
       jdbcTemplate.query(finalSql, preparedStatementSetter, rowCallbackHandler);
       
       if (rowCallbackHandler.getRowCount() == 0) {
           this.performSubtasks(req, res, this.emptyResult);
       }
}
 
Example 20
Project: diamond   File: PersistService.java   Source Code and License 6 votes vote down vote up
public void addConfigInfo(final ConfigInfo configInfo) {
    final Timestamp time = TimeUtils.getCurrentTime();

    this.jt.update(
        "insert into config_info (data_id,group_id,content,md5,gmt_create,gmt_modified) values(?,?,?,?,?,?)",
        new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                int index = 1;
                ps.setString(index++, configInfo.getDataId());
                ps.setString(index++, configInfo.getGroup());
                ps.setString(index++, configInfo.getContent());
                ps.setString(index++, configInfo.getMd5());
                ps.setTimestamp(index++, time);
                ps.setTimestamp(index++, time);
            }
        });
}
 
Example 21
Project: diamond   File: PersistService.java   Source Code and License 6 votes vote down vote up
public void updateConfigInfo(final ConfigInfo configInfo) {
    final Timestamp time = TimeUtils.getCurrentTime();

    this.jt.update("update config_info set content=?,md5=?,gmt_modified=? where data_id=? and group_id=?",
        new PreparedStatementSetter() {

            public void setValues(PreparedStatement ps) throws SQLException {
                int index = 1;
                ps.setString(index++, configInfo.getContent());
                ps.setString(index++, configInfo.getMd5());
                ps.setTimestamp(index++, time);
                ps.setString(index++, configInfo.getDataId());
                ps.setString(index++, configInfo.getGroup());
            }
        });
}
 
Example 22
Project: leopard-data   File: StatementParameter.java   Source Code and License 6 votes vote down vote up
/**
 * 生成PreparedStatementSetter对象.
 * 
 * @return PreparedStatementSetter
 */
public PreparedStatementSetter getParameters() {
	if (list.size() == 0) {
		return null;
	}
	PreparedStatementSetter param = new PreparedStatementSetter() {
		@Override
		public void setValues(PreparedStatement pstmt) {
			try {
				StatementParameter.this.setValues(pstmt);
			}
			catch (SQLException e) {
				throw new InvalidParamDataAccessException(e);
			}
		}

	};
	return param;
}
 
Example 23
Project: p00   File: UserDaoJdbc.java   Source Code and License 6 votes vote down vote up
public int updatePwd(String id,String passwd){
	final String id2 = id;
	int res = 0;
	final String passwd2 = passwd;
	try{
		res = this.jdbcTemplate.update("update organization_user set password=? where id=?", new PreparedStatementSetter(){
	       public void setValues(PreparedStatement ps) throws SQLException{
	           ps.setString(1,passwd2);
	           ps.setString(2,id2);
	       }
	});
	return res;
	}catch(EmptyResultDataAccessException e){
	  e.printStackTrace();
	  return res;
	}
}
 
Example 24
Project: ds4p   File: UsersRepository.java   Source Code and License 6 votes vote down vote up
public void updateUser(final Users user) {
	validateUser(user);
	
    getJdbcTemplate().update(updateUserSql, new PreparedStatementSetter() {
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, user.getPassword());
            ps.setBoolean(2, user.isEnabled());
            ps.setInt(3, user.getFailedLoginAttempts());
            String lockoutTime=(user.getLockoutTime()==null)?
        			"NULL":new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(user.getLockoutTime().getTime());
            ps.setString(4, lockoutTime);
            ps.setString(5, user.getUsername());
            
        }
    });

        deleteUserAuthorities(user.getUsername());
        insertUserAuthorities(user);
}
 
Example 25
Project: ds4p   File: UsersRepository.java   Source Code and License 6 votes vote down vote up
public void createGroup(final String groupName, final List<GrantedAuthority> authorities) {
    Assert.hasText(groupName);
    Assert.notNull(authorities);

    logger.debug("Creating new group '" + groupName + "' with authorities " +
            AuthorityUtils.authorityListToSet(authorities));

    getJdbcTemplate().update(insertGroupSql, groupName);

    final int groupId = findGroupId(groupName);

    for (GrantedAuthority a : authorities) {
        final String authority = a.getAuthority();
        getJdbcTemplate().update(insertGroupAuthoritySql, new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                ps.setInt(1, groupId);
                ps.setString(2, authority);
            }
        });
    }
}
 
Example 26
Project: spring-session   File: JdbcOperationsSessionRepositoryTests.java   Source Code and License 6 votes vote down vote up
@Test
public void saveNewWithAttributes() {
	JdbcOperationsSessionRepository.JdbcSession session = this.repository
			.createSession();
	session.setAttribute("testName", "testValue");

	this.repository.save(session);

	assertThat(session.isNew()).isFalse();
	assertPropagationRequiresNew();
	verify(this.jdbcOperations, times(1)).update(startsWith("INSERT"),
			isA(PreparedStatementSetter.class));
	verify(this.jdbcOperations, times(1)).batchUpdate(
			and(startsWith("INSERT"), contains("ATTRIBUTE_BYTES")),
			isA(BatchPreparedStatementSetter.class));
}
 
Example 27
Project: spring-session   File: JdbcOperationsSessionRepositoryTests.java   Source Code and License 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void getSessionNotFound() {
	String sessionId = "testSessionId";
	given(this.jdbcOperations.query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class)))
			.willReturn(Collections.emptyList());

	JdbcOperationsSessionRepository.JdbcSession session = this.repository
			.findById(sessionId);

	assertThat(session).isNull();
	assertPropagationRequiresNew();
	verify(this.jdbcOperations, times(1)).query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class));
}
 
Example 28
Project: spring-session   File: JdbcOperationsSessionRepositoryTests.java   Source Code and License 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void getSessionExpired() {
	Session expired = this.repository.new JdbcSession();
	expired.setLastAccessedTime(Instant.now().minusSeconds(
			MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS + 1));
	given(this.jdbcOperations.query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class)))
			.willReturn(Collections.singletonList(expired));

	JdbcOperationsSessionRepository.JdbcSession session = this.repository
			.findById(expired.getId());

	assertThat(session).isNull();
	assertPropagationRequiresNew();
	verify(this.jdbcOperations, times(1)).query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class));
	verify(this.jdbcOperations, times(1)).update(startsWith("DELETE"),
			eq(expired.getId()));
}
 
Example 29
Project: spring-session   File: JdbcOperationsSessionRepositoryTests.java   Source Code and License 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void getSessionFound() {
	Session saved = this.repository.new JdbcSession("primaryKey", new MapSession());
	saved.setAttribute("savedName", "savedValue");
	given(this.jdbcOperations.query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class)))
			.willReturn(Collections.singletonList(saved));

	JdbcOperationsSessionRepository.JdbcSession session = this.repository
			.findById(saved.getId());

	assertThat(session.getId()).isEqualTo(saved.getId());
	assertThat(session.isNew()).isFalse();
	assertThat(session.<String>getAttribute("savedName")).isEqualTo("savedValue");
	assertPropagationRequiresNew();
	verify(this.jdbcOperations, times(1)).query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class));
}
 
Example 30
Project: spring-session   File: JdbcOperationsSessionRepositoryTests.java   Source Code and License 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void findByIndexNameAndIndexValuePrincipalIndexNameNotFound() {
	String principal = "username";
	given(this.jdbcOperations.query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class)))
			.willReturn(Collections.emptyList());

	Map<String, JdbcOperationsSessionRepository.JdbcSession> sessions = this.repository
			.findByIndexNameAndIndexValue(
					FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
					principal);

	assertThat(sessions).isEmpty();
	assertPropagationRequiresNew();
	verify(this.jdbcOperations, times(1)).query(isA(String.class),
			isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class));
}
 
Example 31
Project: dhcp   File: JdbcIaManager.java   Source Code and License 6 votes vote down vote up
/**
 * Expire ia.
 * 
 * @param id the id
 */
protected void expireIA(final Long id)
{	
	getJdbcTemplate().update(
			"update identityassoc set state=" + IdentityAssoc.EXPIRED +
			" where id=?" +
			" and not exists" +
			" (select 1 from iaaddress" +
			" where identityassoc_id=identityassoc.id" +
			" and validendtime>=?)",
			new PreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps)
						throws SQLException {
					ps.setLong(1, id);
					java.sql.Timestamp now = new java.sql.Timestamp((new Date()).getTime());
					ps.setTimestamp(2, now, Util.GMT_CALENDAR);
				}
			});
	
}
 
Example 32
Project: dhcp   File: JdbcIaManager.java   Source Code and License 6 votes vote down vote up
/**
 * Delete expired ia.
 * 
 * @param id the id
 */
protected void deleteExpiredIA(final Long id)
{	
	getJdbcTemplate().update(
			"delete from identityassoc" +
			" where id=?" +
			" and not exists (select 1 from iaaddress" +
			"				  where identityassoc_id=identityassoc.id" +
			"				  and validendtime is not null and validendtime>=?)",
			new PreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps)
						throws SQLException {
					ps.setLong(1, id);
					java.sql.Timestamp now = new java.sql.Timestamp((new Date()).getTime());
					ps.setTimestamp(2, now, Util.GMT_CALENDAR);
				}
			});
	
}
 
Example 33
Project: dhcp   File: JdbcIaManager.java   Source Code and License 6 votes vote down vote up
/**
 * Expire i as.
 */
protected void expireIAs()
{
	getJdbcTemplate().update(
			"update identityassoc set state=" + IdentityAssoc.EXPIRED +
			" where exists (select 1 from iaaddress where identityassoc_id=identityassoc.id and validendtime<?)" +
			" and not exists (select 1 from iaaddress where identityassoc_id=identityassoc.id and validendtime>=?)",
			new PreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps)
						throws SQLException {
					java.sql.Timestamp now = new java.sql.Timestamp((new Date()).getTime());
					ps.setTimestamp(1, now, Util.GMT_CALENDAR);
					ps.setTimestamp(2, now, Util.GMT_CALENDAR);
				}
			});
}
 
Example 34
Project: dhcp   File: JdbcIdentityAssocDAO.java   Source Code and License 6 votes vote down vote up
public void update(final IdentityAssoc ia)
{
	String updateQuery = "update identityassoc" +
						" set duid=?," +
						" iatype=?," +
						" iaid=?," +
						" state=?" +
						" where id=?";
	getJdbcTemplate().update(updateQuery,
			new PreparedStatementSetter() {
		@Override
		public void setValues(PreparedStatement ps) throws SQLException {
			ps.setBytes(1, ia.getDuid());
			ps.setByte(2, ia.getIatype());
			ps.setLong(3, ia.getIaid());
			ps.setByte(4, ia.getState()); 
			ps.setLong(5, ia.getId());
		}
	});
}
 
Example 35
Project: dhcp   File: JdbcIaPrefixDAO.java   Source Code and License 6 votes vote down vote up
public List<IaPrefix> findAllOlderThan(Date date)
{
       return getJdbcTemplate().query(
               "select * from iaprefix" +
               " join identityassoc ia on identityassoc_id=ia.id" +
               " where ia.iatype = ?" +
               " and validendtime < ? order by validendtime",
               new PreparedStatementSetter() {
           		@Override
           		public void setValues(PreparedStatement ps) throws SQLException {
           			ps.setByte(1, IdentityAssoc.PD_TYPE);
           			java.sql.Timestamp ts = new java.sql.Timestamp(new Date().getTime());
           			ps.setTimestamp(2, ts, Util.GMT_CALENDAR);
           		}
               },
               new IaPrefixRowMapper());
}
 
Example 36
Project: dhcp   File: JdbcIaPrefixDAO.java   Source Code and License 6 votes vote down vote up
public List<IaPrefix> findUnusedByRange(final InetAddress startAddr, final InetAddress endAddr)
{
	final long offerExpiration = new Date().getTime() - 12000;	// 2 min = 120 sec = 12000 ms
       return getJdbcTemplate().query(
               "select * from iaprefix" +
               " where ((state=" + IaPrefix.ADVERTISED +
               " and starttime <= ?)" +
               " or (state=" + IaPrefix.EXPIRED +
               " or state=" + IaPrefix.RELEASED + "))" +
               " and prefixaddress >= ? and prefixaddress <= ?" +
               " order by state, validendtime, ipaddress",
               new PreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps) throws SQLException {
					java.sql.Timestamp ts = new java.sql.Timestamp(offerExpiration);
					ps.setTimestamp(1, ts);
					ps.setBytes(2, startAddr.getAddress());
					ps.setBytes(3, endAddr.getAddress());
				}                	
               },
               new IaPrefixRowMapper());
}
 
Example 37
Project: dhcp   File: JdbcIaAddressDAO.java   Source Code and License 6 votes vote down vote up
public List<IaAddress> findExpiredAddresses(final byte iatype)
{
       return getJdbcTemplate().query(
               "select * from iaaddress a" +
               " join identityassoc ia on ia.id=a.identityassoc_id" +
               " where ia.iatype = ?" +
               " and a.state != " + IaAddress.STATIC +
               " and a.validendtime < ? order by a.validendtime",
               new PreparedStatementSetter() {
           		@Override
           		public void setValues(PreparedStatement ps) throws SQLException {
           			ps.setByte(1, iatype);
           			java.sql.Timestamp ts = new java.sql.Timestamp(new Date().getTime());
           			ps.setTimestamp(2, ts, Util.GMT_CALENDAR);
           		}
               },
               new IaAddrRowMapper());
}
 
Example 38
Project: dhcp   File: JdbcIaAddressDAO.java   Source Code and License 6 votes vote down vote up
public List<IaAddress> findUnusedByRange(final InetAddress startAddr, final InetAddress endAddr)
{
	final long offerExpiration = new Date().getTime() - 12000;	// 2 min = 120 sec = 12000 ms
       return getJdbcTemplate().query(
               "select * from iaaddress" +
               " where ((state=" + IaAddress.ADVERTISED +
               " and starttime <= ?)" +
               " or (state=" + IaAddress.EXPIRED +
               " or state=" + IaAddress.RELEASED + "))" +
               " and ipaddress >= ? and ipaddress <= ?" +
               " order by state, validendtime, ipaddress",
               new PreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps) throws SQLException {
					java.sql.Timestamp ts = new java.sql.Timestamp(offerExpiration);
					ps.setTimestamp(1, ts);
					ps.setBytes(2, startAddr.getAddress());
					ps.setBytes(3, endAddr.getAddress());
				}                	
               },
               new IaAddrRowMapper());
}
 
Example 39
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
/**
 * Update ia options.
 */
protected void updateIaOptions(final InetAddress inetAddr, 
								final Collection<DhcpOption> iaOptions)
{
	getJdbcTemplate().update("update dhcplease" +
			" set ia_options=?" +
			" where ipaddress=?",
			new PreparedStatementSetter() {
		@Override
		public void setValues(PreparedStatement ps)
				throws SQLException {
			ps.setBytes(1, encodeOptions(iaOptions));
			ps.setBytes(2, inetAddr.getAddress());
		}
	});
}
 
Example 40
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
/**
 * Update ipaddr options.
 */
protected void updateIpAddrOptions(final InetAddress inetAddr,
								final Collection<DhcpOption> ipAddrOptions)
{
	getJdbcTemplate().update("update dhcplease" +
			" set ipaddr_options=?" +
			" where ipaddress=?",
			new PreparedStatementSetter() {
		@Override
		public void setValues(PreparedStatement ps)
				throws SQLException {
			ps.setBytes(1, encodeOptions(ipAddrOptions));
			ps.setBytes(2, inetAddr.getAddress());
		}
	});
}
 
Example 41
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
/**
 * Find dhcp leases for ia.
 *
 * @param duid the duid
 * @param iatype the iatype
 * @param iaid the iaid
 * @return the list
 */
protected List<DhcpLease> findDhcpLeasesForIA(final byte[] duid, final byte iatype, final long iaid)
{
	return getJdbcTemplate().query(
               "select * from dhcplease" +
               " where duid = ?" +
               " and iatype = ?" +
               " and iaid = ?" +
               " order by ipaddress",
               new PreparedStatementSetter() {
           		@Override
           		public void setValues(PreparedStatement ps) throws SQLException {
           			ps.setBytes(1, duid);
           			ps.setByte(2, iatype);
           			ps.setLong(3, iaid);
           		}
           	},
               new DhcpLeaseRowMapper());
}
 
Example 42
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
/**
 * Find dhcp lease for InetAddr.
 *
 * @param inetAddr the InetAddr
 * @return the DhcpLease
 */
protected DhcpLease findDhcpLeaseForInetAddr(final InetAddress inetAddr)
{
       List<DhcpLease> leases = getJdbcTemplate().query(
               "select * from dhcplease" +
               " where ipaddress = ?",
               new PreparedStatementSetter() {
           		@Override
           		public void setValues(PreparedStatement ps) throws SQLException {
           			ps.setBytes(1, inetAddr.getAddress());
           		}
           	},
               new DhcpLeaseRowMapper());
       if ((leases != null) && (leases.size() > 0)) {
       	if (leases.size() == 1) {
       		return leases.get(0);
       	}
       	else {
       		//TODO: this really should be impossible because of the unique
       		//		constraint on the IP address
       		log.error("Found more than one lease for IP=" + 
       					inetAddr.getHostAddress());
       	}
       }
       return null;
}
 
Example 43
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
@Override
public List<IaAddress> findUnusedIaAddresses(final InetAddress startAddr, final InetAddress endAddr)
{
	long offerExpireMillis = 
		DhcpServerPolicies.globalPolicyAsLong(Property.BINDING_MANAGER_OFFER_EXPIRATION);
	final long offerExpiration = new Date().getTime() - offerExpireMillis;
       List<DhcpLease> leases = getJdbcTemplate().query(
               "select * from dhcplease" +
               " where ((state=" + IaAddress.ADVERTISED +
               " and starttime <= ?)" +
               " or (state=" + IaAddress.EXPIRED +
               " or state=" + IaAddress.RELEASED + "))" +
               " and ipaddress >= ? and ipaddress <= ?" +
               " order by state, validendtime, ipaddress",
               new PreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps) throws SQLException {
					java.sql.Timestamp ts = new java.sql.Timestamp(offerExpiration);
					ps.setTimestamp(1, ts);
					ps.setBytes(2, startAddr.getAddress());
					ps.setBytes(3, endAddr.getAddress());
				}                	
               },
               new DhcpLeaseRowMapper());
	return toIaAddresses(leases);
}
 
Example 44
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
protected List<DhcpLease> findExpiredLeases(final byte iatype) {
       return getJdbcTemplate().query(
               "select * from dhcplease" +
               " where iatype = ?" +
               " and state != " + IaAddress.STATIC +
               " and validendtime < ? order by validendtime",
               new PreparedStatementSetter() {
           		@Override
           		public void setValues(PreparedStatement ps) throws SQLException {
           			ps.setByte(1, iatype);
           			java.sql.Timestamp ts = new java.sql.Timestamp(new Date().getTime());
           			ps.setTimestamp(2, ts, Util.GMT_CALENDAR);
           		}
               },
               new DhcpLeaseRowMapper());
}
 
Example 45
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
@Override
public List<IaPrefix> findUnusedIaPrefixes(final InetAddress startAddr, final InetAddress endAddr) {
	final long offerExpiration = new Date().getTime() - 12000;	// 2 min = 120 sec = 12000 ms
       List<DhcpLease> leases = getJdbcTemplate().query(
               "select * from dhcplease" +
               " where ((state=" + IaPrefix.ADVERTISED +
               " and starttime <= ?)" +
               " or (state=" + IaPrefix.EXPIRED +
               " or state=" + IaPrefix.RELEASED + "))" +
               " and ipaddress >= ? and ipaddress <= ?" +
               " order by state, validendtime, ipaddress",
               new PreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps) throws SQLException {
					java.sql.Timestamp ts = new java.sql.Timestamp(offerExpiration);
					ps.setTimestamp(1, ts);
					ps.setBytes(2, startAddr.getAddress());
					ps.setBytes(3, endAddr.getAddress());
				}                	
               },
               new DhcpLeaseRowMapper());
	return toIaPrefixes(leases);
}
 
Example 46
Project: dhcp   File: JdbcLeaseManager.java   Source Code and License 6 votes vote down vote up
@Override
public List<IaPrefix> findExpiredIaPrefixes() {
       List<DhcpLease> leases = getJdbcTemplate().query(
               "select * from dhcplease" +
               " where iatype = " + IdentityAssoc.PD_TYPE +
               " and validendtime < ? order by validendtime",
               new PreparedStatementSetter() {
           		@Override
           		public void setValues(PreparedStatement ps) throws SQLException {
           			java.sql.Timestamp ts = new java.sql.Timestamp(new Date().getTime());
           			ps.setTimestamp(1, ts, Util.GMT_CALENDAR);
           		}
               },
               new DhcpLeaseRowMapper());
	return toIaPrefixes(leases);
}
 
Example 47
Project: cluster-repo   File: ClusterReader.java   Source Code and License 6 votes vote down vote up
@Override
public ClusterSummary findClusterSummaryByUUID(final String uuid) {
    final String CLUSTER_QUERY = "SELECT * FROM spectrum_cluster WHERE uuid=?";

    List<ClusterSummary> clusterSummaries = template.query(CLUSTER_QUERY, new PreparedStatementSetter() {
        @Override
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setString(1, uuid);
        }
    }, RowMapperFactory.getClusterSummaryRowMapper());

    if (clusterSummaries.isEmpty()) {
        return new ClusterSummary();
    } else {
        return clusterSummaries.get(0);
    }
}
 
Example 48
Project: cluster-repo   File: ClusterReader.java   Source Code and License 6 votes vote down vote up
@Override
public ClusterSummary findClusterSummary(final Long clusterId) {
    final String CLUSTER_QUERY = "SELECT * FROM spectrum_cluster WHERE cluster_pk=?";

    List<ClusterSummary> clusterSummaries = template.query(CLUSTER_QUERY, new PreparedStatementSetter() {
        @Override
        public void setValues(PreparedStatement ps) throws SQLException {
            ps.setLong(1, clusterId);
        }
    }, RowMapperFactory.getClusterSummaryRowMapper());

    if (clusterSummaries.isEmpty()) {
        return new ClusterSummary();
    } else {
        return clusterSummaries.get(0);
    }
}
 
Example 49
Project: opennmszh   File: JdbcWebOutageRepository.java   Source Code and License 6 votes vote down vote up
private PreparedStatementSetter paramSetter(final OutageCriteria criteria, final Object... args) {
    return new PreparedStatementSetter() {
        int paramIndex = 1;
        public void setValues(final PreparedStatement ps) throws SQLException {
            for(Object arg : args) {
                ps.setObject(paramIndex, arg);
                paramIndex++;
            }
            criteria.visit(new BaseOutageCriteriaVisitor<SQLException>() {
                @Override
                public void visitFilter(Filter filter) throws SQLException {
                    paramIndex += filter.bindParam(ps, paramIndex);
                }
            });
        }
    };
}
 
Example 50
Project: opennmszh   File: JdbcWebAlarmRepository.java   Source Code and License 6 votes vote down vote up
private PreparedStatementSetter paramSetter(final AlarmCriteria criteria, final Object... args) {
    return new PreparedStatementSetter() {
        int paramIndex = 1;
        public void setValues(final PreparedStatement ps) throws SQLException {
            for (Object arg : args) {
                ps.setObject(paramIndex, arg);
                paramIndex++;
            }
            criteria.visit(new BaseAlarmCriteriaVisitor<SQLException>() {
                @Override
                public void visitFilter(Filter filter) throws SQLException {
                    paramIndex += filter.bindParam(ps, paramIndex);
                }
            });
        }
    };
}
 
Example 51
Project: opennmszh   File: JdbcWebEventRepository.java   Source Code and License 6 votes vote down vote up
private PreparedStatementSetter paramSetter(final EventCriteria criteria, final Object... args) {
    return new PreparedStatementSetter() {
        int paramIndex = 1;
        public void setValues(final PreparedStatement ps) throws SQLException {
            for(Object arg : args) {
                ps.setObject(paramIndex, arg);
                paramIndex++;
            }
            criteria.visit(new BaseEventCriteriaVisitor<SQLException>() {
                @Override
                public void visitFilter(Filter filter) throws SQLException {
                    paramIndex += filter.bindParam(ps, paramIndex);
                }
            });
        }
        
    };
}
 
Example 52
Project: opennmszh   File: JdbcWebNotificationRepository.java   Source Code and License 6 votes vote down vote up
private PreparedStatementSetter paramSetter(final NotificationCriteria criteria, final Object...args){
    return new PreparedStatementSetter(){
        int paramIndex = 1;
        public void setValues(final PreparedStatement ps) throws SQLException {
            for(Object arg : args){
                ps.setObject(paramIndex, arg);
                paramIndex++;
            }
            criteria.visit(new BaseNotificationCriteriaVisitor<SQLException>(){
                @Override
                public void visitFilter(org.opennms.web.filter.Filter filter) throws SQLException{
                    LogUtils.infof(this, "filter sql: " + filter.getSql());
                    paramIndex += filter.bindParam(ps, paramIndex);
                }
            });
        }
        
    };
}
 
Example 53
Project: oauth-client-master   File: JdbcApprovalStore.java   Source Code and License 6 votes vote down vote up
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()));
					}
				});
		logger.debug(deleted + " expired approvals deleted");
	}
	catch (DataAccessException ex) {
		logger.error("Error purging expired approvals", ex);
		return false;
	}
	return true;
}
 
Example 54
Project: oauth-client-master   File: JdbcApprovalStore.java   Source Code and License 6 votes vote down vote up
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()));
			ps.setString(4, approval.getUserId());
			ps.setString(5, approval.getClientId());
			ps.setString(6, approval.getScope());
		}
	});
	if (refreshed != 1) {
		return false;
	}
	return true;
}
 
Example 55
Project: cfi-gov   File: CfLookupStrategy.java   Source Code and License 6 votes vote down vote up
/**
 * Locates the primary key IDs specified in "findNow", adding AclImpl instances with StubAclParents to the
 * "acls" Map.
 *
 * @param acls    the AclImpls (with StubAclParents)
 * @param findNow Long-based primary keys to retrieve
 * @param sids
 */
private void lookupPrimaryKeys(final Map<Serializable, Acl> acls, final Set<Long> findNow, final List<Sid> sids) {
    Assert.notNull(acls, "ACLs are required");
    Assert.notEmpty(findNow, "Items to find now required");

    String sql = computeRepeatingSql(lookupPrimaryKeysWhereClause, findNow.size());

    Set<Long> parentsToLookup = jdbcTemplate.query(sql,
            new PreparedStatementSetter() {
                public void setValues(PreparedStatement ps) throws SQLException {
                    int i = 0;

                    for (Long toFind : findNow) {
                        i++;
                        ps.setLong(i, toFind);
                    }
                }
            }, new ProcessResultSet(acls, sids));

    // Lookup the parents, now that our JdbcTemplate has released the database connection (SEC-547)
    if (parentsToLookup.size() > 0) {
        lookupPrimaryKeys(acls, parentsToLookup, sids);
    }
}
 
Example 56
Project: otter   File: DbLoadAction.java   Source Code and License 6 votes vote down vote up
public Object doInTransaction(TransactionStatus status) {
    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);
            }
        });
        interceptor.transactionEnd(context, Arrays.asList(data), dbDialect);
        return affect;
    } finally {
        lobCreator.close();
    }
}
 
Example 57
Project: spring4-sandbox   File: JdbcConferenceDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void update(final Conference conference) {
	getJdbcTemplate()
			.update("update conference set slug=?, name=?, description=?, started_date=?, ended_date=? where id =? ",
					new PreparedStatementSetter() {

						@Override
						public void setValues(PreparedStatement ps)
								throws SQLException {
							ps.setString(1, conference.getSlug());
							ps.setString(2, conference.getName());
							ps.setString(3, conference.getDescription());
							ps.setTimestamp(4, new java.sql.Timestamp(
									conference.getStartedDate().getTime()));
							ps.setTimestamp(5, new java.sql.Timestamp(
									conference.getEndedDate().getTime()));
							ps.setLong(6, conference.getId());
						}
					});
}
 
Example 58
Project: spring4-sandbox   File: JdbcConferenceDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void update(final Conference conference) {
	getJdbcTemplate()
			.update("update conference set slug=?, name=?, description=?, started_date=?, ended_date=? where id =? ",
					new PreparedStatementSetter() {

						@Override
						public void setValues(PreparedStatement ps)
								throws SQLException {
							ps.setString(1, conference.getSlug());
							ps.setString(2, conference.getName());
							ps.setString(3, conference.getDescription());
							ps.setTimestamp(4, new java.sql.Timestamp(
									conference.getStartedDate().getTime()));
							ps.setTimestamp(5, new java.sql.Timestamp(
									conference.getEndedDate().getTime()));
							ps.setLong(6, conference.getId());
						}
					});
}
 
Example 59
Project: spring4-sandbox   File: NamedParamJdbcTemplateConferenceDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void update(final Conference conference) {
	jdbcTemplate
			.update("update conference set slug=?, name=?, description=?, started_date=?, ended_date=? where id =? ",
					new PreparedStatementSetter() {

						@Override
						public void setValues(PreparedStatement ps)
								throws SQLException {
							ps.setString(1, conference.getSlug());
							ps.setString(2, conference.getName());
							ps.setString(3, conference.getDescription());
							ps.setTimestamp(4, new java.sql.Timestamp(
									conference.getStartedDate().getTime()));
							ps.setTimestamp(5, new java.sql.Timestamp(
									conference.getEndedDate().getTime()));
							ps.setLong(6, conference.getId());
						}
					});
}
 
Example 60
Project: spring4-sandbox   File: JdbcTemplateConferenceDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void update(final Conference conference) {
	jdbcTemplate
			.update("update conference set slug=?, name=?, description=?, started_date=?, ended_date=? where id =? ",
					new PreparedStatementSetter() {

						@Override
						public void setValues(PreparedStatement ps)
								throws SQLException {
							ps.setString(1, conference.getSlug());
							ps.setString(2, conference.getName());
							ps.setString(3, conference.getDescription());
							ps.setTimestamp(4, new java.sql.Timestamp(
									conference.getStartedDate().getTime()));
							ps.setTimestamp(5, new java.sql.Timestamp(
									conference.getEndedDate().getTime()));
							ps.setLong(6, conference.getId());
						}
					});
}