gitee源码
url=jdbc:mysql://localhost:3306/test
user=root
password=sa
driverClass=com.mysql.jdbc.Driver
public class ConnectionTest {
// 方式一:出现异常时, 需要对应版本的mysql连接启动包 我的改为 5.*版本可行
@Test
public void testConnection1() throws SQLException {
// 获取Driver实现类对象
Driver driver = new com.mysql.jdbc.Driver();
// 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", "sa");
Connection conn = driver.connect(url, info);
System.out.println(conn);
}
//