cancel
Showing results for 
Search instead for 
Did you mean: 

Access to remote_id in Java

0 Kudos
3,143

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

Accepted Solutions (0)

Answers (3)

Answers (3)

regdomaratzki
Product and Topic Expert
Product and Topic Expert

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;
    }

}
Former Member

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

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.

VolkerBarth
Contributor
0 Kudos

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.

Former Member
0 Kudos

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

  • Russ
Former Member
0 Kudos

Very useful answer. Thanks for provide a relevant information.