Class.forName(driverClass) not running
滿天的星座
滿天的星座 2017-05-17 10:08:27
0
6
684

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

滿天的星座
滿天的星座

reply all(6)
刘奇

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.

为情所困

YourClass.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"

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!