當前位置: 首頁>>代碼示例>>Java>>正文


Java EmptyResultDataAccessException類代碼示例

本文整理匯總了Java中org.springframework.dao.EmptyResultDataAccessException的典型用法代碼示例。如果您正苦於以下問題:Java EmptyResultDataAccessException類的具體用法?Java EmptyResultDataAccessException怎麽用?Java EmptyResultDataAccessException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EmptyResultDataAccessException類屬於org.springframework.dao包,在下文中一共展示了EmptyResultDataAccessException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDependencies

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
public static void getDependencies(
		Long datasetId,
		List<DatasetDependency> depends)
{
	String nativeName = null;
	try
	{
		nativeName = getJdbcTemplate().queryForObject(
				GET_DATASET_NATIVE_NAME,
				String.class,
				datasetId);
	}
	catch (EmptyResultDataAccessException e)
	{
		nativeName = null;
	}

	if (StringUtils.isNotBlank(nativeName))
	{
		getDatasetDependencies("/" + nativeName.replace(".", "/"), 1, 0, depends);
	}

}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:24,代碼來源:DatasetsDAO.java

示例2: getReferences

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
public static void getReferences(
		Long datasetId,
		List<DatasetDependency> references)
{
	String nativeName = null;
	try
	{
		nativeName = getJdbcTemplate().queryForObject(
				GET_DATASET_NATIVE_NAME,
				String.class,
				datasetId);
	}
	catch (EmptyResultDataAccessException e)
	{
		nativeName = null;
	}

	if (StringUtils.isNotBlank(nativeName))
	{
		getDatasetReferences("/" + nativeName.replace(".", "/"), 1, 0, references);
	}

}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:24,代碼來源:DatasetsDAO.java

