I have a graphical interface that includes a jtable, at the time of registering, it runs normally, only in the jtable it shows me what I have registered repeatedly but in the database it is registered only once.
Is there a way to fix it so that at the time of making a record it is displayed only once in the file and saved in SQL at the same time?
try
{
Connection conexion=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=prueba","sa","sa");
PreparedStatement statement =conexion.prepareStatement("Insert into datos values (?,?,?)");
statement.setString(1,texto1.getText());
statement.setString(2,texto2.getText());
statement.setInt(3, Integer.parseInt(texto3.getText()));
statement.executeUpdate();
//PreparedStatement statement1 =conexion.prepareStatement("Select *from datos");
Statement statement1 = conexion.createStatement();
ResultSet rs=statement1.executeQuery("Select nombre,apellido,edad from datos");
while(rs.next())
{
Object dato[]=new Object[3];
for (int i=0;i<3;i++)
{
dato[i] = rs.getObject(i+1);
}
modelo.addRow(dato);
}
rs.close();
tabla1.updateUI();
}
catch(Exception e1)
{
e1.printStackTrace();
}