@Test
public void test1() throws SQLException {
Driver driver = new Driver();
String url = "jdbc:mysql://localhost:3306/zoo?serverTimezone=UTC";
Properties info = new Properties();
info.setProperty("user", "root");
info.setProperty("password", "root");
Connection conn=driver.connect(url, info);
System.out.println(conn);
}
@Test
public void test2() throws Exception {
Class clazz = Class.forName("com.mysql.cj.jdbc.Driver");
Driver driver = (Driver) clazz.newInstance();
String url="jdbc:mysql://localhost:3306/zoo?serverTimezone=UTC";
Properties info=new Properties();
info.setProperty("user", "root");
info.setProperty("password", "root");
Connection conn=driver.connect(url, info);
System.out.println(conn);
}
@Test
public void test3() throws Exception {
Class clazz = Class.forName("com.mysql.cj.jdbc.Driver");
Driver driver =(Driver) clazz.newInstance();
DriverManager.registerDriver(driver);
String url="jdbc:mysql://localhost:3306/zoo?serverTimezone=UTC";
Connection connection = DriverManager.getConnection(url, "root", "root");
System.out.println(connection);
}
@Test
public void test4() throws Exception {
Class.forName("com.mysql.cj.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/zoo?serverTimezone=UTC";
Connection connection = DriverManager.getConnection(url, "root", "root");
System.out.println(connection);
}
@Test
public void test5() throws Exception {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306?serverTimezone=UTC", "root", "root");
System.out.println(connection);
}
@Test
public void test6() throws Exception {
InputStream is = ConnectionTest.class.getClassLoader().getResourceAsStream("jdbc.properties");
Properties properties = new Properties();
properties.load(is);
String user = properties.getProperty("user");
String password = properties.getProperty("password");
String url = properties.getProperty("url");
String DrverClass = properties.getProperty("DrverClass");
Class.forName(DrverClass);
Connection connection = DriverManager.getConnection(url, user, password);
System.out.println(connection);
}