jdbc连接测试
时间:2021-07-01 10:21:17
帮助过:14人阅读
com.itcast.demo1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.junit.Test;
public class Demo1 {
@Test
public void fun1()
throws ClassNotFoundException, SQLException{
/**
* jdbc四大参数
* driverClassName:com.mysql.jdbc.Driver
* url:jdbc:mysql://localhost:3306/mydb3
* username:root
* password:root
*/
Class.forName("com.mysql.jdbc.Driver"
);
String url = "jdbc.mysql://localhost:3306/test"
;
String username = "root"
;
String password = "root"
;
Connection conn =
DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test", "root", "root"
);
System.out.println(conn);
}
}
jdbc连接测试
标签:class 连接 exce void rman mysq fun demo manage