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

The following examples show how to use org.springframework.jdbc.core.simple.SimpleJdbcTemplate. 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: JdbcNonceVerifierTest.java    From openid4java with 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
Source File: SimpleJdbcClinic.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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 File: UserDaoJpa.java    From ankush with 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
Source File: JdbcCarPartsInventoryImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void setDataSource(DataSource dataSource) {
	this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
 
Example #5
Source File: AbstractCarPartsInventoryTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected void onSetUpBeforeTransaction() throws Exception {
	SimpleJdbcTemplate template = new SimpleJdbcTemplate((DataSource)applicationContext.getBean("dataSource"));
	template.update(DDL);
}
 
Example #6
Source File: AbstractTest.java    From plow with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public SimpleJdbcTemplate jdbc() {
    return simpleJdbcTemplate;
}
 
Example #7
Source File: ContactDAO.java    From maven-framework-project with 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 File: IndustryDAO.java    From maven-framework-project with 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 File: CompanyDAO.java    From maven-framework-project with 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;
}