Ola amigos, estou tendo muita lentidão ao realizar uma Query em uma banco de dados MYSQL na WEB,
Preciso realizar uma query e grava-la em um AbstractTableModel
Teria um jeito mais adequado e rápido para efetuar esse procedimento?
Veja como estou fazendo:
// CONSULTA NO BANCO DE DADOS
String VSql1 = "SELECT codigo, destinatario, lista, dataenvio FROM fila WHERE usuario = '"+sms.main.usuario+"' order by dataenvio";
try {
ArrayList lista;
Statement consulta3 = conexao.getConexao().createStatement();
conexao.rs[3] = consulta3.executeQuery(VSql1);
lista = new ArrayList();
while (conexao.rs[3].next()) {
geteset geteset = new geteset();
geteset.setCodigo(conexao.rs[3].getInt("codigo"));
geteset.setdestinatario(conexao.rs[3].getString("destinatario"));
geteset.setlista(conexao.rs[3].getString("lista"));
geteset.setdata(conexao.rs[3].getTimestamp("dataenvio"));
lista.add(geteset);
}
conexao.rs[3].close();
consulta3.close();
return lista;
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Erro de conexão com banco de dados, tente novamente");
return null;
}
// GRAVAÇÂO DA LISTA NA JTABLE
private void carregalsta1(){
lista = new geteset.geteset().consulta3();
getModel().limpar();
total=0;
for (i = 0; i < lista.size(); i++) {
geteset.geteset geteset = lista.get(i);
total++;
getModel().addListaDeSocios(getSocios());
jLabel2.setText(String.valueOf(total));
}
}
private List<Socio> getSocios() {
List<Socio> socios = new ArrayList<Socio>();
geteset.geteset geteset = lista.get(i);
Socio socio = new Socio();
socio.setRemetente(geteset.getdestinatario());
socio.setData(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(geteset.getdata()));
socio.setLista(geteset.getlista());
socio.setcodigo(geteset.getCodigo());
socios.add(socio);
return socios;
}
Agradeço a ajuda!