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

  • Home
  • SEARCH
  • 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 7644355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:40:06+00:00 2026-05-31T09:40:06+00:00

I am new to mysql and am having a problem updating my sql database

  • 0

I am new to mysql and am having a problem updating my sql database from my java program.My java program performs all the calculations and stores the values to be updated in a string array of size 2000.My sql database contains the following columns
name price high low
my string array stores the price, high,low which are separated by commas.(I actually queried yahoo finance and stored the csv file in a string).
Now i need to update the price,high,low using the data in the string.How do i do it. Or is it possible to directly upload the data returned from yahoo finance into my database.

Code

            URL yahoofin = new URL("http://finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=nl1sjkm3m4r"); 

            URLConnection yc = yahoofin.openConnection(); 
            BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream())); 
            String inputLine; 

            while ((inputLine = in.readLine()) != null) 
            {  

            }

The code i am using to update a single stock

 Statement stmt = conn.createStatement() ;
   // Execute the Update
  int rows = stmt.executeUpdate( "UPDATE tablename SET id = 9842 WHERE name='name'" ) 
  • 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-05-31T09:40:07+00:00Added an answer on May 31, 2026 at 9:40 am

    Construct a prepared statement:

    String sql = "update stock set price = ?, high = ?, low = ? where name = ?"; 
    PreparedStatement stmt = connection.prepareStatement(sql);
    

    Then iterate through the line of the CSV file, and parse each line into a data structure (or a simple array) containing the 4 fields:

    while ((inputLine = in.readLine()) != null) {  
        StockLine line = parseStockLine(inputLine);
    }
    

    And for each line, bind the parameters and execute the statement:

    while ((inputLine = in.readLine()) != null) {  
        StockLine line = parseStockLine(inputLine);
        stmt.setBigDecimal(1, line.getPrice());
        stmt.setBigDecimal(2, line.getHigh());
        stmt.setBigDecimal(3, line.getLow());
        stmt.setString(4, line.getName());
        stmt.executeUpdate();
    }
    

    To speed up things, you may use a batch:

    while ((inputLine = in.readLine()) != null) {  
        StockLine line = parseStockLine(inputLine);
        stmt.setBigDecimal(1, line.getPrice());
        stmt.setBigDecimal(2, line.getHigh());
        stmt.setBigDecimal(3, line.getLow());
        stmt.setString(4, line.getName());
        stmt.addBatch();
    }
    stmt.executeBatch();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently having a problem selecting a certain item from a mySQL database.
I'm new to MySQL and I'm having problem with a query using PHP. See
I'm having a problem echoing a single line from a sql query. I'm still
I having a weird problem with Entity Framework with MySql database. Here's the code
I am having a hard time migrating my MySQL 4.1 database from old 16-byte
I am relatively new to PHP/MySQL and have been having a problem that I
I'm new to php and MySQL and I'm having a problem trying to work
I'm having problems updating a mysql database. I want to run this script on
I was having problems updating information in my SQL database using my vb.net application,
I am trying to learn mysql and having some problem with updating/adding data to

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.