Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » UltraLiteJ » UltraLiteJ 参考 » UltraLiteJ API 参考

 

SyncObserver 接口

接收同步进度信息。

语法
public SyncObserver
注释

要在同步期间接收进度报告,您必须创建一个执行该任务的新类,并使用 setSyncObserver 函数实现此类。

下面的示例说明了一个简单的 SyncObserver 接口:

class MyObserver implements SyncObserver {
    public boolean syncProgress(int state, SyncResult result) {
        System.out.println(
            "sync progress state = " + state
            + " bytes sent = " + result.getSentByteCount()
            + " bytes received = " + result.getReceivedByteCount()
        );
        return false;   // Always continue synchronization.
    }
    public MyObserver() {} // The default constructor.
}

按如下方法启用上面的观察器类:

// J2ME Sample
Connection conn;
ConfigRecordStore config = DatabaseManager.createConfigurationRecordStore(
    "test.ulj"
    );
try {
    conn = DatabaseManager.connect(config);
} catch(ULjException ex) {
    conn = DatabaseManager.createDatabase(config);
    // Create the schema here.
}
SyncParms.setSyncObserver(new MyObserver());
成员

SyncObserver 的所有成员,包括所有继承的成员。


syncProgress 方法