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

SQL Anywhere 11.0.1 (中文) » MobiLink - 服务器管理 » MobiLink 服务器 API » 使用 Java 语言编写同步脚本 » 用于 Java 的 MobiLink 服务器 API 参考

 

DBConnectionContext 接口

语法
public ianywhere.ml.script.DBConnectionContext
注释

用于获取和访问当前数据库连接相关信息的接口。DBConnectionContext 实例会传递给包含脚本的类的构造函数。如果后台线程或在连接生存期以外需要上下文,请使用 ServerContext 类。

另请参见
成员

ianywhere.ml.script.DBConnectionContext 的所有成员,包括所有继承的成员。

示例

以下示例说明应如何创建用于同步脚本中的类级 DBConnectionContext 实例。DBConnectionContext getConnection 方法会获取表示当前 MobiLink 统一数据库连接的 java.sql.Connection 实例。

import ianywhere.ml.script.*;
import java.io.*;
import java.sql.*;

public class OrderProcessor {
    DBConnectionContext _cc;

    public OrderProcessor(DBConnectionContext cc) {
        _cc = cc;
    }

    // The method used for the handle_DownloadData event.
    public void HandleEvent() throws SQLException {
        java.sql.Connection my_connection = _cc.getConnection();
        // ... 
    }

    // ...
}
小心

DBConnectionContext 实例不能在调用 Java 代码的线程之外使用。


getConnection 方法
getDownloadData 方法
getProperties 方法
getRemoteID 方法
getServerContext 方法
getVersion 方法