title: java.sql.SQLException: No value specified for parameter 2 ,Inserting arraylist to database using JDBC
body: <p>I am extracting some data from website using jsoup and storing to arraylist. Now i want to store the data to mysql database. This is my code but i got this     java.sql.SQLException: No value specified for parameter 2</p>
  
  <p>This is my class to get data from the website. </p>
  
  <pre><code>public class Twrapper {
  
      ArrayList&lt;MobilePhone&gt; skrouztPhones = new ArrayList&lt;&gt;();
  
      protected ArrayList&lt;MobilePhone&gt; getPhoneNames() throws IOException{
  
          for (int j=1; j&lt;=1;j++){
              Document mobilePhones = Jsoup.connect("http://www.skroutz.gr/c/40/kinhta-thlefwna.html?order_dir=asc&amp;page=" + j).userAgent("Mozilla").get();
              Elements phoneName = mobilePhones.select("div[class=details]");
              for(int i = 1; i&lt;phoneName.size();i++){
                  MobilePhone names = new MobilePhone();
                  names.setName(phoneName.get(i).text());
                  skrouztPhones.add(names);
              }      
          }
      return skrouztPhones;
      }
  
      protected ArrayList&lt;MobilePhone&gt; getPhonesUrls() throws IOException{
  
          for(int j =1; j&lt;=1;j++){
              Document mobilePhone = Jsoup.connect("http://www.skroutz.gr/c/40/kinhta-thlefwna.html?order_dir=asc&amp;page=" + j).userAgent("Mozilla").get();
              Elements phoneUrls = mobilePhone.select("div[class=details] a ");
              for(int i =0; i&lt;phoneUrls.size(); i++){
                  MobilePhone urls = new MobilePhone();
                  urls.setUrl(phoneUrls.get(i).absUrl("href"));
                  skrouztPhones.add(urls);
              }
          }
          return skrouztPhones;
      }
  }  
  </code></pre>
  
  <p>This is my method to store the data to database.</p>
  
  <pre><code>public static  void main(String[] args) throws  IOException, SQLException{
      Twrapper wrapper = new Twrapper();
  
  
      try
      {
          // create a mysql database connection
          String myDriver = "org.gjt.mm.mysql.Driver";
          String myUrl = "jdbc:mysql://83.212.124.175:3306/zadmin_java?useUnicode=yes&amp;characterEncoding=UTF-8";
          Class.forName(myDriver);
          System.out.println("Connecting to a selected database...");
          Connection conn = DriverManager.getConnection(myUrl, "usr", "pass");
          System.out.println("Connected database successfully...");
  
          // the mysql insert statement
          String query = " INSERT INTO skrouzt(url,name)"
            + " values (?, ?)";
          PreparedStatement updateSkrouztPs = conn.prepareStatement(query);
          //use the wrapper methos to insert to db
  
  
          ArrayList&lt;MobilePhone&gt; skroutzPhonesUrls = wrapper.getPhonesUrls();
          for(MobilePhone phone: skroutzPhonesUrls){
              String urls = phone.getUrl();
              updateSkrouztPs.setString(1, urls);
              updateSkrouztPs.executeUpdate();
          }
          ArrayList&lt;MobilePhone&gt; skrouztPhonesNames  = wrapper.getPhoneNames();
          for(MobilePhone phone: skrouztPhonesNames){
              String names = phone.getName();
              updateSkrouztPs.setString(2, names);
              updateSkrouztPs.executeUpdate();
          }
  
  
  
  
  
  
  
          //close the connection
          conn.close(); 
          System.out.println("Done!!");
      }
      catch(SQLException se){
         //Handle errors for JDBC
         se.printStackTrace();
      }
      catch (Exception e)
      {
        System.err.println("Got an exception!");
        System.err.println(e.getMessage());
  
      }
  }
  </code></pre>