cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with startup synchronization

Former Member
0 Kudos

Hello Friends,

In my sample program getting the customer list, I am synchronizing the data base at the application startup. below is the code.

try {

                              Log.d(TAG, "Synchronizing..");

                              // Set synchronization profile

                              ConnectionProfile cp = SampleOneDB.getSynchronizationProfile();

                              cp.setServerName(SERVER);

                              cp.setPortNumber(SYNC_PORT);

                              cp.setNetworkProtocol(PROTOCOL);

                              cp.setAsyncReplay(true);

                              cp.setDomainName(DOMAIN);

                              cp.save();

                    } catch (Exception e) {

                              e.printStackTrace();

                              Log.d(TAG, e.getMessage());

                    }

try {

                              SampleOneDB.subscribe();

                              SynchronizationGroup sg = SampleOneDB

                                                  .getSynchronizationGroup("default");

                              sg.setEnableSIS(true);

                              sg.save();

  SampleOneDB.synchronize();

                    } catch (Exception e) {

                              e.printStackTrace();

                              Log.d(TAG, e.getMessage());

                    }

after this code execution i m getting my initial screen with a button. if i click on the button i should get the customers list. below is the code.

GenericList<customer> customerIds = Customer.findAll();

here Customer is my MBO.  after execution of this statement i am getting the size of list is 0. but i have the customers in my database.  Can some body help me in this.

thanks,

Accepted Solutions (0)

Answers (1)

Answers (1)

midhun_vp
Active Contributor
0 Kudos

Your codes looks fine. Use the below code for findall and check

for (Customer production : Customer.findAll()) {

 

  String Name = production.getName;

                                                            }

Former Member
0 Kudos

Hello Midhun,

I think there is no difference in this code.  When ever I call "Customer.findAll()" i m getting the result size 0.  So obviously its not going inside the for stmt.

As an alternative I tried with below code at the time of start up instead of the code which i sent in my first post.

CustomerSynchronizationParameters syncParameter = Customer

                                                  .getSynchronizationParameters();

                              syncParameter.delete();

                              syncParameter = Customer.getSynchronizationParameters();

  syncParameter.setState_sp("MN");

  syncParameter.save();

                              SampleOneDB.synchronize();

after this if i were call Customer.findAll() i am getting the result set size as 4, but those 4 are of state "MN".  But here i want to synchronize the complete package not just with the state param.

Can you plz help me.

Thanks

midhun_vp
Active Contributor
0 Kudos

The MBO is having mandatory load parameter and you created sync parameter for it. Hence when you are passing load sync parameter only you will get the data. Findall will not fetch all the data since mandatory load parameters are present. If the the load parameter is nullable / there is no load parameter only you will get all the data using findall.

- Midhun VP

Former Member
0 Kudos

1. By making the sync parameter as nullable also i got the same result size as 0.

2. Also tried by removing the sync parameter,  but unable to deploy the MBO.

what could be the problem in both the cases?

thanks,

midhun_vp
Active Contributor
0 Kudos

My point is that the MBO has a load parameter. If you fill this value only you will get the data. Thats why you are getting "0" for the findall query. Since you have a load parameter you will not get the data for findall. Is the customer MBO associated with any RFC ? The cache DB is not filled while you are making a sync call without any input. if you pass input only the cache will be filled and you will be able to query.

- Midhun VP

Former Member
0 Kudos

Thanks Midhun,

My Customer MBO does not associated with any RFC in this sample.

I have only one sync parameter in my customer table.  Now I want to retrieve the complete customer list into the Android UI. To get this I am trying to do the synchronize at start up.  But as you said I made the sync parameter as nullable and now what should I do to get this?

Thanks,

midhun_vp
Active Contributor
0 Kudos

Are using the customer table available in the sampleDB ? In that case I believe that there is no load parameter for it, then where you are using the sync parameter ? Give a screen of the MBO design and attributes.

Former Member
0 Kudos

Thanks Midhun,

For a quick reply.

here are the attachments what you asked.  plz let me know if u need any more information.

Thanks

midhun_vp
Active Contributor
0 Kudos

In this case you don't have to maintain a sync key.Delete the sync key. In queries you will be having a findall query. In the properties of MBO click on query and check it is present. After synchronize call from device you should be able to use findall and it should get you all the data.

- Midhun VP

Former Member
0 Kudos

After removing the sync key while deploying i am getting an exception as shown in attachment.

Thanks

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Once check in server logs what error you are seeing?

Please share server logs fo that particular incident.

Rgrds,

Jitendra

midhun_vp
Active Contributor
0 Kudos

In the MBO properties click on refresh. If there is any query delete it and create it again. Uncheck and check primary keys if any and deploy.

Former Member
0 Kudos

Still I am getting the same problem.  Can you please tell me where can I see the server log?

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

C:\Sybase\UnwiredPlatform\Servers\UnwiredServer\logs

then check servername.log file