Galera eu quero pegar no bd tudo que iniciar com a sequência digitada nos textsfilds relacionados, em um ou outro no caso. Só q ele está listando todos e na ordem errada, no caso era pra listar no jtable 1º os q coincidem com o q fora digitado. Agradeço taí o código…
[code]public void buscaCliente(String cpf, String Titular){
try {
Class.forName ( driver );
con = DriverManager.getConnection( url );
sta = con.createStatement();
res = sta.executeQuery(“SELECT * FROM Clientes where (cpf like '”+cpf+"%’) or (Titular like ‘"+Titular+"%’) ");
int indice = 1;
String[][] valores = new String[res.getMetaData().getColumnCount()][11];
while(res.next())
{
String Titular1 = res.getString(1);
String Endereço = res.getString(2);
String Bairro = res.getString(3);
String Complemento = res.getString(4);
String cpf1 = res.getString(5);
String rg = res.getString(6);
String Cidade = res.getString(7);
String UF = res.getString(8);
String Telefone = res.getString(9);
String Celular = res.getString(10);
long Código = res.getLong(11);
valores[indice][0] = ""+Titular1;
valores[indice][1] = ""+Endereço;
valores[indice][2] = ""+Bairro;
valores[indice][3] = ""+Complemento;
valores[indice][4] = ""+cpf1;
valores[indice][5] = ""+rg;
valores[indice][6] = ""+Cidade;
valores[indice][7] = ""+UF;
valores[indice][8] = ""+Telefone;
valores[indice][9] = ""+Celular;
valores[indice][10] = ""+Código;
indice++;
TableModel jTable4Model = new DefaultTableModel(valores, new String[]
{“Titular”,“Endereço”,“Bairro”,“Complemento”,“cpf”,“rg”,“Cidade”,“UF”,“Telefone”,“Celular”,“Código”});
Apresentacao.jTable4.setModel(jTable4Model);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
finally {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
try {
sta.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
[/code]