代码之家  ›  专栏  ›  技术社区  ›  jwl

查找到iSeries的特定JDBCSQL连接的实际作业号?

  •  2
  • jwl  · 技术社区  · 15 年前

    我使用jtopenjdbc驱动程序连接到iSeries(aka AS/400,ibmsystem-I,IBMi,WTH…)。我对某个特定语句有问题,似乎需要返回到实际的SQL作业qsrvr(或qzdasonit?)找到更多细节。唯一的问题是系统上有成百上千个这样的程序。有没有一种简单的方法来确定实际处理SQL连接或特定语句的作业?

    2 回复  |  直到 15 年前
        1
  •  4
  •   svachon    15 年前

    从类AS400JDBCConnectionHandle的JT400 javadoc:

    公共字符串getServerJobIdentifier()

    Returns the job identifier of the host server job corresponding to this
    

    连接。每个JDBC连接都是 与上的主机服务器作业关联 系统。格式为:

        * 10 character job name
        * 10 character user name
        * 6 character job number 
    
    Note: Since this method is not defined in the JDBC Connection
    

    接口,您通常需要 PooledConnection.getConnection连接()到

          String serverJobIdentifier = ((AS400JDBCConnectionHandle)connection).getServerJobIdentifier();
    
    
    Returns:
        The server job identifier, or null if not known. 
    Throws:
        SQLException - If the connection is not open.
    
        2
  •  1
  •   user2338816    12 年前

    如果远程应用程序不能被修改,服务器端有两种可能。最常用的方法是搜索对通过连接登录的用户配置文件(*USRPRF)具有锁定的作业。当用户配置文件在作业中处于活动状态时,系统不允许删除该用户配置文件,因此锁定非常方便:

    WRKOBJLCK logonuser *USRPRF
    

    NETSTAT 命令可以列出连接:

    NETSTAT *CNN
    

    可以对照列出的服务检查远程IP地址,以确定特定的连接。可以从那里访问匹配的系统作业。

        3
  •  0
  •   Brad Bentley    5 年前

    如果不使用连接池(不知道为什么不使用连接池:),那么下面的方法更安全,但是…)

    public static String getQualifiedJobNumber(Connection connection) throws SQLException, CustomException {
        if (connection != null && !connection.isClosed()) {
            String jobName = null;
            try {
                AS400JDBCConnectionHandle handle = ((AS400JDBCConnectionHandle) connection);
                if (handle != null) {
                    jobName = handle.getServerJobIdentifier();
                }
            } 
            catch (ClassCastException e) {
                try {
                    AS400JDBCConnection as400Connection = ((AS400JDBCConnection) connection);
                    if (as400Connection != null) {
                        jobName = as400Connection.getServerJobIdentifier();
                    }
                }
                catch (ClassCastException e2) {
                    throw new CustomException("Attempting to retrieve an AS400 qualified job number from a non-AS400 connection");
                }
            }
            if (jobName != null && jobName.length() == 26) {
                return jobName.substring(20) + "/" + jobName.substring(10, 20).trim() + "/" + jobName.substring(0, 10).trim();
            }
        }
        return null;
    }