List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate
public JdbcTemplate(DataSource dataSource)
From source file:org.apache.shiro.samples.sprhib.dao.BootstrapDataPopulator.java
public void afterPropertiesSet() throws Exception { //because we're using an in-memory hsqldb for the sample app, a new one will be created each time the //app starts, so insert the sample admin user at startup: JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource); jdbcTemplate.execute("insert into roles values (1, 'user', 'The default role given to all users.')"); jdbcTemplate.execute(/*from w w w . j a v a 2 s . c om*/ "insert into roles values (2, 'admin', 'The administrator role only given to site admins')"); jdbcTemplate.execute("insert into roles_permissions values (2, 'user:*')"); jdbcTemplate.execute( "insert into users(id,username,email,password) values (1, 'admin', 'sample@shiro.apache.org', '" + new Sha256Hash("admin").toHex() + "')"); jdbcTemplate.execute("insert into users_roles values (1, 2)"); }
From source file:edu.jhuapl.openessence.web.util.MapQueryUtil.java
public Timestamp performCurrentTimestampQuery() { JdbcTemplate pgdb = new JdbcTemplate(mapDataSource); return pgdb.queryForObject("select current_timestamp", Timestamp.class); }
From source file:info.smartkit.hairy_batman.config.DbConfiguration.java
@Bean public JdbcTemplate jdbcTemplate(DataSource dataSource) { // JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); GlobalVariables.jdbcTempate = new JdbcTemplate(dataSource); return GlobalVariables.jdbcTempate; }
From source file:com.recber.dao.UserDaoImpl.java
@Override public User getUser(String id) { List<User> userList = new ArrayList<User>(); String sql = "select * from user where user_id= " + id; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); userList = jdbcTemplate.query(sql, new UserRowMapper()); return userList.get(0); }
From source file:com.emc.ecs.sync.source.DbListFilesystemSource.java
@Override public Iterator<FileSyncObject> iterator() { return new ReadOnlyIterator<FileSyncObject>() { JdbcTemplate jdbc;/* w w w .java 2 s .co m*/ SqlRowSet rs; @Override protected FileSyncObject getNextObject() { if (rs == null) { jdbc = new JdbcTemplate(dataSource); rs = jdbc.queryForRowSet(selectQuery); } if (rs.next()) { File file = new File(rs.getString(filenameColumn)); FileSyncObject object = new FileSyncObject(DbListFilesystemSource.this, new MimetypesFileTypeMap(), file, getRelativePath(file), isFollowLinks()); if (metadataColumns != null) { for (String colName : metadataColumns) { String value = rs.getString(colName); if (value != null) { object.getMetadata().setUserMetadataValue(colName, value); } } } return object; } else { // no more results return null; } } }; }
From source file:com.emc.vipr.sync.source.DbListFilesystemSource.java
@Override public Iterator<FileSyncObject> iterator() { return new ReadOnlyIterator<FileSyncObject>() { JdbcTemplate tmpl;// ww w .j a v a 2s . co m SqlRowSet rs; @Override protected FileSyncObject getNextObject() { if (rs == null) { tmpl = new JdbcTemplate(dataSource); rs = tmpl.queryForRowSet(selectQuery); } if (rs.next()) { File file = new File(rs.getString(filenameColumn)); FileSyncObject object = new FileSyncObject(DbListFilesystemSource.this, new MimetypesFileTypeMap(), file, getRelativePath(file)); if (metadataColumns != null) { for (String colName : metadataColumns) { String value = rs.getString(colName); if (value != null) { object.getMetadata().setUserMetadataValue(colName, value); } } } return object; } else { // no more results return null; } } }; }
From source file:com.team3637.service.MatchServiceMySQLImpl.java
@Override public void setDataSource(DataSource dataSource) { this.jdbcTemplateObject = new JdbcTemplate(dataSource); this.addCols = new SimpleJdbcCall(dataSource).withProcedureName("addCols"); this.addTag = new SimpleJdbcCall(dataSource).withProcedureName("addTag"); this.mergeTags = new SimpleJdbcCall(dataSource).withProcedureName("mergeTags"); }
From source file:zerogame.info.javapay.web.PayOrderCallBackTest.java
@Autowired public void setDataSource(DataSource dataSource) { template = new JdbcTemplate(dataSource); }
From source file:com.surevine.chat.openfire.audit.dao.JdbcAuditDAO.java
/** * Constructs an <code>JdbcAuditDAO</code> with the {@link DataSource} * reference that will provide connections for audit persistence operations. * * @param dataSource//from w ww . j ava2 s . c o m * The data source to persist to. */ public JdbcAuditDAO(final DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); }
From source file:org.springsource.examples.expenses.TestDatabaseChargeService.java
@After public void tearDown() throws Throwable { JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource); jdbcTemplate.execute("TRUNCATE TABLE CHARGE"); }