/** * Test select for update with alias. */ @Test public void testSelectForUpdateWithAlias() { RootContext.bind("mock.xid"); jdbcTemplate.queryForRowSet("select a.name from user0 a where a.id = ? for update", new Object[] {1}); }
/** * Test select for update. */ @Test public void testSelectForUpdate() { RootContext.bind("mock.xid"); jdbcTemplate.queryForRowSet("select a.name from user0 a where a.id = ? for update", new Object[] {1}); }
public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes) throws DataAccessException { return delegate.queryForRowSet(sql, args, argTypes); }
public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes) throws DataAccessException { return delegate.queryForRowSet(sql, args, argTypes); }
private static final String SQL_CREATE_TEST_DB = "CREATE DATABASE test"; private static final String SQL_PROD_TABLES = "SHOW TABLES IN production"; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.execute(SQL_CREATE_TEST_DB); SqlRowSet result = jdbcTemplate.queryForRowSet(SQL_PROD_TABLES); while(result.next()) { String tableName = result.getString(result.getMetaData().getColumnName(1)); //Retrieves table name from column 1 jdbcTemplate.execute("CREATE TABLE test2." + tableName + " LIKE production." + tableName); //Create new table in test2 based on production structure }
@Override public boolean isLockOwner(Object entityId, Principal principal) { if (principal == null) { throw new SecurityException("no principal"); } String sql = "SELECT entity_id from locks where entity_id = ? and lock_owner = ?"; SqlRowSet rs = template.queryForRowSet(sql, entityId.toString(), principal.getName()); return rs.next(); } }
@Override public String validState() { boolean hasData = jdbcTemplate.queryForRowSet( "select datasetid from completedatasetregistration limit 1" ).next(); if ( !hasData ) { return "No complete registrations exist, not updating completeness analytics tables"; } return null; }
@Override public String validState() { boolean hasData = jdbcTemplate.queryForRowSet( "select validationresultid from validationresult limit 1" ).next(); if ( !hasData ) { return "No validation results exist, not updating validation result analytics tables"; } return null; }
protected Date getDbDate() { try { return jdbcTemplate.queryForRowSet(dbDateSql, new Object[0]).getDate(1); } catch (Exception e) { return new Date(); } }
@Override public String validState() { boolean hasData = jdbcTemplate.queryForRowSet( "select dataelementid from trackedentitydatavalue limit 1" ).next(); if ( !hasData ) { return "No events exist, not updating event analytics tables"; } return null; } }
@Override public boolean viewTableExists( String viewTableName ) { try { jdbcTemplate.queryForRowSet( "select * from " + statementBuilder.columnQuote( viewTableName ) + " limit 1" ); return true; } catch ( BadSqlGrammarException ex ) { return false; // View does not exist } }
@Override public boolean isObjectRelation(int templateId, Integer objectId) { logger.debug("IsObjectRelation for templateId: {}, objectId: {}", Arrays.asList(templateId, objectId)); try { SqlRowSet rowSet = this.getJdbcTemplate().queryForRowSet("select * from pn_regex_object where regex_id = ? AND object_id = ?", templateId, objectId); logger.debug("Relation between templateId: {} and objectId: {}, found.", Arrays.asList(templateId, objectId)); return rowSet.next(); } catch (EmptyResultDataAccessException ex) { //This exception signals empty row logger.debug("Relation between templateId: {}, and objectId: {}, not found", Arrays.asList(templateId, objectId)); return false; } }
/** * @see org.kuali.kfs.module.endow.batch.dataaccess.GLInterfaceBatchProcessDao#findDocumentTypes() */ public Collection<String> findDocumentTypes() { LOG.info("findDocumentTypes() started"); Collection<String> documentTypes = new ArrayList<String>(); SqlRowSet documentTypesRowSet = getJdbcTemplate().queryForRowSet("SELECT DISTINCT(DOC_TYP_NM) DOC_TYP_NM FROM END_TRAN_ARCHV_T ORDER BY DOC_TYP_NM"); while (documentTypesRowSet.next()) { documentTypes.add(documentTypesRowSet.getString(EndowPropertyConstants.ColumnNames.GlInterfaceBatchProcessLine.TRANSACTION_ARCHIVE_DOC_TYP_NM)); } LOG.info("findDocumentTypes() exited"); return documentTypes; }
public int account(String sql) throws SQLException { int ret = 0; SqlRowSet sqlRowset = jdbcTemplate.queryForRowSet(sql); if (sqlRowset.next()) { ret = sqlRowset.getInt(1); } return ret; }
private void removeOldPoolMessages(long olderThan) { Set<Integer> proccessedIds = new HashSet<Integer>(); long actualTimeInMillis = new DateTime().getMillis(); SqlRowSet srs = this.getJdbcTemplate().queryForRowSet("SELECT id,created FROM pn_pool_message"); while (srs.next()) { Timestamp timeStamp = srs.getTimestamp("created"); if (timeStamp.getTime() + olderThan < actualTimeInMillis) { proccessedIds.add(srs.getInt("id")); } } removeAllPoolMessages(proccessedIds); } }
@Override public SqlRowSet queryForRowSet(String query, int fetchSize) { JdbcTemplate jdbcTemplate = new StreamingJdbcTemplate(); jdbcTemplate.setDataSource(dataSource); jdbcTemplate.setFetchSize(fetchSize); if(!query.startsWith("select")){ query = "select * from " + query; } return jdbcTemplate.queryForRowSet(query); }
@Override public void populateSqlViewGrid( Grid grid, String sql ) { SqlRowSet rs = readOnlyJdbcTemplate.queryForRowSet( sql ); int maxLimit = (Integer) systemSettingManager.getSystemSetting( SettingKey.SQL_VIEW_MAX_LIMIT ); log.debug( "Get view SQL: " + sql + ", max limit: " + maxLimit ); grid.addHeaders( rs ); grid.addRows( rs, maxLimit ); }
public int account(String sql) throws TinyDbException { try { int ret = 0; SqlRowSet sqlRowset = jdbcTemplate.queryForRowSet(sql); if (sqlRowset.next()) { ret = sqlRowset.getInt(1); } return ret; } catch (DataAccessException e) { throw new TinyDbException(e); } }
private SqlRowSet getRowSet(String id) { JdbcTemplate jdbcTemplate = dbService.getJdbcTemplate(); SqlRowSet rowSet = jdbcTemplate.queryForRowSet("SELECT * FROM " + dbService.getObjectsTableName() + " WHERE source_id=?", id); rowSet.next(); return rowSet; }
private void verifyDb(TestStorage storage) { JdbcTemplate jdbcTemplate = dbService.getJdbcTemplate(); long totalCount = verifyDbObjects(jdbcTemplate, storage, storage.getRootObjects()); SqlRowSet rowSet = jdbcTemplate.queryForRowSet("SELECT count(target_id) FROM " + AbstractDbService.DEFAULT_OBJECTS_TABLE_NAME + " WHERE target_id != ''"); Assert.assertTrue(rowSet.next()); Assert.assertEquals(totalCount, rowSet.getLong(1)); jdbcTemplate.update("DELETE FROM " + AbstractDbService.DEFAULT_OBJECTS_TABLE_NAME); }