Connection to database too slow

0

I do not know what happened that now the connection to the database is taking a long time. Before it was quick I would give the answer if it was connected or not ... now takes about 15 minutes and my pc does not work right is all mainly locking eclipse ...

Now any project gives this "bug" ... where am I going wrong?

The connector I'm using is this one, I already tried the current one also gave the same ... mysql-connector-java-5.0.8-bin-jar

package br.com.Sistema.dal;

import java.sql.*;
public class ModuloConexao {
    //metodo por estabelecer conexao com o banco
    public static Connection conector() {
        java.sql.Connection conexao = null;

        // linha abaixo "chama" o driver
        String driver = "com.mysql.jdbc.Driver";

        // armazenando informaçoes referente ao bd
        String url = "jdbc:mysql://localhost:3306/teste";
        String user = "root";
        String pass = "vertrigo";

        // Estabecendo conexao ao Banco de Dados
        try {
            Class.forName(driver);
            conexao = DriverManager.getConnection(url, user, pass);
            System.out.println(conexao);
            return conexao;
        } catch (Exception e) {
            // a linha abaixo serve de apoio para esclarecer o erro
            //JOptionPane.showMessageDialog(null,"Não há Conexao com o Banco de Dados");
            return null;

        }


    }
}

Login Screen

package TelaPrincipal.telas;




import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.ImageIcon;
import javax.swing.JButton;


import java.sql.*;
import br.com.Sistema.dal.ModuloConexao;


public class TelaLogin extends javax.swing.JFrame {

    Connection conexao = null;
    PreparedStatement pst = null;
    ResultSet rs = null;

    private JPanel contentPane;
    private JTextField textField;
    private JTextField textField_1;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    TelaLogin frame = new TelaLogin();
                    frame.setVisible(true);
                    frame.setLocationRelativeTo(null);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public TelaLogin() {
        conexao = ModuloConexao.conector();
        System.out.println(conexao);

        setResizable(false);
        setTitle("          < Sistema de Usuario >");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 330, 191);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(null);


        JLabel lblUsurio = new JLabel("Usuario");
        lblUsurio.setHorizontalAlignment(SwingConstants.RIGHT);
        lblUsurio.setFont(new Font("Tahoma", Font.BOLD, 12));
        lblUsurio.setBounds(8, 17, 62, 26);
        contentPane.add(lblUsurio);

        JLabel lblSenha = new JLabel("Senha");
        lblSenha.setHorizontalAlignment(SwingConstants.RIGHT);
        lblSenha.setFont(new Font("Tahoma", Font.BOLD, 12));
        lblSenha.setBounds(20, 54, 50, 26);
        contentPane.add(lblSenha);

        textField = new JTextField();
        textField.setBounds(92, 21, 176, 20);
        contentPane.add(textField);
        textField.setColumns(10);

        textField_1 = new JTextField();
        textField_1.setColumns(10);
        textField_1.setBounds(92, 52, 176, 20);
        contentPane.add(textField_1);

        JLabel lblConectado = new JLabel("");
        lblConectado.setIcon(new ImageIcon("C:\ambiente_de_trabalho\teste\Inbras\src\br\com\inbras\icones\desconectado1.png"));
        lblConectado.setBounds(30, 91, 33, 33);
        contentPane.add(lblConectado);

        JButton btnLogin = new JButton("Login");
        btnLogin.setBounds(92, 101, 176, 23);
        contentPane.add(btnLogin);

    }
}

The code is working, it only hangs at the time of the connection with bank ... I unplugged my server, which is the vertrigo, installed again, did not work .. I installed Xampp also, it did not work, it worked anyway ...

What is causing this error?

    
asked by anonymous 27.02.2018 / 05:48

0 answers