Java源码示例:org.springframework.jdbc.core.simple.SimpleJdbcTemplate

示例1
@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;
}
 
示例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");
}
 
示例3
/**
 * {@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);
}
 
示例4
public void setDataSource(DataSource dataSource) {
	this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
 
示例5
@Override
protected void onSetUpBeforeTransaction() throws Exception {
	SimpleJdbcTemplate template = new SimpleJdbcTemplate((DataSource)applicationContext.getBean("dataSource"));
	template.update(DDL);
}
 
示例6
@SuppressWarnings("deprecation")
public SimpleJdbcTemplate jdbc() {
    return simpleJdbcTemplate;
}
 
示例7
public ContactDAO(DataSource dataSource) {
    this.template = new SimpleJdbcTemplate(dataSource);
    this.insertContact = new SimpleJdbcInsert(dataSource).withTableName("CONTACT").usingGeneratedKeyColumns("ID");
}
 
示例8
@Autowired
public IndustryDAO(DataSource dataSource) {
    this.template = new SimpleJdbcTemplate(dataSource);
    this.insertIndustry = new SimpleJdbcInsert(dataSource).withTableName("INDUSTRY").usingGeneratedKeyColumns("ID");
}
 
示例9
@Autowired
public CompanyDAO(DataSource dataSource, IIndustryDAO industryDAO) {
    this.template = new SimpleJdbcTemplate(dataSource);
    this.insertCompany = new SimpleJdbcInsert(dataSource).withTableName("COMPANY").usingGeneratedKeyColumns("ID");
    this.industryDAO = industryDAO;
}