[英]Why aren't these throw statements giving me a compiler error?
public String runQuery(String q) throws JsonGenerationException, JsonMappingException
{
Graph g = null;
try {
g = jdbcTemplate.query(q, new Neo4jGraphResultSetExtractor());
} catch (DataAccessException e) {
if (e instanceof UncategorizedSQLException)
{
//Invalid cypher query
throw (UncategorizedSQLException)e;
}
else throw e;
}
json = g.toJson(); //throws JsonGenerationException, JsonMappingException
return json;
}
編譯器不應該要求此方法還引發UncategorizedSQLException
, DataAccessException
嗎?
因為它們是運行時異常,所以未經檢查就意味着編譯器不需要顯式捕獲它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.