Alguém sabe me dizer porque está repetindo dados nesse ComboBox?
this.CadperfilLinha.removeAllItems();
this.CadperfilProjeto.removeAllItems();
try {
Class.forName(driver);
Connection con = DriverManager.getConnection(url, user, pass);
Statement Sent = con.createStatement();
ResultSet rs = Sent.executeQuery("Select * from Linha, Projeto");
while (rs.next()) {
this.CadperfilLinha.addItem(rs.getString("LINHA"));
this.CadperfilProjeto.addItem(rs.getString("PROJETO"));
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
Já conferiu o que seu ResultSet está trazendo?
Tem certeza de que as colunas “LINHA” e “PROJETO” trazem valores diferentes?
Resolvido o problema pessoal! ele estava fazendo combinações com duas tabelas. criei uma pra cada. segue o exemplo caso alguém precise.
> this.CadperfilLinha.removeAllItems();
> try {
> Class.forName(driver);
> Connection con = DriverManager.getConnection(url, user, pass);
> Statement Sent = con.createStatement();
> ResultSet rs = Sent.executeQuery(“Select * from Linha”);
> while (rs.next()) {
> this.CadperfilLinha.addItem(rs.getString(“LINHA”));
> }
> } catch (Exception e) {
> JOptionPane.showMessageDialog(null, e);
> }
>
> ////////////////////////////////////////////////////////////////////////////
>
> this.CadperfilProjeto.removeAllItems();
> try {
> Class.forName(driver);
> Connection con = DriverManager.getConnection(url, user, pass);
> Statement Sent = con.createStatement();
> ResultSet rs = Sent.executeQuery(“Select * from Projeto”);
> while (rs.next()) {
> this.CadperfilProjeto.addItem(rs.getString(“PROJETO”));
> }
> } catch (Exception e) {
> JOptionPane.showMessageDialog(null, e);
> }