Linking Tomcat to MYSQL on Openshift

I’ve a java web application running on openshift 3 online.
I’m rather new to this platform and not familiar to the usage of service and pods.

So currently i have 2 containers running.
A. Web app
B. MYSQL

I’ve created environment variables to supply the MYSQL username,password,port and ip-address to the container A running the web application. However, it seem like when openshift creates a new pod, the ip-address changes. Is there any other way i could link the two container so that i don’t have to rely on the ip-address?

Each service has a name/domain name. You should use their name to specify their location, rather than the IP address. Internally, the name will be resolved to the IP address.

You can find the name in the service details in the web console.