import org.junit.Test;
import java.sql.*;
public class connection {
@Test
public void test1() throws SQLException {
//提供MySQL中的Driver接口的实现类
Driver driver = new com.mysql.jdbc.Driver();
//注册驱动
DriverManager.registerDriver(driver);
String url="jdbc:mysql://localhost:3306/test";//test:表示具体的数据库名
String user="root";
String password="root";
//获取连接
Connection connection=DriverManager.getConnection(url, user, password);
System.out.println(connection);
}
}



