I think I briefly explain my problem.
What I have is a java JNLP program that connects to a PostgreSQL backend. A user will login using their assigned credentials. Internally, the program knows the master (and only) DB user. This internal DB user can query the database will check the user's entered username and password from a DB table program_users. If this passes, then window becomes visible and allows the user to continue. All queries in this program are also using the master DB user but the user can not run any queries unless they are authenticated.
The issue is that this requires that the DB port be open to enable the user to connect. Is there a way to use tomcat6 like you can do with a web application and use j_security_check? If this is possible, I would like to avoid opening a postgres port such as port 5432 and just use https port 443 or with tomcat6, use 8443.