JDBC1 --- 获取数据库连接的方式一 --- 技术搬运工(尚硅谷)
作者:互联网
需要mysql-connector-java-5.1.7-bin.jar
@Test public void testConnection1() throws SQLException { Driver driver = new com.mysql.jdbc.Driver(); /* * jdbc:主协议 * mysql:子协议 * localhost:ip * 3306:端口 * test:数据库名 */ String url = "jdbc:mysql://localhost:3306/test"; /* * 封装数据库的用户名和密码 * Normally at least a "user" and"password" property should be included. */ Properties info = new Properties(); info.setProperty("user", "root"); info.setProperty("password", "123456"); Connection connect = driver.connect(url, info); System.out.println(connect); }
标签:info,JDBC1,jdbc,数据库,connect,mysql,3306,搬运工,硅谷 来源: https://www.cnblogs.com/noyouth/p/11731794.html