Dieses Beispiel zeigt eine Verbindung zu einem MobiLink-Server zur Synchronisation der Clientdatenbank mit einer konsolidierten Datenbank (in diesem Fall SQL Anywhere).
Wechseln Sie zum folgenden Verzeichnis: Beispielverzeichnis\UltraLiteJ.
Hinweise zum Speicherort von Beispielverzeichnis finden Sie unter Beispielverzeichnis.
Führen Sie das CreateSales-Beispiel aus:
rundemo CreateSales |
Führen Sie den folgenden Befehl aus, um den MobiLink-Server zu starten:
start_ml |
Führen Sie den folgenden Befehl aus (mit Berücksichtigung der Groß- und Kleinschreibung):
rundemo Sync |
Wenn das Beispiel abgeschlossen ist, fahren Sie den MobiLink-Server herunter. Siehe MobiLink-Server stoppen.
// ***************************************************** // Copyright (c) 2006-2010 iAnywhere Solutions, Inc. // Portions copyright (c) 2006-2010 Sybase, Inc. // All rights reserved. All unpublished rights reserved. // ***************************************************** // This sample code is provided AS IS, without warranty or liability // of any kind. // // You may use, reproduce, modify and distribute this sample code // without limitation, on the condition that you retain the foregoing // copyright notice and disclaimer as to the original iAnywhere code. // // ********************************************************************* package com.ianywhere.ultralitej.demo; import com.ianywhere.ultralitej12.*; /** * Sync: sample program to demonstrate Database synchronization. * * Requires starting the MobiLink Server Sample using start_ml.bat */ public class Sync { /** * mainline for program. * * @param args command-line arguments * */ public static void main ( String[] args ) { try { Configuration config = DatabaseManager.createConfigurationFile( "Demo1.ulj" ); Connection conn = DatabaseManager.createDatabase( config ); PreparedStatement ps = conn.prepareStatement( "CREATE TABLE ULCustomer" + "( cust_id int NOT NULL PRIMARY KEY" + ", cust_name VARCHAR(30) NOT NULL" + ")" ); ps.execute(); ps.close(); // // Synchronization // // Version set for MobiLink 12.0.x SyncParms syncParms = conn.createSyncParms( SyncParms.HTTP_STREAM, "50", "custdb 12.0" ); syncParms.getStreamParms().setPort( 9393 ); conn.synchronize( syncParms ); SyncResult result = syncParms.getSyncResult(); Demo.display( "*** Synchronized *** bytes sent=" + result.getSentByteCount() + ", bytes received=" + result.getReceivedByteCount() + ", rows received=" + result.getReceivedRowCount() ); conn.release(); } catch( ULjException exc ) { Demo.displayException( exc ); } } } |
![]() |
Kommentieren Sie diese Seite in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |