List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate
public JdbcTemplate(DataSource dataSource)
From source file:com.thoughtworks.go.server.database.DbDeployMigration.java
private void upgradeWithDbDeploy() { LOG.info("Upgrading database at {}. This might take a while depending on the size of the database.", dataSource);/*from w w w . ja va 2 s . c o m*/ List<String> messages = Arrays.asList(StringUtils.repeat("*", "", 72), "WARNING: Shutting down your server at this point will lead to a database corruption. Please wait until the database upgrade completes.", StringUtils.repeat("*", "", 72)); for (String message : messages) { System.err.println(message); LOG.info(message); } File upgradePath = env.getDBDeltasPath(); bombUnless(upgradePath.exists(), "Database upgrade scripts do not exist in directory " + upgradePath.getAbsolutePath()); InMemory dbDeploy = new InMemory(dataSource, new HsqlDbmsSyntax(), upgradePath, "DDL"); try { String migrationSql = dbDeploy.migrationSql(); new JdbcTemplate(dataSource).execute(migrationSql); System.err.println("Database upgrade completed successfully."); LOG.info("Database upgrade completed."); } catch (Exception e) { String message = "Unable to create database upgrade script for database " + dataSource.getUrl() + ". The problem was: " + e.getMessage(); if (e.getCause() != null) { message += ". The cause was: " + e.getCause().getMessage(); } LOG.error(message, e); System.err.println(message); e.printStackTrace(System.err); throw bomb(message, e); } }
From source file:org.cloudfoundry.identity.uaa.oauth.approval.JdbcApprovalStoreTests.java
@Before public void createDatasource() { template = new JdbcTemplate(dataSource); dao = new JdbcApprovalStore(template, new JdbcPagingListFactory(template, limitSqlAdapter), new SimpleSearchQueryConverter()); addApproval("u1", "c1", "uaa.user", 6000, APPROVED); addApproval("u1", "c2", "uaa.admin", 12000, DENIED); addApproval("u2", "c1", "openid", 6000, APPROVED); }
From source file:uk.ac.kcl.it.PostGresTestUtils.java
@PostConstruct public void init() { this.sourceTemplate = new JdbcTemplate(sourceDataSource); this.targetTemplate = new JdbcTemplate(targetDataSource); JdbcTemplate jobRepoTemplate = new JdbcTemplate(jobRepositoryDataSource); }
From source file:org.jasig.cas.web.support.InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapterTests.java
@Before public void setUp() throws Exception { new JdbcTemplate(dataSource) .execute("CREATE TABLE COM_AUDIT_TRAIL ( " + "AUD_USER VARCHAR(100) NOT NULL, " + "AUD_CLIENT_IP VARCHAR(15) NOT NULL, " + "AUD_SERVER_IP VARCHAR(15) NOT NULL, " + "AUD_RESOURCE VARCHAR(100) NOT NULL, " + "AUD_ACTION VARCHAR(100) NOT NULL, " + "APPLIC_CD VARCHAR(5) NOT NULL, " + "AUD_DATE TIMESTAMP NOT NULL)"); }
From source file:com.beezas.dao.DiscountDaoImpl.java
public List<TicketType> getTickettype() { List tcicketList = new ArrayList(); String sql = "select ticket_type from ticket"; jdbcTemplate = new JdbcTemplate(dataSource); tcicketList = jdbcTemplate.query(sql, new TicketTypeRowMapper()); System.out.println("hai" + tcicketList); return tcicketList; }
From source file:com.seajas.search.attender.service.attender.dao.SettingDAO.java
/** * Initialize the database tables.//from ww w . j av a 2 s . co m * * @param dataSource */ @Autowired public SettingDAO(final DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); try { jdbcTemplate.execute( "CREATE TABLE setting (id INT NOT NULL PRIMARY KEY, name VARCHAR(8196) NOT NULL, value VARCHAR(8196) NOT NULL)"); jdbcTemplate.execute("CREATE SEQUENCE seq_setting AS INTEGER"); } catch (DataAccessException e) { if (logger.isDebugEnabled()) logger.debug("Table 'setting' likely already exists as it could not be created"); } }
From source file:com.rplt.studioMusik.studioMusik.StudioMusikDAO.java
@Override public String getNamaStudio(String pKode) { String namaStudio = ""; String sql = "SELECT nama_studio FROM studio_musik WHERE kode_studio = ?"; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); namaStudio = jdbcTemplate.queryForObject(sql, String.class, pKode); return namaStudio; }
From source file:com.arcane.dao.Impl.PatternDaoImpl.java
@Override public List<Pattern> patternList() { //return all available (occured) patterns LOG.info("Returning all available (occured) patterns"); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "SELECT * from pattern"; List<Pattern> listPattern = jdbcTemplate.query(sql, new RowMapper<Pattern>() { @Override//from ww w . j a v a 2s . c o m public Pattern mapRow(ResultSet rs, int rowNumber) throws SQLException { Pattern pattern = new Pattern(); pattern.setId(rs.getInt("id")); pattern.setName(rs.getString("name")); return pattern; } }); return listPattern; }
From source file:org.ohmage.query.impl.Query.java
/** * Builds this query object by keeping track of the DataSource that was * used to create it and creates a JDBC template for subclasses to use when * querying the database.// w ww. j av a2s . c om * * All subclasses must be Singletons in that all subsequent invocations of * this constructor will throw an IllegalStateException. * * @param dataSource The DataSource to use to query the database. * * @throws IllegalArgumentException Thrown if the 'dataSource' is null. * * @throws IllegalStateException Thrown if someone attempts to instantiate * this class again. All subclasses must be * Singletons. */ protected Query(DataSource dataSource) { if (dataSource == null) { throw new IllegalArgumentException("The data source cannot be null."); } else if (initialized) { throw new IllegalStateException( "A Query should be built exactly once by Spring when the server is initialized."); } this.dataSource = dataSource; jdbcTemplate = new JdbcTemplate(dataSource); initialized = true; }
From source file:eu.trentorise.smartcampus.permissionprovider.oauth.AutoJdbcTokenStore.java
protected void initSchema(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.execute(createAccessTokenStatement); jdbcTemplate.execute(createRefreshTokenStatement); }