Example usage for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate

List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate.

Prototype

public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate) 

Source Link

Document

Create a new NamedParameterJdbcTemplate for the given classic Spring org.springframework.jdbc.core.JdbcTemplate .

Usage

From source file:org.terasoluna.gfw.functionaltest.app.DBLogProvider.java

public DBLogProvider(JdbcOperations jdbcOperations) {
    this.jdbcOperations = new NamedParameterJdbcTemplate(jdbcOperations);
}

From source file:com.xinferin.dao.DAOCustomerRegistrationImpl.java

public DAOCustomerRegistrationImpl(DataSource dataSource) {
    this.dataSource = dataSource;
    jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}

From source file:ru.mystamps.web.dao.impl.JdbcUserDaoImpl.java

public JdbcUserDaoImpl(DataSource dataSource) {
    jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}

From source file:com.mir00r.jdbc_dao.EmployeeDao.java

@Autowired
public void setDataSource(DataSource dataSource) {
    // this.dataSource = dataSource;
    jdbctemplate = new JdbcTemplate(dataSource);
    namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}

From source file:ar.com.springbasic.dao.AdminDaoImpl.java

@Autowired
private void setDataSource(DataSource dataSource) {
    this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}

From source file:com.stehno.test.TestDatabase.java

@Override
protected void before() throws Throwable {
    // org.h2.Driver
    jdbcTemplate = new JdbcTemplate(new DriverManagerDataSource("jdbc:h2:~/test", "sa", ""));

    namedJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);

    jdbcTemplate.execute(//from w  ww .jav  a2s  .  co  m
            "create table people (id int AUTO_INCREMENT primary key, first_name varchar(40), last_name varchar(40), age int)");
}

From source file:no.magott.training.BusinessSchemaDbIntegrationTest.java

@Test
public void createAndInsertIntoSpursMatch() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.addScript("classpath:business-schema.sql").build();
    String sql = "INSERT INTO SPURS_MATCH(MATCH_DATE, COMPETITION, OPPOSITION, VENUE, HALF_TIME_SCORE, GOALS_FOR, GOALS_AGAINST) VALUES(:date, :competition, :opposition, :venue, :halfTimeScore, :spursGoals, :oppositionGoals)";
    NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(db);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("date", new Date());
    params.put("opposition", "Ar5ena1");
    params.put("halfTimeScore", "(2-0)");
    params.put("venue", "WHL");
    params.put("spursGoals", 5);
    params.put("oppositionGoals", 1);
    params.put("competition", "FACUP");
    jdbcTemplate.update(sql, params);//from www.  j  a va  2 s .c om
    db.shutdown();
}

From source file:orz.neptune.prospring3.ch8.JdbcContactDao.java

public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
    this.updateContact = new UpdateContact(dataSource);
    this.insertContact = new InsertContact(dataSource);
    this.storeFunctionQuery = new StoreFunctionQuery(dataSource);
}

From source file:cherry.foundation.etl.ExtractorImpl.java

/**
 * ?/*from  w w w . java2  s. c o m*/
 * 
 * @param dataSource 
 * @param sql SQL
 * @param paramMap ?
 * @param consumer ??
 * @param limiter ?
 * @return ????
 * @throws LimiterException ??
 * @throws IOException ?
 */
@Override
public long extract(DataSource dataSource, String sql, Map<String, ?> paramMap, Consumer consumer,
        Limiter limiter) throws LimiterException, IOException {

    NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource);
    ResultSetExtractor<Long> extractor = new ExtractorResultSetExtractor(consumer, limiter);

    limiter.start();
    try {
        return template.query(sql, paramMap, extractor);
    } catch (IllegalStateException ex) {
        throw (IOException) ex.getCause();
    } finally {
        limiter.stop();
    }
}

From source file:ru.org.linux.tracker.TrackerDao.java

@Autowired
public void setDataSource(DataSource ds) {
    jdbcTemplate = new NamedParameterJdbcTemplate(ds);
}