Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9087413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:41:27+00:00 2026-06-16T21:41:27+00:00

I am a newbie to Java, My problem is I am trying to insert

  • 0

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.

void checkRateAllAtEnd() throws Exception {
       /** print message  */
    System.out.println("checkRateAllAtEnd :");
        long start = System.nanoTime();

        List<Callable<HashMap>> tasks = new ArrayList<Callable<HashMap>>();
        for (final String ccy : CURRENCY) {
                tasks.add(new Callable<HashMap>() {
                        public HashMap call() throws Exception {
                                return getRates(ccy);
                        }
                });
        }
        ExecutorService executorPool = Executors.newCachedThreadPool();
        final List<Future<HashMap>> listRates = executorPool.invokeAll(tasks, 3600, TimeUnit.SECONDS);

        for (Future<HashMap> rate : listRates) {
                HashMap ccyRate = rate.get();
                System.out.println("Value of £1 in " + ccyRate.get("CCY") + " is " + ccyRate.get("RATE"));
        }

I am lacking the credit to pass the values from hashmap to preparedStatement.

        String sql="update currency set currency_name='"+Value1+"'";
        preparedstatement=connection.prepareStatement(sql); 
        preparedstatement.execute();

I have the entire class here on this link fully functioning to keep the question clean >>linke<<<

this is the output of the programe which i would like to store into MYSQL Ideally i would like to store

ccyRate.get(“CCY”) and ccyRate.get(“RATE”)

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:41:28+00:00Added an answer on June 16, 2026 at 9:41 pm

    Your addCurrency method is wrong – Not only you’re not gaining anything by providing the preparedStatmenet as parameter , you’re not gaining anything when trying to close it,
    as it is null at that point.
    Please show us the exact error/exception you’re having and I’ll edit my answer accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a Java newbie and ran into a bit of a problem. I want
I'm a newbie on Java EE and got a problem that I don't understand
I'm a newbie in java and I have a small problem. I want to
Java newbie here, I am trying to find the output of the following chunk
I'm a Java newbie. I'm trying to figure out whether a number is a
I am newbie in Java and just trying to convert a variable according to
I have this Java problem, which I suspect it relates to a higher-level algorithm,
I am newbie in java. I am facing problem now. My purpose is to
i am newbie to java/eclipse and also to creating web services.Now i am trying
i'm a total newbie to java and Alfresco and i have this simple problem:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.