Advertisement
Guest User

Untitled

a guest
Feb 26th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. Java.sql.SQLExeption: No suitable driver found for jdbc:postgresql://localhost:5432
  2.  
  3. package Visual;
  4. import java.sql.*;
  5. import Dal.ConectaBd;
  6. import java.util.logging.Level;
  7. import java.util.logging.Logger;
  8. public class frmlogin extends javax.swing.JFrame {
  9.  
  10. Connection con=null;
  11. PreparedStatement pst=null;
  12. ResultSet rs = null;
  13. public frmlogin() throws ClassNotFoundException {
  14. initComponents();
  15. this.setLocationRelativeTo(null);
  16. con=ConectaBd.Conectabd();
  17. }
  18. public static void main(String args[]) {
  19. /* Create and display the form */
  20. java.awt.EventQueue.invokeLater(new Runnable() {
  21. public void run() {
  22. try {
  23. new frmlogin().setVisible(true);
  24. } catch (ClassNotFoundException ex) {
  25. Logger.getLogger(frmlogin.class.getName()).log(Level.SEVERE, null, ex);
  26. }
  27. }
  28. });
  29. }
  30.  
  31. package Dal;
  32. import java.sql.*;
  33. import javax.swing.JOptionPane;
  34. public class ConectaBd {
  35. public static Connection Conectabd() throws ClassNotFoundException {
  36.  
  37. try {
  38. // conecta com o banco
  39. Class.forName("org.postgresql.Driver");
  40. Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432","postgres","");
  41. JOptionPane.showMessageDialog(null, "Conectado com sucesso");
  42. return con;
  43. }catch(SQLException erro){
  44. JOptionPane.showMessageDialog(null, erro);
  45. return null;
  46. }
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement