It also depends on where your application gets its database connections from.
If it is running inside an application server, it most likely gets database connections from a connection pool managed by the application server (i.e., you're not opening connections yourself using DriverManager, but you're using a DataSource object provided by the appserver). In that case,
you should release (close) each connection as soon as you're done with it, and not hold it for a longer time, otherwise you'll be harming the scalability of your application.
If it's a standalone application that directly opens database connections, it would be better to not close the connection immediately.