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?
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
0
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

0
CEHJCommented:
I don't know that API but there's no flushing or closing of the Writer in that code
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Omer-PitouAuthor Commented:
The API is openCSV
import com.opencsv.CSVReader;
import com.opencsv.CSVWriter;
http://opencsv.sourceforge.net/apidocs/index.html
0
CEHJCommented:
OK - my observations remain the same and i note that the writer has not only a close method, but also a flush method
0
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.
0
CEHJCommented:
You need to call close when you're done writing. In your case, you can probably ignore flush()
0

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
0
CEHJCommented:
Your pleasure and gratitude is worth the additional 500 ;)
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.