Example usage for org.springframework.jdbc.core JdbcTemplate JdbcTemplate

List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate

Introduction

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

Prototype

public JdbcTemplate(DataSource dataSource) 

Source Link

Document

Construct a new JdbcTemplate, given a DataSource to obtain connections from.

Usage

From source file:com.dai.dao.TreinoDaoImpl.java

@Override
public List<Treino> listarTreinos() {
    List<Treino> treinoList = new ArrayList();

    String sql = "select * from treino";

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    treinoList = jdbcTemplate.query(sql, new TreinoRowMapper());
    return treinoList;
}

From source file:com.bt.aloha.sipstone.MaintenanceDao.java

public MaintenanceDao(String driver, String url, String uname, String pwd) {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(driver);//from w  w w.j a v  a 2 s .co m
    ds.setUrl(url);
    ds.setUsername(uname);
    ds.setPassword(pwd);
    this.jdbcTemplate = new JdbcTemplate(ds);
    testConnection();
}

From source file:DAO.Poll_Tbl_pkg.Poll_TblJDBCTemplate.java

public Poll_TblJDBCTemplate() throws SQLException {
    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    conn = (connectivity) context.getBean("connectivity");

    this.dataSource = conn.getDataSource();
    this.jdbcTemplateObject = new JdbcTemplate(dataSource);

}

From source file:org.cloudfoundry.identity.uaa.scim.job.UserSyncJobIntegrationTests.java

public void setUpModifiedUaaData(Date modified) throws Exception {
    TestUtils.deleteFrom(uaaDataSource, "users");
    JdbcTemplate template = new JdbcTemplate(uaaDataSource);
    template.update(/* w  w w  .  j  a v a  2s  . c  o  m*/
            "insert into users (id, version, active, email, password, created, lastModified, userName, givenName, familyName) "
                    + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
            "00", 0, true, "marissa@test.org", "ENCRYPT_ME", new Date(), modified, "marissa@test.org",
            "Marissa", "Koala");
    template.update(
            "insert into users (id, version, active, email, password, created, lastModified, userName, givenName, familyName) "
                    + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
            "01", 0, true, "vcap_tester@vmware.com", "ENCRYPT_ME", new Date(), modified,
            "vcap_tester@vmware.com", "Vcap", "Tester");
    template.update(
            "insert into users (id, version, active, email, password, created, lastModified, userName, givenName, familyName) "
                    + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
            "02", 0, true, "dale@test.org", "ENCRYPT_ME", new Date(), modified, "dale@test.org", "Dale",
            "Olds");
}

From source file:com.sourcesense.ant.dbdep.task.dao.DbDepDao.java

public void setDs(DataSource ds) {
    this.jdbcTemplate = new JdbcTemplate(ds);
}

From source file:com.springsource.greenhouse.develop.JdbcAppRepositoryTest.java

public JdbcAppRepositoryTest() {
    EmbeddedDatabase db = new GreenhouseTestDatabaseBuilder().member().connectedApp().testData(getClass())
            .getDatabase();//w ww.j a v  a  2 s.co m
    transactional = new Transactional(db);
    jdbcTemplate = new JdbcTemplate(db);
    appRepository = new JdbcAppRepository(jdbcTemplate, Encryptors.noOpText());
}

From source file:just.aRest.project.DAO.ApplDAOImpl.java

@Override
public Application getByUsername(String username) {
    //get the application that the user requested,criteria : 1: username , 2: application is not online 
    String query = "SELECT app_code,amount,repayTime,buy_type,drivers_license,taxes,tekmiriwsi,status,accepted,username "
            + "FROM Application WHERE username= ? AND isOnline=0 AND status =1 AND accepted=1 LIMIT 1";
    try {//from   w  w w . j a  va  2s  .  c  o m
        //open jdbc connection
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        //get an object with the requested application
        Object queryForObject = jdbcTemplate.queryForObject(query, new Object[] { username },
                new BeanPropertyRowMapper<Application>(Application.class));
        //Create an application object and return it
        Application app = (Application) queryForObject;
        return app;
    } catch (EmptyResultDataAccessException e) {
        //if no results returned , create an empty application and sent it
        Application app = new Application(0, 0, 0, "", "", 0, "", 0, 0, "");
        return app;
    }
}

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

public void setDataSource(DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.setFetchSize(500);
}

From source file:com.dai.dao.PerfilDaoImpl.java

public void inserirPerfil(Perfil perfil) {
    JdbcTemplate template = new JdbcTemplate(dataSource);
    String sql = "INSERT INTO perfil " + "(designacaoPerfil) VALUES (?)";

    template.update(sql, new Object[] { perfil.getDesignacao() });
}

From source file:com.springsource.greenhouse.events.JdbcEventRepositoryTest.java

@Before
public void setup() {
    db = new GreenhouseTestDatabaseBuilder().member().group().activity().invite().venue().event()
            .testData(getClass()).getDatabase();
    jdbcTemplate = new JdbcTemplate(db);
    eventRepository = new JdbcEventRepository(jdbcTemplate);
}