1、首先 下载驱动:mysql-connector-java-5.1.49.jar
然后eclipse中,新建项目,鼠标右键单击项目名,找到build path,configure build path。modulepath 中,添加额外jar包。
2、
class Mysql{
public Mysql (String link,String sentence)throws ClassNotFoundException, SQLException
{
Class.forName("com.mysql.jdbc.Driver");