MCPcopy Create free account
hub / github.com/BeichenDream/InjectJDBC / main

Method main

src/com/abc/Main.java:22–45  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

20 private static HashMap dbConnMap=new HashMap();
21 private static String outFile;
22 public static void main(String[] args) throws Throwable{
23 if (args.length == 0){
24 help();
25 return;
26 }
27 Class.forName("sun.tools.attach.HotSpotAttachProvider");
28 String option = args[0].trim();
29 if ("list".equals(option)){
30 List<VirtualMachineDescriptor> vms = VirtualMachine.list();
31 System.out.println("vm count: " + vms.size());
32 for (int i = 0; i < vms.size(); i++) {
33 VirtualMachineDescriptor vm = vms.get(i);
34 System.out.println(String.format("pid: %s displayName:%s",vm.id(),vm.displayName()));
35 }
36 }else if ("inject".equals(option) && args.length >= 2){
37 String targetPid = args[1];
38 String outFile = args[2];
39 VirtualMachine virtualMachine = VirtualMachine.attach(targetPid);
40 virtualMachine.loadAgent(getJarFileByClass(Main.class),outFile);
41 System.out.println("inject ok!");
42 }else {
43 help();
44 }
45 }
46 public static void help(){
47 System.out.println("java -jar injectDatabase.jar list\n" +
48 "java -jar injectDatabase.jar inject targetPid outFile\n" +

Callers

nothing calls this directly

Calls 2

helpMethod · 0.95
getJarFileByClassMethod · 0.95

Tested by

no test coverage detected