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 7910739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:59:03+00:00 2026-06-03T12:59:03+00:00

I am writing the result set of 1st database query result set to first

  • 0

I am writing the result set of 1st database query result set to first 2 columns of csv file.

Then I am trying to write header name ‘HSS1’ in third column of csv which is going to have result set of another database table. Am not doing the second step the right way.

1st step:

        fw = new FileWriter(filename);
        fw.append("CID");
        fw.append(',');
        fw.append("Uniques");
        fw.append('\n');

        rs=stmt.executeQuery(sql);

            while(rs.next()){

                fw.append(rs.getString(1));
                fw.append(',');
                fw.append(rs.getString(2));
                fw.append('\n');
                fw.flush();

Writing header name in csv file for the second database query

second step

try{

    fw.append(",");
    fw.append(",");
    fw.append("HSS1");
    fw.append('\n');

    fw.close();

HSS1 gets written to 3rd column but it’s not the header.

Thanks

  • 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-03T12:59:04+00:00Added an answer on June 3, 2026 at 12:59 pm

    append() always appends to the end of the file.

    What you need to do is move the code to the right place and iterate over both database queries at the same time (in one loop).

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

Sidebar

Related Questions

I'm writing two LINQ queries where I use my first query's result set in
I'm writing a set of results to an XML file. Each result set contains
I'm writing a simple diagnostic query then attempting to execute it in the Oracle
I have a very complex Linq to SQL query that returns a result set
I am writing a program that will query an MS access database, return the
I'm writing a set of numeric type conversion functions for a database engine, and
I am writing a query that will retrieve data that match a set of
I am writing a universal application. As a result I have set it up
I'm writing a server in C# which creates a (long, possibly even infinite) IEnumerable<Result>
Help needed. Im writing a function that returns result of ajax call but i

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.