Problems connecting to PostgreSQL (ghost URL)

0

I'm working on a java web project and I have a connection class with the PostgreSQL database, which links to the database called BASE_X that performed properly, but I made a copy of the project that has this class and made another database in PostgreSQL identical to the previous one, just changing the name to BASE_X1 . I wanted to do some new experiments with the new bank that was not populated like the old one, I changed the database name in the link class path URL to go to the new unpopulated bank and compiled the entire project along with the class . I cleared the browser history, cleared the cache, unzipped the project, and then rode the new project with the new path and it connected with the old !! To get the doubt I took the class that was compiled and decompiled to check if there was any error but nothing he was indicating the connection to the new bank !! I have never seen something like that !! And I've done this experiment other times with other non-web projects and they worked. I do not know what's going on ..

Part of the code for the connection class of the first project:

private Connection con;

private final Properties prop = null;

private final String URL = "jdbc:postgresql://localhost:5433/BASE_X";  

Part I changed from connection class of second project:

private final String URL = "jdbc:postgresql://localhost:5433/BASE_X1";  

Connection code:

package br.com.banco.basex.Connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

import br.com.banco.basex.Excecoes.FonteDeDadosException;
import java.util.Properties;
public class Conexao implements ConexaoIF {

private Connection con;

private final Properties prop = null;

private final String URL = "jdbc:postgresql://localhost:5433/BASE_X";

public Conexao() throws SQLException {
    try {

        Class.forName("org.postgresql.Driver");

        this.con = DriverManager.getConnection(URL, "postgres", "doremifa");
    } catch (FonteDeDadosException | ClassNotFoundException e) {
        throw new FonteDeDadosException(
                        "Não foi possível conectar com o banco de dados!");
    }
}

public Connection getConnection() {

    return this.con;
}

public void closeAll(PreparedStatement stat) throws FonteDeDadosException {
    try {
        this.con.close();
        stat.close();
    } catch (SQLException e) {
        throw new FonteDeDadosException("Falha ao fechar conexões");
    }

}

public void closeAll(Statement stat) throws FonteDeDadosException {
    try {
        this.con.close();
        stat.close();
    } catch (SQLException e) {
        throw new FonteDeDadosException("Falha ao fechar conexões");
    }

  }
}
    
asked by anonymous 25.09.2015 / 21:30

1 answer

1

I've never seen such a strange situation !! Sometimes this kind of episode happens, maybe it's a "byte of the German", that wants to mock our high prosopopeia of decent and respected programmer citizens ...

I solved the problem like this:

Since the old project was happy, it is not the problem, and I left for PostgresSQL and made the only plausible solution:

I made backup of the old BASE_X database and deleted it from PostgreSQL. It was shot and fall, as the old one did not exist anymore, it connected with the new bank BASE_X1 not populated !! See you later!

    
25.09.2015 / 22:41