Using external service

My bad if this is already covered in the forum but I couldn’t find any topic that correlates with my question.
I created an external service, i.e a database with hostname and port that is located outside of rancher. Now I have a container that I want to connect to this database. When creating a new service I can under the ‘Service link’ add my database. My question is how in my application can get the hostname and IP of the external service?

Do I fetch it from an environment variable? For example: System.getenv(“database name”) ?

It’s available via Rancher DNS, which your container is configured to use by default. So, you container will be able to access it using the hostname that you specified in the “As name” field in the service link.

thanks @cjellick, exactly what I was looking for