Java Code Examples for org.springframework.jdbc.core.JdbcTemplate#afterPropertiesSet()

The following examples show how to use org.springframework.jdbc.core.JdbcTemplate#afterPropertiesSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUp() throws InterruptedException{
	Thread.sleep(2000);
	template = new JdbcTemplate(applicationContext.getBean(DataSource.class));
	template.afterPropertiesSet();

	template.update(
			"INSERT into TASK_EXECUTION(TASK_EXECUTION_ID, " + "START_TIME, " + "END_TIME, " + "TASK_NAME, "
					+ "EXIT_CODE, " + "EXIT_MESSAGE, " + "LAST_UPDATED," + "ERROR_MESSAGE, "
					+ "EXTERNAL_EXECUTION_ID)" + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)",
			TASK_EXECUTION_ID, startTime, endTime, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, endTime, ERROR_MESSAGE,
			EXTERNAL_EXECUTION_ID);
	template.update(
			"INSERT into TASK_EXECUTION(TASK_EXECUTION_ID, " + "START_TIME, " + "END_TIME, " + "TASK_NAME, "
					+ "EXIT_CODE, " + "EXIT_MESSAGE, " + "LAST_UPDATED," + "ERROR_MESSAGE, "
					+ "EXTERNAL_EXECUTION_ID)" + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)",
			TASK_EXECUTION_ID - 1, startTime, null, TASK_NAME, null, EXIT_MESSAGE, null, ERROR_MESSAGE,
			EXTERNAL_EXECUTION_ID);

	template.update(
			"INSERT into task_deployment(id, object_version, task_deployment_id, task_definition_name, platform_name, created_on) " +
					"values (?,?,?,?,?,?)",
					1, 1, TASK_EXECUTION_ID, TASK_NAME, "default", startTime);

}
 
Example 2
Source File: JobExecutionsDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
	if (!initialized) {
		registerApp(ApplicationType.task, "timestamp", "1.2.0.RELEASE");
		initialize();
		createJobExecution(JOB_NAME, BatchStatus.STARTED);
		createJobExecution(JOB_NAME + "_1", BatchStatus.STOPPED);


		jdbcTemplate = new JdbcTemplate(this.dataSource);
		jdbcTemplate.afterPropertiesSet();
		jdbcTemplate.update(
				"INSERT into task_deployment(id, object_version, task_deployment_id, task_definition_name, platform_name, created_on) " +
						"values (?,?,?,?,?,?)",
				1, 1, "2", JOB_NAME + "_1", "default", new Date());

		documentation.dontDocument(() -> this.mockMvc.perform(
				post("/tasks/definitions")
						.param("name", "DOCJOB_1")
						.param("definition", "timestamp --format='YYYY MM DD'"))
				.andExpect(status().isOk()));

		initialized = true;
	}
}
 
Example 3
Source File: JobCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void tearDown() {
	JdbcTemplate template = new JdbcTemplate(applicationContext.getBean(DataSource.class));
	template.afterPropertiesSet();
	final String TASK_EXECUTION_FORMAT = "DELETE FROM task_execution WHERE task_execution_id = %d";
	final String TASK_BATCH_FORMAT = "DELETE FROM task_task_batch WHERE task_execution_id = %d";

	for (Long id : taskExecutionIds) {
		template.execute(String.format(TASK_BATCH_FORMAT, id));
		template.execute(String.format(TASK_EXECUTION_FORMAT, id));
	}
}
 
Example 4
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void tearDown() {
	JdbcTemplate template = new JdbcTemplate(applicationContext.getBean(DataSource.class));
	template.afterPropertiesSet();
	final String TASK_EXECUTION_FORMAT = "DELETE FROM task_execution WHERE task_execution_id = %d";
	template.execute(String.format(TASK_EXECUTION_FORMAT, TASK_EXECUTION_ID - 1));
	template.execute(String.format(TASK_EXECUTION_FORMAT, TASK_EXECUTION_ID));
}
 
Example 5
Source File: Junit4ExampleApplicationTest.java    From booties with Apache License 2.0 5 votes vote down vote up
@Test
public void contextLoads() {
    assertThat(dataSource).isNotNull();
    JdbcTemplate jdbc = new JdbcTemplate(dataSource);
    jdbc.afterPropertiesSet();
    jdbc.execute(SQL);
}
 
Example 6
Source File: Junit5ExampleApplicationTests.java    From booties with Apache License 2.0 5 votes vote down vote up
@Test
void contextLoads() {
    assertThat(dataSource).isNotNull();
    JdbcTemplate jdbc = new JdbcTemplate(dataSource);
    jdbc.afterPropertiesSet();
    jdbc.execute(SQL);
}
 
Example 7
Source File: DiscardController.java    From minicubes with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value="/dummyMerge", method={RequestMethod.POST, RequestMethod.GET})
public @ResponseBody String mergePrepare(@NotBlank @RequestParam String timeSeries, @RequestParam String sql) {
    
    LOGGER.info("Try to merge data to {}.", sql, timeSeries);
    JdbcTemplate template = new JdbcTemplate(dataSource);
    template.afterPropertiesSet();
    template.execute(sql);
    LOGGER.info("Success for merge data to {}.", sql, timeSeries);
    
    return OK;
}
 
Example 8
Source File: EmptyDatabaseIntegrationTest.java    From embedded-database-spring-test with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.afterPropertiesSet();
}
 
Example 9
Source File: JdbcHttpSessionConfiguration.java    From spring-session with Apache License 2.0 4 votes vote down vote up
private static JdbcTemplate createJdbcTemplate(DataSource dataSource) {
	JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
	jdbcTemplate.afterPropertiesSet();
	return jdbcTemplate;
}
 
Example 10
Source File: TestUtilities.java    From rice with Educational Community License v2.0 4 votes vote down vote up
public static JdbcTemplate getJdbcTemplate() {
	JdbcTemplate jdbcTemplate = new JdbcTemplate(KEWServiceLocator.getDataSource());
	jdbcTemplate.afterPropertiesSet();
	return jdbcTemplate;
}