方式一
Driver driver = new com.mysql.jdbc.Driver(); String url = "jdbc:mysql://localhost:3306/test"; Properties info = new Properties(); info.setProperty("user","root"); info.setProperty("password","1234"); Connection connection = driver.connect(url,info); System.out.println(connection);