Login/Registration with Sybase from any mobile devices for offline applications.
- Database Creation
This article tend to address registration and login issue with Sybase.
There are two ways to sync with Sybase RBS and MBS.
RBS is the replication based sync which is usually default available for all devices except IOS. However from Sybase 2.1.3 IOS will also migrate to RBS.
MBS (message BS) was only supported for IOS. For details about replication methods you can see the following link.
As RBS is the way forward and all offline application are moving to it . I will summaries the way to login/connect using RBS.
If you are trying to connect your Windows mobile /Android /IOS devices to sybase. Do it in following order.
Registration occurs between SUP —–> Mobile devices. In RBS scenario registration is auto. You not need to register user in Sybase server and use activation code. The only thing that need to be maintained in server is auto registration template.
Auto registration template should be maintained in such a way that it should give unique result for your input parameters.
Eg if you have give “application id” than there should be only one auto registration template for each application, if you give “application id ” and security configuration, then combination should be unique.
Most scenario of Login/Registration fails here.
Registration code for android devices is a follows. .
com.sbase.mobile.Application app = com.sybase.mobile.Application.getInstance();
if (app.getApplicationIdentifier()== null)
ConnectionProperties profile = app.getConnectionProperties();
//if user name pwd doesn’t work then create credential
LoginCredentials logcred = new LoginCredentials(userid,password);
if (app.getRegistrationStatus()!= RegistrationStatus.REGISTERED)
After execution of the last line of above code, you must be able to see an entry in SCC-> application connections, showing your simulator or device id . This random number is generated by SCC and assigned to your device/simulator. If you reregister the device again with different user, it will generate a different number for same device/simulator.
One important thing to notice is same user can’t be registered with 2 devices for a give device type. Haven’t tried multiple devices for same user yet, so can’t comment.
Once a device is registered. It is by default authenticated., user need not to authenticate it twice.
However for every subsequent synchronization, user should open connection.
if (app.getConnectionStatus()!= ConnectionStatus.CONNECTED)
However as our application should work in offline more in case of no network connection, you can use offlineauthentication method as well.
Once user is registered and authenticated, the MBO database has to be created in device, the code is straight forward and self explanatory. Following is code for android device
ConnectionProfile conprof = SAPRetailExDB.getConnectionProfile();
File dir = Environment.getExternalStorageDirectory();
File yourFile = new File(dir, “RETAILEXECUTION/SAPRETAILEX10.ulj”);
Connection profile determine the database connection properties õf local database.
Once database has been created, user registered and authenticated, the final step is synchronization.
For sync, first you need to maintain the synchronization profile, which unfortunately is also named as ConnectionProfile and adds to confusion(people tend to think it is same as connectionprofile) .
However this profile is purely used for sync, and its properties are prefilled from server, when user is registered. Still it is safe to provide all possible value again manually
ConnectionProfile syncProfile = SAPRetailExDB.getSynchronizationProfile();
LoginCredentials cred = new LoginCredentials(userid,password);
Once synchronization profile is set the only thing pending is to set the personalization parameter and sync. Personalization parameter is an important concept and has to be mandatorily given even if it is not being used. It has to be saved blank for the MBO’s you have declared them in server.
If personalization parameters are not maintained, the sync will fail, even if you are not using them.
PersonalizationParameters pp = SAPRetailExDB.getPersonalizationParameters();
// Assign values to the PersonalizationParameters object:
//String value =”002BC74DB9D8446FE10000000A428970″;
String value = generateRandomId();
Each of the above steps has more intricacies to it. I have just jotted down the most common things to do to achieve the sync. However for each of above topic it is advised to read in great length in http://infocenter.sybase.com/help/index.jsp?workingSet=SUP2.1
Happy Coding !!!!!