Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

We are running SQLAnywhere and MobiLink

I need access to the remote_id of the current synchronization in Java.

I wrote a Java class/method for the authentication of the user:

 public void authenticateUser (
            String user,
            String pwd,
            String newPwd )

As parameters I only get the username and password - to verify the credentials, I also need access to the consolidated database and to the remote_id of the current synchronisation.

Is it possible in this Java code to figure out if a connection via MobiLink is the initial synchronization or a following one?

Thanks for your help! Alex

asked 15 Sep '14, 04:52

Alexander%20Ilg's gravatar image

Alexander Ilg
accept rate: 50%

To get the remote ID, see DBConnectionContext.getRemoteID():

To determine first synchronization, there is the s.new_remote_id parameter:*d5e14986. This will be non-NULL if the remote ID has never synchronized to this MobiLink server and consolidated database.

permanent link

answered 15 Sep '14, 09:33

RussC_FromSAP's gravatar image

accept rate: 18%

edited 15 Sep '14, 09:48

Hm, according to the docs (but you got the code:)...), the meaning is contrary:

VARCHAR(128). The MobiLink remote ID, if the remote ID is new in the consolidated database. If the remote ID is not new, the value is null.

(15 Sep '14, 09:43) Volker Barth

You are correct Volker. I flipped it. Call me "out of sync" on that one. ;-) I'll edit my response above.

  • Russ
(15 Sep '14, 09:48) RussC_FromSAP

Here's some sample java code that accesses the remote id value in the authenticate user script, and accesses the last download variable in the begin download event. If the current MobiLink user has never synchronized, or has never synchronized successfully, this value is set to 1900-01-01. If you need a connection to the consolidated database, the DBConnectionContext has a getConnection method that will return the existing Connection to the consolidated database for this synchronization (i.e. MobiLink will COMMIT and ROLLBACK on this connection and you SHOULD NOT). If you'd like to establish another connection to the consolidated, the ServerContext interface has a newConnection method that will establish a new connection to the consolidated database using the same connection parameters used by the MobiLink Server.

import java.sql.*;
import java.util.*;

public class Example {

    DBConnectionContext _dbcc;
    Boolean             _debug = true;
    Timestamp           _last;

    public Example( DBConnectionContext cc ) throws SQLException {
        if( _debug ) System.out.println( "====DBG==== DBConnectionContext Constructor" );
        _dbcc = cc;

    public void authUser( authStatus,
        String user,
        String pwd,
        String newPwd )
    throws java.sql.SQLException {
        if( _debug ) System.out.println( "====DBG==== authUser" );
        System.out.println( "====DBG==== remoteID : " + _dbcc.getRemoteID() );

    public void beginDownload ( Timestamp last_download, String user ) throws SQLException {
        if( _debug ) System.out.println( "====DBG==== beginDownload" );
        _last = last_download;

permanent link

answered 15 Sep '14, 10:27

Reg%20Domaratzki's gravatar image

Reg Domaratzki
accept rate: 36%

edited 15 Sep '14, 10:34

Very useful answer. Thanks for provide a relevant information.

permanent link

answered 16 Sep '14, 04:06

Jimadams's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 15 Sep '14, 04:52

question was seen: 2,920 times

last updated: 16 Sep '14, 04:06