stats: use db exceptions and parameters