I am trying to run a new SQL command for each value in my list. I have the following that just repeats the same value over and over for the amount in my list.
Note that I need to loop around SQL for the number of values ββin my list of arrays and insert each value as a name in SQL, as shown below.
What is the best way to do this, as it is definitely not.
int listSize = al.size(); for(int i = 0; i < listSize; i++) { ResultSet rs1 = name.executeQuery("SELECT sum(hours) FROM PROJECT_TIME WHERE DATE = '"+date+"' AND name = '"+al.listIterator().next()+"'"); al1.add(rs1.getString(1)); rs1.close(); } System.out.println(al1);
Result:
[70, 70, 70, 70, 70, 70, 70, 70, 70, 70]
Expected Result:
[70, 80, 110, 60, 35, 10, 15, 10, 0, 25]
source share