Guest User

Untitled

a guest
Sep 25th, 2018
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. package exercicioconexao;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class Conexao {
  8.  
  9. static Connection obterConexao() {
  10.  
  11. Connection con = null;
  12.  
  13. try {
  14. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bancodados" , "root" , "");
  15. System.out.println("Conectado com sucesso.");
  16. } catch (SQLException e) {
  17. System.out.println("Erro.");
  18. e.printStackTrace();
  19. }
  20. return con;
  21.  
  22. }
  23.  
  24. }
Add Comment
Please, Sign In to add comment