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:
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 |
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. Hm, according to the docs (but you got the code:)...), the meaning is contrary:
(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.
(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; } } |