How to Parse the database Connection String for IPV4 and IPV6

Viewed 1797

Im trying to parse the bunch of url.I tried using the URI class in java but it is not perfect for the different set of strings. And also i have to do the parsing on IPV6.The input strings is given below.

jdbc:postgresql:database
jdbc:postgresql://host/database
jdbc:postgresql://host:port/database
jdbc:postgresql://host:port/database?user=userName&password=pass
jdbc:postgresql://host:port/database?charSet=LATIN1&compatible=7.2

jdbc:postgresql://[::1]:5740/accounting (IPV6)

I want the hostname,port,and database name.

Guide me !

1 Answers
Related