mysql数据库连接问题

2024-11-30 07:49:53
推荐回答(1个)
回答1:

如果报错的话把错误贴出来,还有就是你倒没倒连接jar包,3个jar加在程序里了吗?
import java.sql.*;
Connection conn =null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost/mybbs", "root", "root");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}