Java Code Examples for org.springframework.jdbc.core.simple.SimpleJdbcTemplate

The following examples show how to use org.springframework.jdbc.core.simple.SimpleJdbcTemplate. These examples are extracted from open source projects. 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 Project: openid4java   Source File: JdbcNonceVerifierTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public NonceVerifier createVerifier(int maxAge) {
	DataSource dataSource = new SingleConnectionDataSource(
			"org.hsqldb.jdbcDriver",
			"jdbc:hsqldb:mem:saasstore_security_client", "sa", "", true);
	SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
	jdbcTemplate.getJdbcOperations().execute(
			"DROP TABLE IF EXISTS openid_nonce;");
	jdbcTemplate
			.getJdbcOperations()
			.execute(
					"CREATE TABLE openid_nonce (  "
							+ "opurl varchar(255) NOT NULL,  nonce varchar(25) NOT NULL,  "
							+ "date datetime DEFAULT NULL,  PRIMARY KEY (opurl,nonce))");

	JdbcNonceVerifier jdbcNonceVerifier = new JdbcNonceVerifier(maxAge,
			"openid_nonce");
	jdbcNonceVerifier.setDataSource(dataSource);
	return jdbcNonceVerifier;
}
 
Example 2
@Autowired
public void init(DataSource dataSource) {
	this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);

	this.insertOwner = new SimpleJdbcInsert(dataSource)
		.withTableName("owners")
		.usingGeneratedKeyColumns("id");
	this.insertPet = new SimpleJdbcInsert(dataSource)
		.withTableName("pets")
		.usingGeneratedKeyColumns("id");
	this.insertVisit = new SimpleJdbcInsert(dataSource)
		.withTableName("visits")
		.usingGeneratedKeyColumns("id");
}
 
Example 3
Source Project: ankush   Source File: UserDaoJpa.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String getUserPassword(String username) {
	SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
	Table table = AnnotationUtils.findAnnotation(User.class, Table.class);
	return jdbcTemplate.queryForObject(
			"select password from " + table.name() + " where username=?",
			String.class, username);
}
 
Example 4
public void setDataSource(DataSource dataSource) {
	this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
 
Example 5
@Override
protected void onSetUpBeforeTransaction() throws Exception {
	SimpleJdbcTemplate template = new SimpleJdbcTemplate((DataSource)applicationContext.getBean("dataSource"));
	template.update(DDL);
}
 
Example 6
Source Project: plow   Source File: AbstractTest.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public SimpleJdbcTemplate jdbc() {
    return simpleJdbcTemplate;
}
 
Example 7
Source Project: maven-framework-project   Source File: ContactDAO.java    License: MIT License 4 votes vote down vote up
public ContactDAO(DataSource dataSource) {
    this.template = new SimpleJdbcTemplate(dataSource);
    this.insertContact = new SimpleJdbcInsert(dataSource).withTableName("CONTACT").usingGeneratedKeyColumns("ID");
}
 
Example 8
Source Project: maven-framework-project   Source File: IndustryDAO.java    License: MIT License 4 votes vote down vote up
@Autowired
public IndustryDAO(DataSource dataSource) {
    this.template = new SimpleJdbcTemplate(dataSource);
    this.insertIndustry = new SimpleJdbcInsert(dataSource).withTableName("INDUSTRY").usingGeneratedKeyColumns("ID");
}
 
Example 9
Source Project: maven-framework-project   Source File: CompanyDAO.java    License: MIT License 4 votes vote down vote up
@Autowired
public CompanyDAO(DataSource dataSource, IIndustryDAO industryDAO) {
    this.template = new SimpleJdbcTemplate(dataSource);
    this.insertCompany = new SimpleJdbcInsert(dataSource).withTableName("COMPANY").usingGeneratedKeyColumns("ID");
    this.industryDAO = industryDAO;
}