functional version
functional version with JDBC