title: PreparedStatement with hashmap
body: <p>I am a newbie to Java, My problem is I am trying to insert currency rates into my MySQL database table called currency which contains two columns Currency_name and rate. The program fetches currency rate from finance yahoo API, I am facing The problem of storing the data into my database. </p>
  
  <pre><code>void checkRateAllAtEnd() throws Exception {
         /** print message  */
      System.out.println("checkRateAllAtEnd :");
          long start = System.nanoTime();
  
          List&lt;Callable&lt;HashMap&gt;&gt; tasks = new ArrayList&lt;Callable&lt;HashMap&gt;&gt;();
          for (final String ccy : CURRENCY) {
                  tasks.add(new Callable&lt;HashMap&gt;() {
                          public HashMap call() throws Exception {
                                  return getRates(ccy);
                          }
                  });
          }
          ExecutorService executorPool = Executors.newCachedThreadPool();
          final List&lt;Future&lt;HashMap&gt;&gt; listRates = executorPool.invokeAll(tasks, 3600, TimeUnit.SECONDS);
  
          for (Future&lt;HashMap&gt; rate : listRates) {
                  HashMap ccyRate = rate.get();
                  System.out.println("Value of £1 in " + ccyRate.get("CCY") + " is " + ccyRate.get("RATE"));
          }
  </code></pre>
  
  <p>I am lacking the credit to pass the values from hashmap to preparedStatement.</p>
  
  <pre><code>        String sql="update currency set currency_name='"+Value1+"'";
          preparedstatement=connection.prepareStatement(sql); 
          preparedstatement.execute();
  </code></pre>
  
  <p>I have the entire class here on this link fully functioning to keep the question clean >><a href="http://pastebin.com/HGtQ3qqW" rel="nofollow">linke</a>&lt;&lt;&lt;</p>
  
  <p>this is the output of the programe which i would like to store into MYSQL Ideally i would like to store </p>
  
  <blockquote>
    <p>ccyRate.get("CCY") and  ccyRate.get("RATE")</p>
  </blockquote>
  
  <pre><code>checkRateAllAtEnd :
  Value of £1 in AED is 5.9201
  Value of £1 in AFN is 82.4359
  Value of £1 in ALL is 171.681
  Value of £1 in AMD is 650.4296
  Value of £1 in ANG is 2.8849
  Value of £1 in AOA is 154.4766
  Value of £1 in ARS is 7.9438
  Value of £1 in AUD is 1.5345
  </code></pre>