Forum Stats

  • 3,827,529 Users
  • 2,260,790 Discussions
  • 7,897,291 Comments

Discussions

ADF Mobile Client, SQLite - Olite Sync exception

User9170343-Oracle
User9170343-Oracle Member Posts: 3
edited Jun 2, 2010 6:04AM in JDeveloper and ADF
Hi,
I'm developing an ADF Mobile client application, which uses SQLite as the database in the Mobile client (Blackberry simulator). Need to synchronize the local data with the Oracle Lite Server Repository through API. Getting the following exception, (able to see it by attaching blackberry JDE debugger to the simulator), but not getting the stack trace. I've started MDS service in blackberry simulator and loaded mSync.cod
osync_rim.cod before executing the application.

Exception:

OSSE Exception.....
Error Code : -12011
Error Message: Plugin has thrown an exception, see the cause
Cause: oracle.opensync.osp.PluginException
Cause Msg : null
OSSE :oracle.opensync.ose.OSEException(-12011): Plugin has thrown an exception, see the cause <- oracle.opensync.osp.PluginException
No stack trace
No stack trace
============================================================================================

Following is the listener configured for synchronization on a button click.

public void syncWithServer() {
try {
System.out.println("Starting Synchronization....");
//set up username and password
String user = "SYNCUSER";
String pwd = "SYNCUSER";
OSESession sess = new OSESession(user, pwd.toCharArray());
//Identify Mobile Server URL
// sess.setURL("localhost:80");
sess.setURL("localhost:80/webtogo");
sess.selectPub("InventoryAdj4");

//Identify the progress listener, myProgressTracker
sess.setProgress(new SyncProgressTracker());
//Initiate Sync
sess.sync();

this.flgSynch = "Sync Done";
System.out.println("Finished Synchronization");
} catch (OSEException osse) {
System.out.println("OSSE Exception.....");
System.out.println("Error Code : " + osse.getErrorCode());
System.out.println("Error Message: " + osse.getMessage());
System.out.println("Cause: " + osse.getCause());
System.out.println("Cause Msg : " + osse.getCause().getMessage());
System.out.println("OSSE :" + osse.toString());
osse.getCause().printStackTrace();
osse.printStackTrace();
}
catch (Exception ex) {
System.out.println("Exception.....");
ex.printStackTrace();
System.err.println(ex);
System.out.println(ex.toString());
}
}

Can any one help ......

Thanks,
Sreekumar
Tagged:

Answers

  • Sreekumar, first off, this functionality will be available in the ADF Mobile Client production version as an API you can just call so you won't need to specify all of this yourself. Basically you'll just call some Sync funtion and it will do everything for you. If you want to do this programmatically for now, I've included the code below. The one caveat is that it will require a patch for the Mobile Server that should be out very shortly. I'll post another reply to this when I get more info on when the patch is ready and where to get it.





    import oracle.adfnmc.java.sql.DBHelper;
    import oracle.opensync.ose.OSEException;
    import oracle.opensync.ose.OSESession;

    ...

    public void PerformSync() {
    OSESession session = null;

    try {
    session = new OSESession("syncuser"); // specify the sync username
    session.shareConnection("CCMOBILE",
    DBHelper.GetNativeDBHandle(this)); // specify the name of the DB you want to sync
    session.setPassword("adfmc".toCharArray()); // specify the password.
    session.setURL("myhost:myport"); // whatever the host name and port is for your mobile server
    session.setUseFiles(true);
    session.setEncryptionType(OSESession.ENC_NONE);
    session.sync();
    } catch (OSEException e) {
    System.out.println(e.getMessage());
    Trace.log(Trace.TEST_LOGNAME, Level.SEVERE, this.getClass(),
    "Sync Exception: " + e.getMessage(), null);
    } finally {
    try {
    session.close();
    DBHelper.ReturnNativeDBHandle(this);
    } catch (OSEException e) {
    System.out.println(e.getMessage());
    Trace.log(Trace.TEST_LOGNAME, Level.SEVERE, this.getClass(),
    "Sync Close Exception: " + e.getMessage(), null);
    }
    }
    }

    You'll also need to create a new class called DBHelper and give it the specified package.
    package oracle.adfnmc.java.sql;

    import net.rim.device.api.database.Database;
    import oracle.jbo.server.ApplicationModuleImpl;
    import oracle.jbo.server.DBTransactionImpl;

    public class DBHelper {
    public DBHelper() {
    super();
    }

    public static Database GetNativeDBHandle(ApplicationModuleImpl appmodule) {
    DBTransactionImpl db = (DBTransactionImpl)appmodule.getDBTransaction();
    SQLiteConnection conn =
    (SQLiteConnection)db.getPersistManagerConnection();
    conn.setAutoCommit(true);
    return conn.getNativeDBHandle();
    }

    public static void ReturnNativeDBHandle(ApplicationModuleImpl appmodule) {
    DBTransactionImpl db = (DBTransactionImpl)appmodule.getDBTransaction();
    SQLiteConnection conn =
    (SQLiteConnection)db.getPersistManagerConnection();
    conn.setAutoCommit(false);
    }
    }
  • It turns out this patch was already released.

    You can get it off of support.oracle.com. The patch id is 9743448.

    Just click the Patches & Updates tab and then enter the patch id above and select your OS and then it will display the patch and you can download it and follow the instructions on how to install it.
  • Denis,
    Thank you very much for the detailed reply. But i was unable to figure out how to access to the current ApplicationModuleImpl, which is being passed to DBHelper.GetNativeDBHandle(this)); Could you please help me with a sample code for this?

    Thanks & Regards,
    Sreekumar
This discussion has been closed.