List of usage examples for org.springframework.jdbc.core.namedparam MapSqlParameterSource addValue
public MapSqlParameterSource addValue(String paramName, @Nullable Object value, int sqlType)
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public void saveRequestHeader(MutableRequestHeader requestHeader, int contentId) throws DataAccessException { saveMessageHeader(requestHeader, contentId); MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(ID, requestHeader.getId(), Types.INTEGER); params.addValue(HOST, requestHeader.getTarget().getHostName(), Types.VARCHAR); params.addValue(PORT, requestHeader.getTarget().getPort(), Types.INTEGER); params.addValue(SSL, requestHeader.isSsl(), Types.BIT); addTimestamp(params, REQUEST_SUBMISSION_TIME, requestHeader.getTime()); getNamedParameterJdbcTemplate().update(INSERT_REQUEST, params); }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public int getMessageContentId(int headerId) throws DataAccessException { try {/*from ww w .ja v a 2s . c om*/ MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(ID, headerId, Types.INTEGER); SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate()); return template.queryForInt(SELECT_CONTENT_ID, params); } catch (EmptyResultDataAccessException erdae) { return -1; } }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public int getMessageContentSize(int id) throws DataAccessException { try {//from w ww. ja va 2 s . c om MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(ID, id, Types.INTEGER); SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate()); return template.queryForInt(SELECT_CONTENT_SIZE, params); } catch (EmptyResultDataAccessException erdae) { return -1; } }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public Conversation getConversation(int id) throws DataAccessException { try {/*from w ww .j a va2 s. c om*/ MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(ID, id, Types.INTEGER); SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate()); return template.queryForObject(SELECT_SUMMARY, CONVERSATION_MAPPER, params); } catch (EmptyResultDataAccessException erdae) { return null; } }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public byte[] loadMessageContent(int id) throws DataAccessException { try {/*from w w w .j a v a 2 s . com*/ MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(ID, id, Types.INTEGER); SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate()); return template.queryForObject(SELECT_CONTENT, CONTENT_MAPPER, params); } catch (EmptyResultDataAccessException erdae) { return null; } }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public MutableResponseHeader loadResponseHeader(int id) throws DataAccessException { try {//www. j a v a 2s .c o m MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(ID, id, Types.INTEGER); SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate()); return template.queryForObject(SELECT_RESPONSE, RESPONSE_MAPPER, params); } catch (EmptyResultDataAccessException erdae) { return null; } }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public int saveMessageContent(InputStream messageContent) throws DataAccessException { CountingInputStream cis = new CountingInputStream(messageContent); MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(CONTENT, cis, Types.LONGVARBINARY); params.addValue(SIZE, 0, Types.INTEGER); KeyHolder key = new GeneratedKeyHolder(); getNamedParameterJdbcTemplate().update(INSERT_CONTENT, params, key); int id = key.getKey().intValue(); params = new MapSqlParameterSource(); params.addValue(SIZE, cis.getCount(), Types.INTEGER); getNamedParameterJdbcTemplate().update(UPDATE_CONTENT_SIZE, params); return id;//www .j a v a2 s. com }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public Collection<Integer> listConversationsSince(int id) throws DataAccessException { MapSqlParameterSource params = new MapSqlParameterSource(); try {/*from w w w. ja va 2s . c o m*/ params.addValue(ID, id, Types.INTEGER); SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate()); return template.query(SELECT_CONVERSATIONS, ID_MAPPER, params); } catch (EmptyResultDataAccessException erdae) { return Collections.emptyList(); } }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAO.java
public RequestHeader loadRequestHeader(int id) throws DataAccessException { MapSqlParameterSource params = new MapSqlParameterSource(); try {/*www. j a va2 s . c o m*/ params.addValue(ID, id, Types.INTEGER); SimpleJdbcTemplate template = new SimpleJdbcTemplate(getNamedParameterJdbcTemplate()); return template.queryForObject(SELECT_REQUEST, REQUEST_MAPPER, params); } catch (EmptyResultDataAccessException erdae) { return null; } }
From source file:anyframe.core.query.impl.QueryServiceImpl.java
private Map generatePropertiesMap(Object[] values, int[] types, MapSqlParameterSource mapSqlParameterSource) throws QueryServiceException { Map properties = new HashMap(); String tempStr = null;// w w w . j av a 2s . co m Object[] tempArray = null; for (int i = 0; i < values.length; i++) { if (values[i] instanceof String) { tempStr = (String) values[i]; int pos = tempStr.indexOf(DELIMETER); if (pos < 0) { throw new QueryServiceException(getMessageSource(), "error.query.generate.valuemap.string"); } properties.put(tempStr.substring(0, pos), tempStr.substring(pos + 1)); if (mapSqlParameterSource != null) mapSqlParameterSource.addValue(tempStr.substring(0, pos), tempStr.substring(pos + 1), types[i]); } else if (values[i] instanceof Object[]) { tempArray = (Object[]) values[i]; if (tempArray.length != 2) { throw new QueryServiceException(getMessageSource(), "error.query.generate.valuemap.array"); } properties.put(tempArray[0], tempArray[1]); if (mapSqlParameterSource != null) mapSqlParameterSource.addValue((String) tempArray[0], tempArray[1], types[i]); } else if (values[i] == null) { continue; } else { return null; } } return properties; }