SQL Database Function Implementation in Java