1

当我尝试连接到我的数据库时遇到问题:我想我的 mysql-connector 可能会自动更改数据库的 URL,我不知道如何修复它......但这可能是另一个问题,事实上我没有真不知道是什么。

这是我的代码:

    private String driver = "com.mysql.jdbc.Driver";
private static String url_db = "jdbc:mysql://mysqldev.fundp.ac.be:3306/neptun";
private static String login = "";
private static String pwd = "";
private static RepositoryParams rep = new RepositoryParams();
private static String path = rep.getPath() ;
private static boolean canConnect = true;
private static Connection connect;
private static FileUtils fU = new FileUtils();
    private ConnectToDb() {
    boolean driverOk = false;
    setParamsToConnect();
    try {
        Class.forName(driver);
        driverOk = true;
    } catch (ClassNotFoundException ex) {
        System.out.println("ERROR : Unable to load the Oracle driver:");
        ex.printStackTrace();
    }
    if (driverOk) {
        try {
            if (canConnect) {
                System.out.println("Oracle drivers load successfully");
                connect = DriverManager.getConnection(url_db, login, pwd);
            } 

        } catch (SQLException ex) {
            printSQLException(ex);
        }
    }
}

和输出:

Oracle drivers load successfully
SQLException > SQLState: 28000
SQLException > Message :Access denied for user 'neptun'@'anthony-morre.bump.fundp.ac.be' (using password: YES)
4

0 回答 0