Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package br.com.farmacia.factory;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class Conexao {
  8. private static final String USUARIO = "root";
  9. private static final String SENHA = "admin";
  10. private static final String URL = "jdbc:mysql://localhost:3306/cafeteria?useSSL=false&serverTimezone=UTC";
  11.  
  12. public static Connection conectar() throws SQLException {
  13. Connection conexao = DriverManager.getConnection(URL, USUARIO, SENHA);
  14. return conexao;
  15. }
  16.  
  17. public static void main(String[] args) {
  18. try {
  19. Connection conexao = Conexao.conectar();
  20. System.out.println("Conectado com Sucesso !!");
  21. } catch (SQLException e) {
  22. e.printStackTrace();
  23. System.out.println("Conexão falhou !!");
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement