Advertisement
Guest User

CONEXAO

a guest
May 10th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package br.com.vitor.dal;
  7.  
  8. import java.sql.*;
  9.  
  10. public class ModuloConexao {
  11.  
  12. //metodo responsavel por estabalecer conexao com o banco de dados //
  13.  
  14. public static Connection conector() {
  15. java.sql.Connection conexao = null;
  16. //chama o driver //
  17. String driver = "com.mysql.jdbc.Driver";
  18. //Armazenando informacao//
  19. String url = "jdbc:mysql://localhost:3306/aula";
  20. String user = "root";
  21. String password = "root";
  22. //estabelecendo conezao//
  23. try{
  24. Class.forName(driver);
  25. conexao=DriverManager.getConnection(url,user,password);
  26. return conexao;
  27. }catch(Exception e){
  28. //exibe o erro
  29. System.out.println(e);
  30. return null;
  31.  
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement