shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.walker.jdbc;
 
import com.walker.jdbc.ds.DefaultDataSource;
import com.walker.jdbc.util.TextUtils;
import org.junit.Test;
 
public class TestJdbc {
 
//    @Test
    public void testDataSource(){
        DefaultDataSource dataSource = new DefaultDataSource();
        if(dataSource instanceof DataSourceMeta){
            System.out.println("dataSource is 'DataSourceMeta'!");
        } else {
            System.out.println("failed!");
        }
    }
 
//    @Test
    public void testParseIpAndPort(){
        String jdbcUrl = "jdbc:dm://192.168.100.100:5236?SCHEMA=SYSDBA";
//        String jdbcUrl = "jdbc:mysql://193.193.193.236:3306/cpmsxc?serverTimezone=Asia/Shanghai";
//        String jdbcUrl = "jdbc:oracle:thin:@61.163.210.202:6021/orcl";
        String[] ipAndPortAndService = TextUtils.parseIpAndPortFromUrl(jdbcUrl);
        if(ipAndPortAndService != null){
            System.out.println("ip = " + ipAndPortAndService[0]);
            System.out.println("port = " + ipAndPortAndService[1]);
            System.out.println("dbName = " + ipAndPortAndService[2]);
        }
    }
}