Connecting String for jdbc connection load balancing


We have a requirement to route requests to multiple backends based on the connection string of a datasource url.
The bottleneck is that on haproxy all these requests would be listened on a port say 31000 and then based on the name of the datasource in the connection string has to be distributed to a different backend.
We can achieve this by listening on different ports but it is mandatory that all requests would listen on same port and the routing has to be based on some other paramater like the datasource name in the connection url