I have the following expression:
<bean class="java.net.InetAddress" id="inetAddress" />
<bean id="dataSource"
class="org.apache.tomcat.jdbc.pool.DataSource"
p:driverClassName="org.postgresql.Driver"
p:url="#{'jdbc:postgresql://' + inetAddress.getLocalHost().getHostName()=='alex-HP-290-G1-SFF-Business-PC'?'localhost':'172.18.0.2' + ':5432/infostock'}"/>
This expression
inetAddress.getLocalHost().getHostName()=='alex-HP-290-G1-SFF-Business-PC'?'localhost':'172.18.0.2'
must compare hostname-value (retrieved from getHostName) with 'alex-HP-290-G1-SFF-Business-PC'. If true, it returns 'localhost', otherwise '172.18.0.2'.
Actual value of hostname is 'alex-HP-290-G1-SFF-Business-PC'. I get this from:
System.out.println(InetAddress.getLocalHost().getHostName());
So, ternary operator must return 'localhost'
But it returns '172.18.0.2'.