import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class OracleConnectionStringParser {
public static void parseConnectionString(String connectionString) {
String regex = "\\(HOST =([^)]+)\\)\\(PORT =([^)]+)\\)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(connectionString);
while (matcher.find()) {
String ip = matcher.group(1).trim();
int port = Integer.parseInt(matcher.group(2).trim());
System.out.println("IP Address: " + ip + ", Port: " + port);
}
}
public static void main(String[] args) {
String connectionString = "User ID=111;Password=222;Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST =10.1.1.1)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST =10.1.1.2)(PORT = 1521)))(CONNECT_DATA =(SERVER = 123)(SERVICE_NAME = 333)(FAILOVER_MODE =(TYPE = SESSION)(METHOD =BASIC)(RETRIES = 2)(DELAY = 1))))";
parseConnectionString(connectionString);
}
}