I am developing a Java application for my college education. I ran into a problem while loading values into a Jtable. I used the following code to load values. He makes duplicate entries. Can you help me get rid of this problem?
private void LoadSupplierTable() {
clearTable((javax.swing.table.DefaultTableModel) tblSupp.getModel());
javax.swing.table.DefaultTableModel dtSupp = (javax.swing.table.DefaultTableModel) tblSupp.getModel();
Vector ver = new Vector();
try {
ResultSet resO = null;
String sqo = "select id,name from supplier";
Connection coo = DataBaseConnection.getDbConnection();
PreparedStatement pso = coo.prepareStatement(sqo);
resO = pso.executeQuery();
while (resO.next()) {
ver.add(resO.getInt("id"));
ver.add(resO.getString("name"));
dtSupp.addRow(ver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
user3077212
source
share