Using Netbeans to Access BD Posgresql - jdbc. Drivers

Asked

Viewed 35 times

1

I made the connection in the database using netbeans but is not finding the DRIVE, apparently everything is correct, but always returns the error:

No suitable driver found for jdbc:postgresql:localhost:5432/Postgre

public class ConexaoBD {

public Statement stn; //pesquisa no banco de dados
public ResultSet rs; // armazena o resultado da pesquisa
private String driver = "org.postgresql.Driver"; //identifica o nosso serviço BD
private String caminho = "jdbc:postgresql://localhost:5432/Postgre"; //Qual o caminho do BD
private String usuario = "postgres";
private String senha = "xxxxxxx";
public Connection con; 

public void conexao(){
    
    try {
        System.setProperty("jdbc.Drivers", driver);
        con=DriverManager.getConnection(caminho, usuario, senha);
        JOptionPane.showMessageDialog(null, "Conexão efetuada com sucesso");
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Erro na conexão efetuada!\n"+ex.getMessage());
    }
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.