Advertisement
Guest User

Untitled

a guest
Sep 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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.ConexaoBanco;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.SQLException;
  11.  
  12. /**
  13. *
  14. * @author ProfAlexandre
  15. */
  16. public class ConexaoDB {
  17.  
  18.  
  19.  
  20. public Connection getConnection() throws SQLException, ClassNotFoundException {
  21. try {
  22. Class.forName("com.mysql.jdbc.Driver");
  23. String url ="jdbc:mysql://localhost:3306/exemplo";
  24. String usuario = "root";
  25. String senha = "1234";
  26. return DriverManager.getConnection(url,usuario,senha);
  27. } catch (SQLException e) {
  28. throw new RuntimeException(e);
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement