public CachedRowSet execute(String asql) throws ServiceUnavailableException {
try (Connection connection = getDatabaseConnection();
Statement statement = connection.createStatement();) {
try (ResultSet resultSet = statement.executeQuery(asql);
CachedRowSet rowset = CachedRowSetFactory.getCachedRowSet()) {
rowset.populate(resultSet);
return rowset;
}
} catch (SQLException se) {
throw new ServiceUnavailableException("Database broken " + se);
} catch (Exception ne) {
throw new ServiceUnavailableException("JNDI Lookup broken ");
}
return null;
}
大家好。我有一个如上所示的示例代码。问题是返回的rowset总是为空,即使数据库中有大量数据。 有什么建议?谢谢。