找不到JDBC驱动程序 [英] Cannot find JDBC driver
本文介绍了找不到JDBC驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
try
{
String userName = "root";
String password = "";
//<facility> is my database
String url = "jdbc:mysql://localhost/facility";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.out.println ("Cannot connect to database server " +e.getClass().getName());
}
输出>无法连接到数据库服务器java.lang.ClassNotFoundException
output> Cannot connect to database server java.lang.ClassNotFoundException
推荐答案
似乎您应该将MySQL驱动程序jar放入您的 classpath .
It seems that you should put your MySQL driver jar into your classpath.
这篇关于找不到JDBC驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文