Connection error between Java and postgresql

0

I'm trying to make a GUI in Java connect to a database, so I'm using Netbenas and Postegresql. I created a table in Postegresql. I downloaded postgresql-9.4.1208.jre6.jar and added it to the project. I have two Classes one of the connection and the other of the Form, but when I try to connect, this message comes out:

Java.sql.SQLExeption: No suitable driver found for jdbc:postgresql://localhost:5432

Does anyone know what this means? NOTE: As a test I made the interface in the Netbeans editor. Here are the classes:

    package Visual;
import java.sql.*;
import Dal.ConectaBd;
import java.util.logging.Level;
import java.util.logging.Logger;
public class frmlogin extends javax.swing.JFrame {

    Connection con=null;
    PreparedStatement pst=null;
    ResultSet rs = null;
    public frmlogin() throws ClassNotFoundException {
        initComponents();
        this.setLocationRelativeTo(null);
        con=ConectaBd.Conectabd();
    }
    public static void main(String args[]) {
 /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new frmlogin().setVisible(true);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(frmlogin.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

Second class:

package Dal;
import java.sql.*;
import javax.swing.JOptionPane;
public class ConectaBd {
    public static Connection Conectabd() throws ClassNotFoundException {

        try {
          // conecta com o banco
            Class.forName("org.postgresql.Driver");
            Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432","postgres","");
            JOptionPane.showMessageDialog(null, "Conectado com sucesso");
            return con;
        }catch(SQLException erro){
            JOptionPane.showMessageDialog(null, erro);
            return null;
        } 

    }
}  
    
asked by anonymous 26.02.2016 / 20:30

0 answers