Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package conexao;
- import java.sql.*;
- public class ModuloConexao {
- //método responsável por estabelecer conexão com o BD
- public static Connection Conector() {
- java.sql.Connection conexao = null;
- //a linha abaixo "chama" o driver
- String driver = "com.mysql.jdbc.Driver";
- //Armazenando informações referente ao banco
- //String url = "jdbc:mysql://localhost:3306/dbinfox";
- String url = "jdbc:mysql://localhost/simulado1?autoReconnect=true&useSSL=false";
- String user = "root";
- String password = "";
- //Estabelecendo a conexão com o banco
- try {
- //Class.forName(driver);
- conexao = DriverManager.getConnection(url, user, password);
- //System.out.println("Conexão com Sucesso");
- return conexao;
- } catch (Exception e) {
- //a linha abaixo serve de apoio para esclarecer o erro
- System.err.println("\n============================================");
- System.err.println("\nCLASSE VISITAS CONECTA BANCO");
- System.err.println("\nERRO NO MÉTODO GET CONNECTION");
- System.err.println("\n " + e.getCause());
- System.err.println("\n " + e.getMessage());
- System.err.println("\n============================================");
- throw new RuntimeException(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement