java JDBC-数据库的链接

public class Demo {

public static void main(String[] args) {
    try {
        //加载驱动类(jar包提供的类)
        Class.forName("com.mysql.jdbc.Driver");
        //链接数据库
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","dyl123");

        System.out.println(conn);

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
}
相关文章
相关标签/搜索