Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. package br.com.utd.jdbc;
  2. import java.sql.DriverManager;
  3. import java.sql.SQLException;
  4. import javax.swing.JOptionPane;
  5. import com.mysql.jdbc.Connection;
  6.  
  7. public class Conexao {
  8. private final static String URL = "jdbc:mysql://127.0.0.1:3306/livraria";
  9. private final static String USUARIO = "root";
  10. private final static String SENHA = "**********";
  11.  
  12. public static Connection factoryConexao(){
  13. Connection conexao = null;
  14. try{
  15. conexao = DriverManager.getConnection(URL, USUARIO, SENHA);
  16. return conexao;
  17. }catch(SQLException e1){
  18. JOptionPane.showMessageDialog(null,
  19. "Falha na conexão com o banco de dados:"+e1);
  20. return conexao;
  21. }
  22. }
  23.  
  24. }
  25.  
  26. conexao = DriverManager.getConnection(URL, USUARIO, SENHA);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement