1.方式一(了解)
1)数据库版本8.0.25
import org.junit.Test;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;
public class ConnectionTest {
@Test
public void connection() throws SQLException {
Driver driver =new com.mysql.cj.jdbc.Driver(); //ctrl + h查看Driver接口的实现类
//url:http://localhost:8080/gmall/keyboard.jpg
//jdbc:mysql:协议
//localhost:ip:地址
//3306:默认mysql的端口号
//test:test数据库
String url = "jdbc:mysql://localhost:3306/test";
//将用户名和密码封装在Properties中
Properties info = new Properties();
info.setProperty("user","root");//数据库用户名
info.setProperty("password","123456");//数据库密码
Connection conn = driver.