jdbc连接测试
package 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); } }