List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate
public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate)
From source file:org.cloudfoundry.samples.handson.ex6.CopyController.java
@Qualifier("toDataSource") public void setToDataSource(DataSource dataSource) { this.toTemplate = new NamedParameterJdbcTemplate(dataSource); }
From source file:com.thinkbiganalytics.jira.JiraSpringTestConfig.java
@Bean public NamedParameterJdbcTemplate namedParameterJdbcTemplate() { return new NamedParameterJdbcTemplate(dataSource()); }
From source file:org.cloudfoundry.identity.uaa.rest.jdbc.JdbcPagingList.java
public JdbcPagingList(JdbcTemplate jdbcTemplate, LimitSqlAdapter limitSqlAdapter, String sql, Map<String, ?> args, RowMapper<E> mapper, int pageSize) { this(new NamedParameterJdbcTemplate(jdbcTemplate), limitSqlAdapter, sql, args, mapper, pageSize); }
From source file:org.ext4spring.parameter.dao.JdbcParameterRepository.java
@Required public void setDataSource(DataSource dataSource) { this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); }
From source file:com.exploringspatial.dao.impl.ConflictDaoImpl.java
@PostConstruct public void init() { jdbcTemplate = new JdbcTemplate(dataSource); namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); selectSql = "SELECT ".concat("GWNO, ").concat("EVENT_ID_CNTY, ").concat("EVENT_ID_NO_CNTY, ") .concat("EVENT_DATE, ").concat("YEAR, ").concat("TIME_PRECISION, ").concat("EVENT_TYPE, ") .concat("ACTOR1, ").concat("ALLY_ACTOR_1, ").concat("INTER1, ").concat("ACTOR2, ") .concat("ALLY_ACTOR_2, ").concat("INTER2, ").concat("INTERACTION, ").concat("COUNTRY, ") .concat("ADMIN1, ").concat("ADMIN2, ").concat("ADMIN3, ").concat("LOCATION, ").concat("LATITUDE, ") .concat("LONGITUDE, ").concat("GEO_PRECIS, ").concat("SOURCE, ").concat("NOTES, ") .concat("FATALITIES FROM CONFLICT "); insertSql = "INSERT INTO CONFLICT (".concat("GWNO, ").concat("EVENT_ID_CNTY, ").concat("EVENT_ID_NO_CNTY, ") .concat("EVENT_DATE, ").concat("YEAR, ").concat("TIME_PRECISION, ").concat("EVENT_TYPE, ") .concat("ACTOR1, ").concat("ALLY_ACTOR_1, ").concat("INTER1, ").concat("ACTOR2, ") .concat("ALLY_ACTOR_2, ").concat("INTER2, ").concat("INTERACTION, ").concat("COUNTRY, ") .concat("ADMIN1, ").concat("ADMIN2, ").concat("ADMIN3, ").concat("LOCATION, ").concat("LATITUDE, ") .concat("LONGITUDE, ").concat("GEO_PRECIS, ").concat("SOURCE, ").concat("NOTES, ") .concat("FATALITIES) VALUES (:gwno, :event_id_cnty, :eventId, :eventDate, :year, :timePrecision, :eventType, ") .concat(":actor1, :allyActor1, :inter1, :actor2, :allyActor2, :inter2, :interaction, :country, ") .concat(":admin1, :admin2, :admin3, :location, :latitude, :longitude, :geoPrecision, :source, ") .concat(":notes, :fatalities )"); batchUpdateSql = "INSERT INTO CONFLICT (".concat("GWNO, ").concat("EVENT_ID_CNTY, ") .concat("EVENT_ID_NO_CNTY, ").concat("EVENT_DATE, ").concat("YEAR, ").concat("TIME_PRECISION, ") .concat("EVENT_TYPE, ").concat("ACTOR1, ").concat("ALLY_ACTOR_1, ").concat("INTER1, ") .concat("ACTOR2, ").concat("ALLY_ACTOR_2, ").concat("INTER2, ").concat("INTERACTION, ") .concat("COUNTRY, ").concat("ADMIN1, ").concat("ADMIN2, ").concat("ADMIN3, ").concat("LOCATION, ") .concat("LATITUDE, ").concat("LONGITUDE, ").concat("GEO_PRECIS, ").concat("SOURCE, ") .concat("NOTES, ") .concat("FATALITIES) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"); }
From source file:com.catt.mobile.repository.jdbc.JdbcAccountRepositoryImpl.java
@Autowired public JdbcAccountRepositoryImpl(DataSource dataSource, NamedParameterJdbcTemplate namedParameterJdbcTemplate) { this.dataSource = dataSource; this.insertAccount = new SimpleJdbcInsert(dataSource).withTableName("account") .usingGeneratedKeyColumns("id"); this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); }
From source file:com.simplymeasured.prognosticator.ThreadedQueryRunnable.java
@Override public void run() { NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource); try {/* w w w . j a v a 2 s . co m*/ template.query(query, parameters, new RowCallbackHandler() { @Override public void processRow(ResultSet resultSet) throws SQLException { try { Map<String, Object> result = Maps.newHashMap(); final ResultSetMetaData metadata = resultSet.getMetaData(); for (int i = 1; i <= metadata.getColumnCount(); i++) { String columnTypeName = metadata.getColumnTypeName(i); final Object value; if ("array".equalsIgnoreCase(columnTypeName)) { String stringValue = resultSet.getString(i); if (stringValue != null) { value = objectMapper.readValue(stringValue, List.class); } else { value = null; } } else if ("map".equalsIgnoreCase(columnTypeName) || "struct".equalsIgnoreCase(columnTypeName)) { String stringValue = resultSet.getString(i); if (stringValue != null) { value = objectMapper.readValue(stringValue, Map.class); } else { value = null; } } else { value = resultSet.getObject(i); } result.put(metadata.getColumnName(i), value); } resultQueue.put(result); } catch (SQLException se) { LOG.warn("Database error!", se); throw new RuntimeException("Database error!", se); } catch (InterruptedException ie) { LOG.warn("Query killed!", ie); throw new RuntimeException("Query killed!", ie); } catch (Exception ex) { LOG.warn("Unable to parse row!", ex); throw new RuntimeException("Unable to parse row!", ex); } } }); resultQueue.put(Collections.<String, Object>emptyMap()); } catch (DataAccessException dae) { try { resultQueue.put(Collections.<String, Object>emptyMap()); } catch (InterruptedException ie) { LOG.warn("Queue is dead!", ie); } LOG.warn("Unable to execute query - attempting to clean up", dae); } catch (InterruptedException ie) { LOG.warn("Queue is dead!", ie); } }
From source file:com.phideltcmu.recruiter.server.dao.RecruitListDao.java
@Override public List<Person> selectAll(List<Category> desiredCategories) { checkSingleton();// w ww .j a v a 2s . com List<String> list = new ArrayList<String>(); for (Category c : desiredCategories) { list.add(c.getValue()); } NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate); MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue("categories", list); return namedParameterJdbcTemplate.query("SELECT * FROM recruitList.infolist WHERE status IN (:categories)", parameters, new PersonRowMapper()); }