包com.mysql.jdbc不存在 [英] package com.mysql.jdbc does not exist
本文介绍了包com.mysql.jdbc不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在导入com.mysql.jdbc.Connection时遇到问题,它说包com.mysql.jdbc不存在,而且iam已经将mysql-connector-java-5.1.36放在了netbeans上
i have problem with import com.mysql.jdbc.Connection it say package com.mysql.jdbc does not exist and iam already put mysql-connector-java-5.1.36 at the netbeans
package pkgnew;
import com.mysql.jdbc.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author xxxx1
*/
public class DBConn {
private Connection DBConn;
public Connection connect() {
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Connection Success");
}
catch(ClassNotFoundException cnfe){
System.out.println("Connection Fail" + cnfe);
}
String url = "jdbc:mysql://localhost:3306/cars";
try {
DBConn = (Connection) DriverManager.getConnection(url, "root","123456");
System.out.println("Database Connected");
}
catch (SQLException se){
System.out.println("No Database"+se);
}
return DBConn;
}
}
推荐答案
这是Jar缺少的问题. Netbean编辑器无法从MySQL_XXX_whatever_Name.jar进行分类.
It's Jar missing issue. Netbean Editor Unable to fine Classed from MySQL_XXX_whatever_Name.jar.
请首先将正确要求的库添加到您的Java项目中.
Please add properly required library first into your java project.
In Netbean, Right click on Library -> search Mysql...jar file(if exist from list) otherwise, manually download and import.
您的问题将得到解决.
这篇关于包com.mysql.jdbc不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文