Hello everyone It is not alot of code but I am having great differculties with it. I have another integer which is the value 4. And a arraylist with 40 words inside it. Now I can set up my column names and question marks to 4 without having to chnaging my sql statement. I want to be able to get the first 10 values from my arraylist (arr3) and insert them into the first column name (Phone). Then i want the next 10 words from the arraylist (10 to 20) and Insert them into the second column name(Addr1). Then I want the next 10 words from the arraylist (20 to 30) and Insert them into the Third column name(Addr2). Then I want the next 10 words from the arraylist (30 to 40) and Insert them into the last column name (Addr3). As you can see below that my code will do this fine, But my problem is that i want to be able to do this without having to change my code each time i have another setString method to fill. I want to be able to have just one setString method so that each time it loops though it will change the values to what is there. for example pss.setString("loop Though so that it will change the number 1 to a 2 then to a 3 then 4", arr3.get(j1+ "then another loop so that it will add 10 to j1 each time it loops though").toString()) Thanks for your help and time Ben
Here is my code that works fine // arr3 is a arraylist that holds 40 words inside it. try { String data = "jdbc:odbc:myProject"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection(data,"","");
String sql = "INSERT INTO Ben (Phone,Addr1,Addr2,Addr3) VALUES (?,?,?,?)";