OracleConnectionStringParser

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);

}

}

相关推荐
k***19539 分钟前
Tomcat的升级
java·tomcat
j***49562 小时前
Windows操作系统部署Tomcat详细讲解
java·windows·tomcat
草莓熊Lotso2 小时前
unordered_map/unordered_set 使用指南:差异、性能与场景选择
java·开发语言·c++·人工智能·经验分享·python·网络协议
20岁30年经验的码农4 小时前
Spring Cloud Gateway 网关技术文档
java
likuolei5 小时前
XML DOM 节点类型
xml·java·服务器
ZHE|张恒6 小时前
Spring Bean 生命周期
java·spring
q***38518 小时前
SpringCloud实战十三:Gateway之 Spring Cloud Gateway 动态路由
java·spring cloud·gateway
小白学大数据8 小时前
Python爬虫伪装策略:如何模拟浏览器正常访问JSP站点
java·开发语言·爬虫·python
程序员西西9 小时前
SpringBoot接口安全:APIKey保护指南
java·spring boot·计算机·程序员·编程·编程开发
summer_west_fish9 小时前
单体VS微服务:架构选择实战指南
java·微服务·架构