on 2014 Sep 15 5:52 AM
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
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; } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very useful answer. Thanks for provide a relevant information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
8 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.