use of org.springframework.jdbc.core.JdbcTemplate in project camel by apache.
the class JdbcMessageIdRepositoryTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
dataSource = context.getRegistry().lookupByNameAndType("dataSource", DataSource.class);
jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.afterPropertiesSet();
}
use of org.springframework.jdbc.core.JdbcTemplate in project camel by apache.
the class JdbcAggregateStoreAsText method postProcessTest.
@Override
public void postProcessTest() throws Exception {
super.postProcessTest();
repo = applicationContext.getBean("repo3", JdbcAggregationRepository.class);
dataSource = context.getRegistry().lookupByNameAndType("dataSource3", DataSource.class);
jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.afterPropertiesSet();
}
use of org.springframework.jdbc.core.JdbcTemplate in project musiccabinet by hakko.
the class JdbcDatabaseAdministrationDao method setDataSource.
// Spring setters
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
parseJDBCURL();
}
use of org.springframework.jdbc.core.JdbcTemplate in project musiccabinet by hakko.
the class PostgreSQLUtil method truncateTables.
public static void truncateTables(JdbcTemplateDao dao) throws ApplicationException {
JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
jdbcTemplate.execute("truncate music.artist cascade");
jdbcTemplate.execute("truncate library.directory cascade");
jdbcTemplate.execute("truncate music.tag cascade");
jdbcTemplate.execute("truncate music.lastfmuser cascade");
/*
* If we really wanted to truncate all tables, we could do:
* loadFunction(dao, PostgreSQLFunction.TRUNCATE_ALL_TABLES);
* jdbcTemplate.execute("select util.truncate_all_tables()");
*
* Truncating music.artist and library.file reaches pretty much
* everything and is by far faster, though.
*/
}
use of org.springframework.jdbc.core.JdbcTemplate in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method oldInvocationsAreIgnored.
@Test
public void oldInvocationsAreIgnored() {
Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
Track track = new Track("Red Sparowes", "Finally, As That Blazing Sun Shone Down Upon Us, Did We Know That True Enemy Was the Voice of Blind Idolatry; and Only Then Did We Begin to Think for Ourselves.");
WebserviceInvocation similarTrack = new WebserviceInvocation(SIMILAR, track);
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(similarTrack));
dao.logWebserviceInvocation(similarTrack);
assertFalse(dao.isWebserviceInvocationAllowed(similarTrack));
// make the invocation age in database, by updating it.
DateTime dateTime = new DateTime();
JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
for (int days = 1; days <= 14; days++) {
jdbcTemplate.update("update library.webservice_history set invocation_time = ?", new Object[] { dateTime.minusDays(days).toDate() });
boolean isAllowed = dao.isWebserviceInvocationAllowed(similarTrack);
boolean cacheIsInvalid = days > SIMILAR.getDaysToCache();
assertTrue(isAllowed == cacheIsInvalid);
}
}
Aggregations