OpenCSV Library: Export ResultSet to csv

Hi Sirs,

I am playing with this library and my code is the one below.
       writer = new CSVWriter(new FileWriter(csv, true));
       writer.writeAll(myResultSet, true);

This resultSet has 2028 rows, but I am suprised that only 2000 rows are exported.
I tried with another table that 61 rows, and no rows were exported.

Is there someone familiar with OpenCSV, especially exporting a ResultSet to csv?

Regards
Omer-PitouAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Please post the full writing code
Omer-PitouAuthor Commented:
myDBAccessMgr is a separate class  dealing with all JDBC stuffs (Driver, Connection, Statement, executeQuery, etc.)
        myResultSet = myDBAccessMgr.executeQuery("SELECT * FROM compte");
        String csv = "c:/autre/pointstestSQLCentres.csv";
        CSVWriter writer = null;
        try {
           writer = new CSVWriter(new FileWriter(csv, true));
       } catch (IOException ex) {
           Logger.getLogger(TestOpenCSVReadALL.class.getName()).log(Level.SEVERE, null, ex);
       }
       try {
           writer.writeAll(myResultSet, true); //writer is instance of CSVWriter
       } catch (SQLException ex) {
           Logger.getLogger(TestOpenCSVReadALL.class.getName()).log(Level.SEVERE, null, ex);
       } catch (IOException ex) {
           Logger.getLogger(TestOpenCSVReadALL.class.getName()).log(Level.SEVERE, null, ex);
       }

Open in new window

CEHJCommented:
I don't know that API but there's no flushing or closing of the Writer in that code
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Omer-PitouAuthor Commented:
The API is openCSV
import com.opencsv.CSVReader;
import com.opencsv.CSVWriter;
http://opencsv.sourceforge.net/apidocs/index.html
CEHJCommented:
OK - my observations remain the same and i note that the writer has not only a close method, but also a flush method
Omer-PitouAuthor Commented:
Hi CEHJ,
I am a little bit lost with these concepts. Can this impact the export?
As I said before, I got 2000 rows over 2028.
Where should I include the close and flush methods

Thanks for your usual support.
CEHJCommented:
You need to call close when you're done writing. In your case, you can probably ignore flush()

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Omer-PitouAuthor Commented:
It works. I can't believe that a small detail like this can break the export.
THANK YOU VERYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY MUCH..
I WISH I COULD GIVE 1000 points
CEHJCommented:
Your pleasure and gratitude is worth the additional 500 ;)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.