Advertisement
Guest User

Untitled

a guest
May 28th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. package classes;
  2. import java.sql.*;
  3.  
  4. public class Conexao {
  5.     public Connection conn;
  6.     public Statement stmt;
  7.     public ResultSet consulta;
  8.    
  9.     public Conexao() {
  10.         try {
  11.             Class.forName("org.gjt.mm.mysql.Driver");
  12.             conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/notas","root","root");
  13.             stmt = conn.createStatement();
  14.             System.out.println("Conexão efetuada com sucesso");
  15.         } catch (Exception e) {
  16.             System.out.println("Não foi possível conectar ao banco" + e.getMessage());
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement