We are running SQLAnywhere and MobiLink 16.0.0.1915.

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 (
            ianywhere.ml.script.InOutInteger authentication_status,
            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
146111219
accept rate: 0%


To get the remote ID, see DBConnectionContext.getRemoteID(): http://dcx.sybase.com/index.html#sa160/en/mlserver/mobilink-srvjava-dbconnectioncontext-int-getremoteid-met.html

To determine first synchronization, there is the s.new_remote_id parameter: http://dcx.sybase.com/index.html#sa160/en/mlserver/authenticate-user.html*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

RussC_FromSAP
1.3k11030
accept rate: 18%

edited 15 Sep '14, 09:48

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

s.new_remote_id
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 ianywhere.ml.script.*;
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(
        ianywhere.ml.script.InOutInteger 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() );
        authStatus.setValue(1000);
    }

    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
5.4k33579
accept rate: 39%

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

Jimadams
0
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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×299
×65
×19

question asked: 15 Sep '14, 04:52

question was seen: 954 times

last updated: 16 Sep '14, 04:06