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:kramer.ExecuteScriptDataSource.java

public void afterPropertiesSet() throws Exception {
    new JdbcTemplate(this).execute(script);
}

From source file:org.wso2.carbon.metrics.data.service.MetricsDataServiceTest.java

public static Test suite() {
    return new TestSetup(new TestSuite(MetricsDataServiceTest.class)) {

        protected void setUp() throws Exception {
            DataSource dataSource = JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "");
            template = new JdbcTemplate(dataSource);
            ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
            populator.addScript(new ClassPathResource("dbscripts/h2.sql"));
            populator.populate(dataSource.getConnection());

            // Create initial context
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
            System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
            InitialContext ic = new InitialContext();
            ic.createSubcontext("jdbc");
            ic.bind("jdbc/WSO2MetricsDB", dataSource);
        }//from w  w w .  j  a  v  a  2s.co m

        protected void tearDown() throws Exception {
            InitialContext ic = new InitialContext();
            ic.unbind("jdbc/WSO2MetricsDB");
            ic.unbind("jdbc");
        }
    };
}

From source file:org.paxml.util.DBUtils.java

public static int[] runSqlResource(DataSource ds, String uri) {
    JdbcTemplate temp = new JdbcTemplate(ds);
    List<String> list = DBUtils.breakSql(PaxmlUtils.readResourceToString(uri, null));
    return temp.batchUpdate(list.toArray(new String[list.size()]));

}

From source file:com.dojo.parkinglot.dao.VehicleDaoImpl.java

@Autowired
public void setDataSource(DataSource dataSource) {
    template = new JdbcTemplate(dataSource);
    insert_vehicle = new SimpleJdbcInsert(dataSource).withTableName(VEHICLES_TABLE)
            .usingColumns("licensePlate", "type").usingGeneratedKeyColumns("id");
}

From source file:factory.JdbcTemplateFactory.java

public static JdbcTemplate getProjectDBTemplate() throws SQLException {
    String project_db_user = Configuration.getConfig_properties().getProperty("project.db.user");
    String project_db_passwd = Configuration.getConfig_properties().getProperty("project.db.password");
    String project_db_url = Configuration.getConfig_properties().getProperty("project.db.url");

    OracleDataSource dataSource = new OracleDataSource();
    dataSource.setUser(project_db_user);
    dataSource.setPassword(project_db_passwd);
    dataSource.setURL(project_db_url);/*from ww  w. j a v a2  s .c om*/
    return new JdbcTemplate(dataSource);
}

From source file:com.rplt.studioMusik.studioMusik.StudioMusikDAO.java

@Override
public void simpanData(StudioMusik pStudioMusik) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    String sql = "INSERT INTO studio_musik VALUES(?, ?, ?, ?, ?)";

    jdbcTemplate.update(sql, new Object[] { pStudioMusik.getmKodeStudio(), pStudioMusik.getmNamaStudio(),
            pStudioMusik.getmTarifPerJam(), pStudioMusik.getmJamBuka(), pStudioMusik.getmJamTutup() });
}

From source file:com.beezas.dao.DiscountDaoImpl.java

public DiscountDaoImpl(DataSource dataSource) {
    jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:org.camelcookbook.transactions.dao.MessageDao.java

public MessageDao(DataSource dataSource) {
    jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:org.camelcookbook.transactions.dao.AuditLogDao.java

public AuditLogDao(DataSource dataSource) {
    jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:org.cloudfoundry.identity.uaa.audit.JdbcAuditService.java

public JdbcAuditService(DataSource dataSource) {
    this.template = new JdbcTemplate(dataSource);
}