Reply
Contributor
slider
Posts: 3
0

Problem about export Blob data from SF by java

I want to export all Attachment data from SF, the volumn is too big(nearly 18G) and seems like it cannot be put into one csv file by DataLoader.(I tried and failed for  "java heap space").

So I tried to write a java batch, use for loop, make csv file each 500 records. Then I got a very strange exception.

 

Here is my code:

String str = "select Id, ParentId, Name, Description, BodyLength, Body from Attachment limit 10";
QueryResult results = conn.query(str);
for (int i = 0; i < results.getSize(); i++) {
    SObject obj = (SObject) results.getRecords()[i];
    ******
}

 I debugged this program, and I saw "results.getSize() = 10", but "results.getRecords() = 1"!!!

So when i comes to 1, list out of bound exception.

 

Then I tried not selecting the Body

String str = "select Id, ParentId, Name, Description, BodyLength from Attachment limit 10";
QueryResult results = conn.query(str);
for (int i = 0; i < results.getSize(); i++) {
    SObject obj = (SObject) results.getRecords()[i];
    ******
}

 I saw  "results.getSize() = 10", and "results.getRecords() = 10".

 

What's the problem? How can I get the Blob data?

I'm waiting for your help. Thanks.