示例3: getDatasetSchemaTextByVersion

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
public static String getDatasetSchemaTextByVersion(
		Long datasetId, String version)
{
	String schemaText = null;
	try
	{
		schemaText = getJdbcTemplate().queryForObject(
				GET_DATASET_SCHEMA_TEXT_BY_VERSION,
				String.class,
				datasetId, version);
	}
	catch (EmptyResultDataAccessException e)
	{
		schemaText = null;
	}
	return schemaText;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:18,代碼來源:DatasetsDAO.java

示例4: getMetricByID

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
public static Metric getMetricByID(int id, String user)
{
   	Integer userId = UserDAO.getUserIDByUserName(user);
	Metric metric = null;
	try
	{
		metric = (Metric)getJdbcTemplate().queryForObject(
				GET_METRIC_BY_ID,
				new MetricRowMapper(),
         			userId,
				id);
	}
	catch(EmptyResultDataAccessException e)
	{
		Logger.error("Metric getMetricByID failed, id = " + id);
		Logger.error("Exception = " + e.getMessage());
	}

	return metric;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:21,代碼來源:MetricsDAO.java

示例5: getFlowSnapshot

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Override
public FlowSnapshotEntity getFlowSnapshot(final String flowIdentifier, final Integer version) {
    final String sql =
            "SELECT " +
                    "fs.flow_id, " +
                    "fs.version, " +
                    "fs.created, " +
                    "fs.created_by, " +
                    "fs.comments " +
            "FROM " +
                    "flow_snapshot fs, " +
                    "flow f, " +
                    "bucket_item item " +
            "WHERE " +
                    "item.id = f.id AND " +
                    "f.id = ? AND " +
                    "f.id = fs.flow_id AND " +
                    "fs.version = ?";

    try {
        return jdbcTemplate.queryForObject(sql, new FlowSnapshotEntityRowMapper(),
                flowIdentifier, version);
    } catch (EmptyResultDataAccessException e) {
        return null;
    }
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:27,代碼來源:DatabaseMetadataService.java

示例6: getCurrentGithubId

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
public long getCurrentGithubId() {
    KeyHolder keyHolder = new GeneratedKeyHolder();
    String sql = "SELECT stat_id FROM github_stats WHERE stat_date = current_date()";
    long statId = -1;
    try {
        statId = jdbcTemplate.queryForObject(sql, Long.class);
    } catch (EmptyResultDataAccessException e) {

        jdbcTemplate.update(
                new PreparedStatementCreator() {
                    String INSERT_SQL = "INSERT INTO github_stats (stat_date) VALUES (current_date())";
                    public PreparedStatement createPreparedStatement(Connection cn) throws SQLException {
                        PreparedStatement ps = cn.prepareStatement(INSERT_SQL, new String[] {"stat_id"});
                        return ps;
                    }
                },
                keyHolder);
        statId = keyHolder.getKey().longValue();

    }
    logger.info("Current GitHub Stats ID: " + statId);
    return statId;
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:24,代碼來源:GithubJobUI.java

示例7: githubStatRecordKeyReturned

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Test
public void githubStatRecordKeyReturned() throws Exception {
    KeyHolder keyHolder = new GeneratedKeyHolder();
    long statId = -1L;
    try {
        statId = jdbcTemplate.queryForObject("SELECT stat_id FROM github_stats WHERE stat_date = '2010-10-10'", Long.class);
    } catch (EmptyResultDataAccessException e) {

        jdbcTemplate.update(
                new PreparedStatementCreator() {
                    String INSERT_SQL = "INSERT INTO github_stats (stat_date) VALUES ('2010-10-10')";

                    public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                        PreparedStatement ps = connection.prepareStatement(INSERT_SQL, new String[]{"stat_id"});
                        return ps;
                    }
                },
                keyHolder);
        statId = keyHolder.getKey().longValue();
    }

    assertThat(statId).isGreaterThan(0);
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:24,代碼來源:GitHubTests.java

示例8: updateConfigurationValue

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Override
public void updateConfigurationValue(Environment env,
                                     String defaultEnvKey,
                                     String key,
                                     String value) throws DataAccessException {
	Map<String, Object> paramMap = new HashMap<>();
	paramMap.put("config_key", key);
	paramMap.put("config_value", value);
	try {
		// check, whether there is a concrete config value
		paramMap.put("config_env", env.getValue());
		namedParameterJdbcTemplate.queryForObject(this.getQuery, paramMap, new ConfigurationValueRowMapper());
	} catch (EmptyResultDataAccessException e) {
		// no... set the default to update
		LOG.trace("no concrete config value, set the default to update", e);
		paramMap.put("config_env", defaultEnvKey);
	}

	namedParameterJdbcTemplate.update(this.updateQuery, paramMap);
}
 
開發者ID:namics,項目名稱:spring-configuration-support,代碼行數:21,代碼來源:ConfigurationDaoImpl.java

示例9: updateConfigurationValue

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Override
@Transactional(readOnly = false)
public void updateConfigurationValue(Environment env,
                                     String defaultEnvKey,
                                     String key,
                                     String value) throws DataAccessException {
	Map<String, Object> paramMap = new HashMap<>();
	paramMap.put("config_key", key);
	paramMap.put("config_value", value);
	try {
		// check, whether there is a concrete config value
		paramMap.put("config_env", env.getValue());
		namedParameterJdbcTemplate.queryForObject(this.getQuery, paramMap, new ConfigurationValueRowMapper());
	} catch (EmptyResultDataAccessException e) {
		// no... set the default to update
		LOG.trace("no concrete config value, set the default to update", e);
		paramMap.put("config_env", defaultEnvKey);
	}

	namedParameterJdbcTemplate.update(this.updateQuery, paramMap);
}
 
開發者ID:namics,項目名稱:spring-configuration-support,代碼行數:22,代碼來源:ConfigurationDaoJdbcImpl.java

示例10: testSpringLocalTx

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Test
public void testSpringLocalTx() throws Exception {
    DataSource ds = wrap(createHsqlDataSource());
    JdbcTemplate jdbc = new JdbcTemplate(ds);
    TransactionTemplate tx = new TransactionTemplate(new DataSourceTransactionManager(ds));

    jdbc.execute(DROP_USER);
    jdbc.execute(CREATE_TABLE_USER);

    tx.execute(ts -> jdbc.update(INSERT_INTO_USER, 1, "user1"));
    User user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
    assertEquals(new User(1, "user1"), user);
    tx.execute(ts -> jdbc.update(DELETE_FROM_USER_BY_ID, 1));

    tx.execute(ts -> {
        int nb = jdbc.update(INSERT_INTO_USER, 1, "user1");
        ts.setRollbackOnly();
        return nb;
    });
    try {
        user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
        fail("Expected a EmptyResultDataAccessException");
    } catch (EmptyResultDataAccessException e) {
        // expected
    }
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:27,代碼來源:HsqlTest.java

示例11: findByClientIdAndSubject

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Override
@Transactional
public RefreshTokenContext findByClientIdAndSubject(ClientID clientId, Subject subject) {
	Objects.requireNonNull(clientId, "clientId must not be null");
	Objects.requireNonNull(subject, "subject must not be null");
	try {
		RefreshTokenContext context = this.jdbcOperations.queryForObject(this.statementSelectByClientIdAndSubject,
				refreshTokenContextMapper, clientId.getValue(), subject.getValue());
		if (context.isExpired()) {
			this.jdbcOperations.update(this.statementDeleteByToken,
					ps -> ps.setString(1, context.getRefreshToken().getValue()));
			return null;
		}
		return context;
	}
	catch (EmptyResultDataAccessException e) {
		return null;
	}
}
 
開發者ID:vpavic,項目名稱:simple-openid-provider,代碼行數:20,代碼來源:JdbcRefreshTokenStore.java

示例12: findById

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Override
public User findById(Integer id) {

	Map<String, Object> params = new HashMap<String, Object>();
	params.put("id", id);

	String sql = "SELECT * FROM users WHERE id=:id";

	User result = null;
	try {
		result = namedParameterJdbcTemplate.queryForObject(sql, params, new UserMapper());
	} catch (EmptyResultDataAccessException e) {
		// do nothing, return null
	}

	/*
	 * User result = namedParameterJdbcTemplate.queryForObject( sql, params,
	 * new BeanPropertyRowMapper<User>());
	 */

	return result;

}
 
開發者ID:filipebraida,項目名稱:siga,代碼行數:24,代碼來源:UserDaoImpl.java

示例13: registerGlobalAuthentication

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Autowired
public void registerGlobalAuthentication(AuthenticationManagerBuilder auth) throws Exception {
    LOG.info("Registering global user details service");
    auth.userDetailsService(username -> {
        try {
            BillingUser user = billingDao.loadUser(username);
            return new User(
                    user.getUsername(),
                    user.getPassword(),
                    Collections.singletonList(() -> "AUTH")
            );
        } catch (EmptyResultDataAccessException e) {
            LOG.warn("No such user: " + username);
            throw new UsernameNotFoundException(username);
        }
    });
}
 
開發者ID:izaharkin,項目名稱:JavaRestCalculator,代碼行數:18,代碼來源:SecurityServiceConfiguration.java

示例14: loadUser

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
public BillingUser loadUser(String username) throws EmptyResultDataAccessException {
    LOG.trace("Querying for user " + username);
    return jdbcTemplate.queryForObject(
            "SELECT username, password, enabled FROM billing.users WHERE username = ?",
            new Object[]{username},
            new RowMapper<BillingUser>() {
                @Override
                public BillingUser mapRow(ResultSet rs, int rowNum) throws SQLException {
                    return new BillingUser(
                            rs.getString("username"),
                            rs.getString("password"),
                            rs.getBoolean("enabled")
                    );
                }
            }
    );
}
 
開發者ID:izaharkin,項目名稱:JavaRestCalculator,代碼行數:18,代碼來源:BillingDao.java

示例15: findUserByEmail

import org.springframework.dao.EmptyResultDataAccessException; //導入依賴的package包/類
@Override
@Transactional(readOnly = true)
public CalendarUser findUserByEmail(final String email) {
    if (email == null) {
        throw new IllegalArgumentException("email cannot be null");
    }
    try {
        return userRepository.findByEmail(email);
    } catch (EmptyResultDataAccessException notFound) {
        return null;
    }
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:13,代碼來源:JpaCalendarUserDao.java


注:本文中的org.springframework.dao.EmptyResultDataAccessException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。