我需要您的幫助來從列表中獲取值並將它們附加到插入語句。我有一個類中調用員工說:如何從java列表獲取值
public class Employee {
private Integer id; //Getter and Setter
private String name;//Getter and Setter
private String remarks;//Getter and Setter
private boolean disable;//Getter and Setter
public Employee(Integer id, String name, String remarks, boolean disable){
this.id = id;
this.name = name;
this.remarks=remarks;
this.disable=disable;
}
在豆,我生成隨機數的EmployeeList的:
private List<Employee> employeeList;
private List<Employee> selectedEmployees;
public test() {
super();
employeeList = new ArrayList<Employee>();
for (int i = 1; i <= 10; i++) {
employeeList.add(new Employee(i, "Name " + i, "Remarks " + i, true));
}
}
和選擇的值將被存儲在列表selectedEmployees
。現在我想編寫一個新的方法來打印提取的值,然後將它們附加到一個插入語句中以將選定的值插入到表中。
public void updateRecords() {
System.out.println("Size =" + selectedEmployees.size());
//Here I need help to print the values of the list and then to append them to an insert statement to the table employees
insert into employees (id,name,remarks) values();
}
邀請SQL注入 – Sanjeev
@Sanjeev謝謝你的注意事項 – Pooya