Insert user IP Address into MySql table using Prepared Statement in java

If you want to get the IP then Instead of use :

preparedStatement.setString(1, ipaddress);

Use:

// this will return the IP Host Adresse for example 192.168.1.2
preparedStatement.setString(1, ipaddress.getHostAddress());