System.out.println("======1======");
Class.forName(driverClass);
conn = DriverManager.getConnection("xxxx"," xxxx","xxxx");
System.out.println("======2======");
This paragraph is written in try catch without any error
The operation can print out ======1======
But in Class.forName(driverClass); the card owner
cannot print out======2=== ===
There are no errors in the whole process, but the conn cannot be obtained, and it is stuck in Class.forName
The jars are also under the classpath. If classnotfound, it will be caught by exception
Dear, is there something wrong with the compiler? Can you just use the java command to compile and execute it?
Are you sure you have something written in your catch?
Change
Class.forName(driverClass) to
Class.forName(driverClass).newInstance() and try it
It does not prove that it is stuck on the forName method. The probability of getting stuck on the getConnection method is much greater. This is to connect to the database.
Your
Class.forName(driverClass);
First, make sure you specify a specific path for the driverClass class you dynamically load;driverclass needs to be enclosed in double quotes "driverclass"