jdbc错误的主机名(自动替换)

时间:2013-07-08 07:07:31

标签: java sql database jdbc hostname

当我尝试连接到我的数据库时遇到问题:我想我的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)

0 个答案:

没有答案