Hello , I met mysql jdbc load issue in Tomcat servlet , I also pasted the content in this stackoverflow <https://stackoverflow.com/questions/45725610/tomcat-jdbc-drivermanager-initial-load-issue> .
I finally found this code snippet in the tomcat70 code<https://github.com/apache/tomcat70/blob/c1a62522e9a6cd6625f026e4197b490ef1beaa78/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java> and did the debug in eclipse. The classloader to load DriverManager is always the AppClassLoader which contains only the bootstrap.jar and tomcat-juli.jar on the CLASSPATH only (under ${catalina.home}/bin . So my servlet has to manually call Class.forName("com.mysql.jdbc.Driver") , otherwise the call to DriverManager.getConnection("jdbc:mysql://xxx") will throw "no suitable driver found" exception. My questions: 1. is my understanding true ? 2. The manual or the stackoverflow said put the mysql-connector.jar under ${catalina.home}/lib which will be initialized once and should work for the DriverManager case. Is it not correct now ? try { // Use the system classloader as the victim for all this // ClassLoader pinning we're about to do. Thread.currentThread().setContextClassLoader( ClassLoader.getSystemClassLoader()); /* * First call to this loads all drivers in the current class * loader */ if (driverManagerProtection) { DriverManager.getDrivers(); } My enviroment: C:\Users\xxxx\Desktop\Tools\apache-tomcat-7.0.78-windows-x64\apache-tomcat-7.0.78\bin>version.bat Using CATALINA_BASE: "C:\Users\aisun\Desktop\Tools\apache-tomcat-7.0.78-windows-x64\apache-tomcat-7.0.78" Using CATALINA_HOME: "C:\Users\aisun\Desktop\Tools\apache-tomcat-7.0.78-windows-x64\apache-tomcat-7.0.78" Using CATALINA_TMPDIR: "C:\Users\aisun\Desktop\Tools\apache-tomcat-7.0.78-windows-x64\apache-tomcat-7.0.78\temp" Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_131" Using CLASSPATH: "C:\Users\aisun\Desktop\Tools\apache-tomcat-7.0.78-windows-x64\apache-tomcat-7.0.78\bin\bootstrap.jar;C:\Users\aisun\Desktop\Tools\apache-tomcat-7.0.78-windows-x64\ap Server version: Apache Tomcat/7.0.78 Server built: May 10 2017 15:02:19 UTC Server number: 7.0.78.0 OS Name: Windows 7 OS Version: 6.1 Architecture: amd64 JVM Version: 1.8.0_131-b11 JVM Vendor: Oracle Corporation C:\Users\aisun\Desktop\Tools\apache-tomcat-7.0.78-windows-x64\apache-tomcat-7.0.78\bin> Thanks very much. Keith