如何在我的jdbc/DB2连接中插入其他库? [英] How can I insert additional libraries to my jdbc/DB2 connection?

查看:107
本文介绍了如何在我的jdbc/DB2连接中插入其他库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小的Java程序,以通过jdbc(db2jcc.jar版本1.0.581)将数据写入AS/400 DB2表中,并且将触发器与INSERT操作相关联.此触发器适用于与库(jdta73p10)相关的各种表,这些库与包含我的表(f4104)的库(jdta73p10)不同.

I'm writing a little java program to write data in a AS/400 DB2 table via jdbc (db2jcc.jar version 1.0.581) and a trigger is associated to the INSERT operation. This trigger works on various tables associated with libraries different from that (jdta73p10) which contains my table (f4104).

遵循我用来建立连接并读取可完美运行的数据的代码.

Follows the code I use to establish connection and read data that perfectly runs.

import java.sql.*;
import com.ibm.db2.jcc.*;

public class ProvaNUMEAN13 {

public static void main(String[] args) throws SQLException, ClassNotFoundException {

    DB2DataSource dbds = new DB2DataSource();

    dbds.setDriverType(4);
    dbds.setServerName("a60d45bb");
    dbds.setPortNumber(446);
    dbds.setDatabaseName("prodgrp");
    dbds.setDescription("Prova collegamento");
    dbds.setUser("XXXXX");
    dbds.setPassword("XXXXX");

    Connection con = dbds.getConnection();

    Statement stmtNum = con.createStatement();
    stmtNum.executeQuery("select * from INTERFACCE.NUMEAN13");
    ResultSet rs = stmtNum.getResultSet();

    rs.next();  
    System.out.println("Valore numeratore: " + rs.getString("E13EAN"));
    System.out.println("Tipo numeratore: " + rs.getString("K13KEY"));

    stmtNum.close();

    Statement stmtAnag = con.createStatement();
    stmtAnag.executeQuery("select * from jdta73p10.f4101lb where IMLITM = " + "'" + args[0] + "'");
    ResultSet rsAna = stmtAnag.getResultSet();
    int idCodice = 0;
    if (!rsAna.next()) {

        System.out.println("Il codice " + args[0] + " non esiste in anagrafica!");

    } else {

        idCodice = rsAna.getInt("IMITM");
        System.out.println("idCodice per " + args[0] + ": " + Integer.toString(idCodice));
        Statement stmtQEAN = con.createStatement();
        stmtQEAN.executeQuery("select IVALN, IVCITM, IVLITM, IVDSC1 from jdta73p10.f4104 where IVXRT = 'B ' and IVALN = '8000000000000'");
        ResultSet rsQEAN = stmtQEAN.getResultSet();

        if (rsQEAN.next()) {
            System.out.println("Codice EAN per " + args[0] + " già presente: " + rsQEAN.getString("IVALN"));
            System.out.println("Valore EAN13: " + rsQEAN.getString("IVCITM"));
            System.out.println("Risultato ricerca per EAN13: " + rsQEAN.getString("IVLITM")+" - "+rsQEAN.getString("IVDSC1"));

        }
    }
}
}

问题是当我尝试执行INSERT操作时(如下所示);由于执行触发器,在AS/400中生成了一个错误.

Problem is when I try to execute an INSERT operation (like that below); an error is generated in AS/400 due to trigger execution.

stmtQEAN.execute("insert into jdta73p10.f4104 (IVXRT,IVITM,IVCITM,IVDSC1,IVALN,IVLITM) values ('B ','18539','8000000000000','Prodotto PROVA','8000000000000','ABABABAB')");

这是错误的AS/400端:

This is the error AS/400 side:

消息ID. . . . . . :RNQ0211严重性. . . . . . . :99

Message ID . . . . . . : RNQ0211 Severity . . . . . . . : 99

消息类型. . . . . :查询

Message type . . . . . : Inquiry

发送日期. . . . . . :15年8月1日发送时间. . . . . . :10:01:31

Date sent . . . . . . : 08/01/15 Time sent . . . . . . : 10:01:31

消息. . . . :调用程序或过程时发生错误 * LIBL/PRHWRAPUSE(C G D F). 原因 . . . . . :程序INTERFACCE/TRG_F4104A中的RPG程序TRG_F4104A位于 语句152尝试调用程序或过程* LIBL/WS_MATERI,但是 无法访问程序或过程,库或必需项 服务程序.如果名称为* N,则该调用是过程的绑定调用 指针.

Message . . . . : Error occurred while calling program or procedure *LIBL/PRHWRAPUSE (C G D F). Cause . . . . . : RPG procedure TRG_F4104A in program INTERFACCE/TRG_F4104A at statement 152 attempted to call program or procedure *LIBL/WS_MATERI, but was unable to access the program or procedure, the library, or a required service program. If the name is *N, the call was a bound call by procedure pointer.

恢复. . . :检查作业日志,以获取有关造成原因的更多信息 错误,并与负责程序维护的人员联系. 回复消息的可能选择. . . . . . . . . . . . . . . :

Recovery . . . : Check the job log for more information on the cause of the error and contact the person responsible for program maintenance. Possible choices for replying to message . . . . . . . . . . . . . . . :

D-获取RPG格式的转储.

D -- Obtain RPG formatted dump.

S-获取系统转储.

S -- Obtain system dump.

我的问题是:如何指定触发需求的其他库?在我的旧版工具(用Delphi编写)中,我使用了Client/Access ODBC,其中有一个特殊的字段,您可以在其中输入其他库,但是现在我不知道该怎么做.

My question is: how can I specify the other libraries that trigger need? In a old version of my tools (written in Delphi) I used the Client/Access ODBC where there was a special field where you can enter additional libraries but now I don't know how to do.

推荐答案

夫妇解决方案.

快速实时修复 将触发程序复制到QGPL(临时修订.需要尽快实施永久修订)

quick real time fix Copy the trigger program to QGPL (Temporary fix. A permanent fix would need to be implemented ASAP)

更改用于连接到AS400的用户配置文件的JOBD,以便它具有正确的列表.用于JDBC的用户配置文件应该已经被锁定,或者它是组中用户的jdbc,所以这是一个简单的CHGJOBD JOBD(x)LIBL(xxx xxx xxx xxx),但是必须回收连接.

Change the JOBD of the user profile used to connect to the AS400 so it has the correct list. The user profile used for JDBC should already be locked down or it's the jdbc of a user in a group so this is a simple CHGJOBD JOBD(x) LIBL(xxx xxx xxx xxx) but the connections will have to be recycled.

更改触发器程序,使其具有硬编码的库.我敢打赌,尽管如此,您仍需要对该文件的独占访问权限.我没有工作(无法访问iserie),因此无法验证此解决方案.

Change the trigger program so that it has a hard coded library. I'd bet you'd need exclusive access to the file though. I'm not working (no access to iseries) so I can't verify this solution.

我建议不要更改连接字符串.您最终将不得不为连接到数据库的每台计算机进行更改.

I recommend against changing the connection string. You'll end up having to change it for every machine that connects to the database.

这篇关于如何在我的jdbc/DB2连接中插入其他库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