// must create connection
Connection connection = datasource.getConnection();
localConnection.set(connection);
return connection;
} catch (SQLException ex) {
throw new DatabaseException("Cannot obtain a new connection (" + ex.getMessage() + ")", ex);
} catch (NullPointerException e) {
if (datasource == null) {
throw new DatabaseException("No database found. Check the configuration of your application.", e);
}
throw e;
}
}