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
怪我咯2017-05-17 10:10:27
Dear, is there something wrong with the compiler? Can you just use the java command to compile and execute it?
習慣沉默2017-05-17 10:10:27
Change
Class.forName(driverClass) to
Class.forName(driverClass).newInstance() and try it
某草草2017-05-17 10:10:27
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.
为情所困2017-05-17 10:10:27
YourClass.forName(driverClass);
First, make sure you specify a specific path for the driverClass class you dynamically load;