如何修復(fù):“在使用池時(shí)找不到JDBC:mysql:/localhost/dbName”錯(cuò)誤?我試圖創(chuàng)建到我的數(shù)據(jù)庫(kù)的連接,當(dāng)我使用主方法測(cè)試我的代碼時(shí),它是無(wú)縫工作的。然而,當(dāng)試圖通過(guò)Tomcat 7訪問(wèn)它時(shí),它失敗了,并出現(xiàn)了錯(cuò)誤:No suitable driver found for jdbc:mysql://localhost/dbname.我用的是池。我在Web-INF/lib和.classpath中添加了MySQL連接器(5.1.15)、DBCP(1.4)和池(1.4.5)庫(kù)。我正在使用EclipseIDE。我的數(shù)據(jù)庫(kù)驅(qū)動(dòng)程序代碼是:import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import org.apache.tomcat.dbcp.dbcp.ConnectionFactory;import org.apache.tomcat.dbcp.dbcp.DriverManagerConnectionFactory;import org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory;import org.apache.tomcat.dbcp.dbcp.PoolingDriver;import org.apache.tomcat.dbcp.pool.impl.GenericObjectPool;public class DatabaseConnector {
public static String DB_URI = "jdbc:mysql://localhost/dbname";
public static String DB_USER = "test";
public static String DB_PASS = "password";
// Singleton instance
protected static DatabaseConnector _instance;
protected String _uri;
protected String _username;
protected String _password;堆棧跟蹤的開始:Apr 5, 2011 9:49:14 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Login] in context with path [/Project]
threw exception
java.lang.RuntimeException: java.sql.SQLException:
No suitable driver found for jdbc:mysql://localhost/dbname是什么導(dǎo)致了這個(gè)錯(cuò)誤?
如何修復(fù):“在使用池時(shí)找不到JDBC:mysql:/localhost/dbName”錯(cuò)誤?
胡說(shuō)叔叔
2019-07-09 13:11:31