NullPointerException em Cadastro Postgresql

Crio uma instancia:
private final ConexaoDB conect = new ConexaoDB();

depois uso ela e chamo o método:
conect.openPostgreSql();

no mysql ta funcionando bem assim.

Acredito que possa tá com algum problema com o driver do Postgresql

retorna o que?? vc tem q retornar um Connection e com esse Connection vc fazer o prepareStatement e todo resto

public class ConexaoDB implements Serializable {

    public Connection conPostgres;

    public Connection openPostgreSql() {
        try {
            Class.forName("org.postgresql.Driver");
            conPostgres = DriverManager.getConnection("jdbc:postgresql://10.8.0.105:5445/sinanpop51", "postgres", "");
            System.out.println("Postgresql ConnectON: " + conPostgres);
        } catch (ClassNotFoundException ex) {
            System.out.println("ClassNotFoundException: " + ex);
        } catch (SQLException ex) {
            System.out.println("SQLException: " + ex);
        } catch (NullPointerException err) {
            System.out.println("NullPointerException: " + err);
        }
        return conPostgres;
    }

    public void closePostgreSql() {
        try {
            System.out.println("SINOMP - Postgresql ConnectOFF: " + conPostgres);
            conPostgres.close();
        } catch (SQLException ex) {
            System.out.println("SQLException: " + ex);
        }
    }

Esse ta retornando: org.postgresql.jdbc4.Jdbc4Connection@16ea171f

public class ConexaoDB implements Serializable {

    static {
        try {
            Class.forName("org.postgresql.Driver");

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ConexaoDB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static Connection openPostgreSql() throws Exception {

        return DriverManager.getConnection("jdbc:postgresql://10.8.0.105:5445/sinanpop51", "postgres", "");

    }

    public void closePostgreSql(Connection conPostgres) throws Exception{
        if (conPostgres != null) {
            conPostgres.close();
        }
    }
}

sem dor…hehe

Vou testar :smiley:

Deu certo pessoal:

private static final ConexaoPostgres conect = new ConexaoPostgres();

Connection x = conect.openPostgreSql();
cst = x.prepareCall("INSERT INTO dbsinan.tb_notificacao......);

Agradeço pela ajuda.

Valeu esmo.