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);
        
    }

}

 

posted @ 2020-06-13 11:39  技术白菜  阅读(542)  评论(0编辑  收藏  举报