I'm working on a SOAP based webservice where in a part of it i have to perform some queries on the database using nested loop, the problem is that the inner loop just gets executed for ONE time only, before giving up.This is the code:
for(int i=0; i<selec.length; i++){
for(int j=0; j<sintom.length;j++){
var[(i*sintom.length)+j] = "INSERT INTO malattia (nome, eta, descrizione, sesso, etnia, sintomi) "
+ "VALUES ('" + malattia + "','" + eta + "','" + descrizione + "','" + sexarra[0] + "','" + selec[i] + "','" + sintom[j] + "')";
}
}
This is where the queries are supposed to get executed:
if (errore.equals("")) {
try {
Statement st = conn.createStatement();
for(int i=0; i<selec.length; i++){
for(int j=0;j<sintom.length;j++){
st.executeUpdate(var[(i*sintom.length)+j]);}}
What happens is that no matter the size of select it will work fine as long as the length of sintom is 1,bigger than 1 and it wont work.
Thanks for your expert advices, always appreciated!
Statementobject for each query. Also, fix your SQL injection vulnerability.