Google App-Engine Java Batch Update

Posted by Manjoor on Stack Overflow See other posts from Stack Overflow or by Manjoor
Published on 2010-05-18T06:24:20Z Indexed on 2010/05/18 6:30 UTC
Read the original article Hit count: 232

I need to upload a .csv file and save the records in bigtable. My application successfully parse 200 the records in the csv files and save to table.

Here is my code to save the data.

for (int i=0;i<lines.length -1;i++) //lines hold total records in csv file
{
   String line = lines[i]; 

   //The record have 3 columns integer,integer,Text 

   if(line.length() > 15)
   {
    int n = line.indexOf(",");

    if (n>0)
    {
        int ID = lInteger.parseInt(ine.substring(0,n));
        int n1 = line.indexOf(",", n + 2);

        if(n1 > n)
        {
           int Col1 = Integer.parseInt(line.substring(n + 1, n1));
           String Col2 = line.substring(n1 + 1);

           myTable uu = new myTable();

           uu.setId(ID);
           uu.setCol1(MobNo);

           Text t = new Text(Col2);                     
           uu.setCol2(t);

           PersistenceManager pm = PMF.get().getPersistenceManager();
               pm.makePersistent(uu);                                                   
           pm.close();
        }
       }
    }
}

But when no of records grow it gives timeout error.

The csv file may have upto 800 records. Is it possible to do that in App-Engine?

(something like batch update)

© Stack Overflow or respective owner

Related posts about google

Related posts about google-app-engine