How to create an alias for IP address for JDBC connection

aliasMySQLNetwork

I have the “db” alias in my JDBC connection specified in the Java properties file for MYSQL. This alias does not currently work on my local computer.

I would like not to change the properties file but instead of this create the alias “db” that will work the same as IP address for JDBC connection. Is it possible?

I am on OS X Mavericks

Best Answer

Add the alias to the file /etc/hosts with a line like this:

123.123.123.123 db

Where 123.123.123.123 should be substituted with your IP-address and db must match the name given as alias in the JDBC connection.

After editing the file, run the following command in the Terminal:

sudo killall -HUP mDNSResponder

This will reload the hosts file.