java实战 连接数据库

Last updated on September 15, 2024 pm

🧙 Questions

☄️Ideas

/**
     * 测试数据库连接
     */
    public static boolean testDatasource(String url, String username, String password) {

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection connection = DriverManager.getConnection(url, username, password);
            return connection != null;
        } catch (ClassNotFoundException | SQLException e) {
            return false;
        }
    }

java实战 连接数据库
https://ispong.isxcode.com/spring/java/java实战 连接数据库/
Author
ispong
Posted on
January 13, 2021
Licensed under