This project creates an outline of how one may implement multithreading and the PostgreSQL JDBC driver to handle incoming requests, connect them to a database, and send a reply.
To run this, you will need a PostgreSQL JDBC driver in your project library, see here to download one. This project was built using the PostgreSQL JDBC 4.2 Driver, 42.2.20.
This project provides a general outline. I have inserted TODO tags where I think you might want to insert your own code, to implement your required functionality.