XI to AS/400 DB2 connectivity_doubt

Hi,
has anyone connected to an AS/400 DB2 from XI's Sender JDBC Adapter? if so, can you please suggest the procedure and the <b>driver</b> that was used.
Regards,
Balaji.M

Hi All,
Thank you for the response. i have downloaded the <b>jt400.jar</b> and installed in XI.
i am in doubt about the connection string i should be using in XI JDBC Sender Adapter.
the details i have at this point is
AS/400 server IP - available
port number - not available
LocationName - NBHAGWAT
Table Name - STGORDOPDH
can you help me with the connection string?
should it be one of the below or something else:
jdbc:as400://IP/NBHAGWAT
or
jdbc:as400://IP:446;LocationName=NBHAGWAT
or
jdbc:as400://IP:446;collectionName=NBHAGWAT
or
port number replace with 50000(instead of 446)
Thank you,
Regards,
Balaji.

Similar Messages

  • JDBC receiver adapter for AS/400 DB2

    Hi guys,
    We have developed an Idoc to JDBC scenario for inserting data in a Z-table of SAP R/3 that sits on an AS/400 DB2.
    When testing it, message Mapping is executed successfully, but in communication channel monitoring, we get the following error log:
    Error while parsing or executing XML-SQL document: Error processing request in sax parser: Error when executing statement for table/stored proc. 'ZSBU_MATERIALS' (structure 'STATEMENT'): java.sql.SQLException: [SQL0204] ZSBU_MATERIALS in SBU type *FILE not found.
    The Z-table name is correct. It seems to me that it needs something more (like a library name).
    Any ideas?
    Evaggelos

    Hi,
    There is a difference between db2..and db2 on as400 as on as400 db2 comes as part of the OS install itself..See if you can connect to db2 on the as400 system from qshell..
    If you really want to manually configure the connection via the DB2 command line, then you will need to enter catalog commands similar to the following:
       1. > db2 catalog tcpip node as400 remote as400.somecompany.com server 446
       2. > db2 catalog db as400db at node as400 authentication dcs
       3. > db2 catalog dcs db as400db as mydbsvr
    Where "as400db" is your local alias for the database and "mydbsvr" is the local RDB name of the AS/400 (set via WRKRDBDIRE).
    If you catalogued the DB2 for i5/OS server incorrectly, you may get an SQL5048N error message. SQL7008N is another common error is that the DB2 for i5/OS tables being accessed on the server are not being journaled. To correct the SQL7008N error, you need to start journaling your tables or change the isolation level to No Commit.
    Regards
    Ravi Raman

  • Error in XI Sender JDBC adapter for AS/400 DB2

    We are trying to connect to AS/400 DB2 from XI's Sender JDBC Adapter. we got the driver from DataDirect (connectjdbc.jar) and configured it within XI .The configuration according to the manual for this jar file is
    // Register the driver with the driver manager
    Class.forName("com.ddtek.jdbc.db2.DB2Driver");
    // Establish the Connection
    String url = "jdbc:datadirect:db2://corpserver1:50000;LocationName=ACCTNG";
    Connection con = DriverManager.getConnection(url, "test04", "test04");
    In XI we configured this as:
    Driver = com.ddtek.jdbc.db2.DB2Driver
    Connection = jdbc:datadirect:db2://servername;LocationName=NBHAGWAT
    and specified the user id and password
    <b>Note</b>: The Port Number is optional
    When this was done in XI, we got the below error in the Adapter Monitoring:
    Sender Adapter v2108 for Party '', Service 'JDBCtoFile':
    Configured at 2006-12-19 15:45:31 MST
    History:
    - 2006-12-19 15:45:31 MST: Retry interval started. Length: 10.000 s
    - 2006-12-19 15:45:31 MST: Error: Accessing database connection 'jdbc:datadirect:db2://AS400a;LocationName=NBHAGWAT' failed: DriverManagerException: Cannot establish connection to URL 'jdbc:datadirect:db2://AS400a;LocationName=NBHAGWAT': SAPClassNotFoundException: com.ddtek.jdbc.db2.DB2Driver
    - 2006-12-19 15:45:31 MST: Processing started
    Is this because there is something wrong because the way the connection string is specified.
    Anybody who has configured XI Sender JDBC adapter for AS/400 DB2, please send us some information on this.
    Thank you,
    Regards,
    Balaji

    > SAPClassNotFoundException:
    > com.ddtek.jdbc.db2.DB2Driver
    It looks like your JDBC driver is not found. Have you deployed the driver to XI?
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3867a582-0401-0010-6cbf-9644e49f1a10">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3867a582-0401-0010-6cbf-9644e49f1a10</a>

  • DB connect with as/400 db2 and aix db2

    Hi,
    We are implementing a connection with AS/400 IBM platform with DB2 400 (DB4) and OS400 like operating system. We are using DB-Connect to
    extract data from a DB2 Database to BW (operating system AIX and DB2 UD6 - Sap Netweaver 2004).
    We follow all the steps provided in SAP help to
    configured the Connections. We created the source system for DB-Connect. In BW when we try to select tables and views with right button option the system gets this error " The current ABAP program "RSDL_META_UPLOAD" had to be terminated because one of the statements could not be executed".
    The connection fails, and can't establish it.
    Someone knows about this topic?
    There are other options?
    I would appreciate your help.
    Regards,
    Victoria

    Hi,
    For extract data with DB connect in BW from  AS/400-DB2(DB4) to aix-db2, BW write a wrong abap code.
    For this reason the solutions are:
    Write a funtion module with abap and native SQL for db2 (EXEC SQL) or Change the application server to windows.
    Regards,
    Victoria

  • AS/400 db2 database asks signon to AS/400 prompt for USER ID and PASSWORD when BO report is refreshed by client users

    Post Author: LalitJoshi
    CA Forum: Publishing
    I have created a report which is using  AS/400 db2 database.Connection is setup in a universe and through Client Access ODBC driver.
    Users are trying to connect AS/400 db2 system through ODBC(Client Access ODBC driver)  and full client BO 6.5.
    It asks for signon to AS/400 prompt for USER ID and PASSWORD when BO report is refreshed by users.
    Is there any way i can avoid the USER ID and PASSWORD as it is not feasible to give database USER ID and PASSWORD to each users.

    > SAPClassNotFoundException:
    > com.ddtek.jdbc.db2.DB2Driver
    It looks like your JDBC driver is not found. Have you deployed the driver to XI?
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3867a582-0401-0010-6cbf-9644e49f1a10">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3867a582-0401-0010-6cbf-9644e49f1a10</a>

  • Connection between AS-400 DB2 sys and XI server

    Hi All,
    I am trying to connect the AS-400 DB2 system with the XI server;
    what '.jar' files of JAVA are required
    so as to make the connection successful
    with the use of JDBC Adpt.
    Thanks & Regards
    Ranjit

    Ref:
    http://www-128.ibm.com/developerworks/db2/downloads/jcc/
    http://www-128.ibm.com/developerworks/db2/library/techarticle/0203zikopoulos/0203zikopoulos.html
    to find the drivers.
    Also have a look at - How to install and configure external drivers for JDBC &JM at the how to guide section in service market place.

  • H/W & Data migration form AS 400/DB2 V5 R4 to Unix/Linux and Oracle

    We are considering migration of huge data(in Terabytes) from AS 400/DB2 V5 R4 to Unix/Linux and Oracle.
    We are changing operating system and data base also..Please advise if R98403 can be used to move data in terabytes.
    I understand Oracle work bench does not support V5 R4.
    I would like to know pointers on possible tools and approach for the migration.
    Thanks
    Las

    Hi,
    May I know the reason for this huge change? As most of the current setups of E1 are on AS00 only. Then also if you are planning to migrate your hardware and data from DB2/OS400 to Orcle and Unix/Linux you can consider below options for data migration:
    1) R98403 and R98403A are best approach for this type of migration it may consule some extra time but accurate..! As no other tools like Oracle Workbench can
    provide 100% accuracy.
    2) Archive data size if possible with the help of BA team and work on some purging this will help you to great level.
    3) If you decide to go live on new setup please consider going live module wise as a specific module data can be moved fast, and if BA team can specify some specific tables only getting hit for module trasection they can develop TC reports for specific data to be migrated and can save your time instead of copying entire data set again at go live.
    Good Luck..!
    Thanks,
    Manoj Kathare

  • JDBC Sender Adapter for AS/400 DB2 (V5R1) Error

    Hi,
    I'm trying to create a connection to an DB2 database on an AS/400 (V5R1) server. First does anyone know what JDBC driver I should use for this... I am trying to use the DB2 Universal type 4 JDBC driver... But have a suspicion I should be using the Legacy type 2 which I'm trying to track down with the client. If anyone can give me details as to where exactly I can find this driver it would be very useful???
    Currently my settings are as follows:
    JDBC Driver: com.ibm.db2.jcc.DB2Driver
    Connection: jdbc:db2://10.101.10.9:446/PROTST01
    I have verified my user is correct etc... I get the following response in the RWB.
    - 2006-01-13 10:54:40 GMT: Error: Accessing database connection 'jdbc:db2://10.101.10.9:446/PROTST01' failed: com.ibm.db2.jcc.b.SqlException: Connection authorization failure occurred. Reason: local security service non-retryable error.
    Can this error be resolved or should I concentrate on installing the legacy type 2 driver and trying that???
    Thanks in advance,
    Pete

    Hi Peter,
    Check if these links are useful to you.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/34a1e590-0201-0010-2c82-9b6229cf4a41
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7bf6e190-0201-0010-83b7-cc557eb76abe
    Hope this helps.
    Regards,
    Chandra

  • Call Java from AS/400 DB2 Trigger

    I need to call a Java Program from an SQL Triger (is there anyway to do this?).
    I can call PGM files but my java program is a class file which I can call from:
    1- Command Line with JAVA or RUNJVA
    2- QSHELL with java
    3- SQLScript with CALL QSYS.QCMDEXC('java class(holamundo.PrintParametros) PARM(1 3)',0000000047.00000)
    I thought I could use the sentence CALL QSYS.QCMDEXC in an sql trigger but I couldn't.
    My trigger must be able to send parameters to my JAVA Program.
    I've set my environment variable CLASSPATH I need at *sys level in my AS/400 iSeries 270 with ADDENVVAR.
    Thank you for your time. I appreciate any information.
    Best regards.

    I thought... well if triggers are able to call PGM programs easily,
    then I can add a CL which calls my java program with 'java class
    (package1.ProgramX)' but it falied with the following message (NOTE
    that PGM program is RUNJVAPGM in library ADAM):
    ======================
    Message ID . . . . . . : CPF502B
    Date sent . . . . . . : 06/20/03 Time sent . . . . . . : 10:00:06
    Message . . . . : Error occurred in trigger program.
    Cause . . . . . : The trigger program which was called as the result of a
    database insert, update, delete, or read operation failed. See the previous
    messages in the job log to determine the error. The error code is 2 for
    trigger RUNJVAPGM in library ADAM type *SYS. This error code can be used to
    determine the trigger which caused the error, as follows:
    1 -- BEFORE INSERT trigger
    2 -- AFTER INSERT trigger
    3 -- BEFORE UPDATE trigger
    4 -- AFTER UPDATE trigger
    5 -- BEFORE DELETE trigger
    6 -- AFTER DELETE trigger
    More...
    ===============================
    Code is as follows
    *************** Beginning of data *************************************
    0001.00 PGM
    0002.00 MONMSG CPF502B
    0003.00 RUNJVA CLASS(holamundo.HolaMundo)
    0004.00 ENDPGM
    ****************** End of data ****************************************
    Any comments?

  • Connection to AS/400 from 9.2 on RHE 2.1

    We have data warehouse running on oracle that sources the AS/400.
    since Oracle did not include hsodbc for linux, what are my options to connect to a AS/400 db2 db.
    Jeff

    I think you are in a wrong forum.
    go here: http://www.dbforums.com
    Joel Pérez

  • How to migrate the data in AS/400 to Oracle

    I have a customer, they plan to migrate their data from AS/400 DB2 V5R3,V6R1 to Oracle 11g. Since the source system is in production, they can only halt for 48 hours,
    which way is the fastest?
    ORACLE workbench can only support to IBM DB2/400 V4R3 and V4R5, must we export the data from AS400 to ASCII then sql load to Oracle, the user data size is about 3T?
    even get the initial data, how to capture the increased data? Oracle GoldenGate 11g can't access AS400 as source.

    Hello,
    An option would be to use the Database Gateway for DRDA. With this tool, all the data in the iSeries machine will be seen like an Oracle Table.
    You will be able to run statements like :
    INSERT INTO <Oracle_table> SELECT <col1, col2.....> FROM <iSeries_table>@AS400
    or even like
    CREATE TABLE <oracle_table> AS SELECT * FROM <iSeries_table>@AS400
    The Database Gateway for DRDA is more an integration tool than a migration tool. You will be able to access live data on the AS/400 like this data was in Oracle
    table(s). You can even modify the AS/400 data (insert, update, delete) from Oracle. This can avoid to have to do a one-time migration.
    The Database Gateway for DRDA documentation is available at http://download.oracle.com/docs/cd/E11882_01/gateways.112/e12014/toc.htm

  • Does Developer2000 work with AS400/DB2

    Hi Folks,
    Has anyone worked on Oracle Developer 2000 using an AS/400 DB2 as database server? Is it feasible using Oracle Open Client Adapter? Appreciate if you could detail the issues you faced during implementation.
    Thanks
    Ramesh

    I have configed the transparent Gateway in oracle database 9i , the sqlserver transparent Gateway worked prefectly , but the transparent Gateway for AS400 did not work , can you tell me your configration detail .
    Thanks a lot .

  • Cannot Connect to DB2/AS400 Database

    I have tried to connect using JDBC connection drivers to an AS/400 DB2 database (R5V4) in Topology. I was using the IBM Toolbax for Java and Hit JDBC/400 drivers without success. I am putting in the Host Name and Library with no other property. We do not have a port number to try the DB2 Universal JDBC Driver. Do we have to add any Jar file for DB2? Any help would be appriciated.
    KG

    This is on ODI 10.1.3.5
    KG

  • Classpath for ExcelDriver in AS/400 enviroment

    Hello there!
    I'm trying to create application which would be capable copy excel file sheet to AS400 DB2 file.
    First of all I created this program on Windows enviroment tryed and it works fine.In this program
    Im using two drivers Microsoft Excel Driver(without DSN) for reading Excel file and AS/400 jt.400 driver for writing to AS/400 file.
    My problem arised when I put the program into AS/400 enviroment and tryed to do same thing(copy Excel file which is in folder directory on AS/400 to AS/400 ordinary file).
    I've got message in AS/400 enviroment:"java.sql.SQLException: No suitable driver"
    Of course No suitable driver because I did not put Microsoft Excel Driver on AS/400 enviroment
    and did not declare the classpath either.
    Question is:Where can I get Microsoft Excel Driver so that put it into AS/400 enviroment?
    If somebody need have a look into the source code here is it:
    // Convert Excel file to AS/400 DB2 file
    // Andrey Parahnevich 05/06/2002
    package com.parahnevich.exceltoas400;
    import java.sql.*;
    import java.io.*;
    import com.ibm.as400.access.AS400JDBCDriver.*;
    import com.ibm.as400.access.*;
    public class ExcelToAS400{
    static long qty=0;
    public ExcelToAS400()
    System.out.println("Entered without parameters!");
    System.exit(0);
    private static String format(String s,int width)
    String formattedString;
    if(s.length()<width)
    StringBuffer buffer = new StringBuffer(s);
    for(int i = s.length(); i<width; ++i)
    buffer.append(" ");
    formattedString=buffer.toString();
    } //endif
    else
    formattedString=s.substring(0,width);
    return formattedString;
    } //endmethod format
    public static void main(String[] args) throws Exception
    String lib = args[0];
    String file = args[1];
    String pathfile = args[2];
    String query_Excel = "";
    String insertSQL_AS400 = "";
    System.out.println("lib :" + lib);
    System.out.println("file :" + file);
    System.out.println("pathfile :" + pathfile);
    // *************************Connection to Excel***************************
    //connection to database
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("Before Microsoft Excel Driver loading");
    Connection connect_Excel = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ="+pathfile+";DriverID=22;READONLY=false","","");
    System.out.println("After Microsoft Excel Driver loading");
    /* Construct and execute the sql, positioning before the
    first row in the result set */
    Statement stmt_Excel = connect_Excel.createStatement();
    // *************************Connection to iSeries***************************
    /* Connection to the database */
    DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
    // Get a connection to the database. Since we do not
    // provide a user id or password, a prompt will appear.
    Connection connect_AS400 = DriverManager.getConnection("jdbc:as400:AS400stam","USER","PASSWORD");
    //create statement
    Statement stmt_AS400 = connect_AS400.createStatement();
    try
    System.out.println("Catalog :" + connect_Excel.getCatalog());
    DatabaseMetaData dbmeta = connect_Excel.getMetaData();
    ResultSet rs1 = dbmeta.getTables(connect_Excel.getCatalog(),null,"%",null);
    ResultSetMetaData rsmd1 = rs1.getMetaData();
    System.out.println("Table name :"+ rsmd1.getTableName(2));
    //while (rs1.next()) {
    rs1.next();
    String table_cat = rs1.getString("TABLE_CAT");
    String table_sch = rs1.getString("TABLE_SCHEM");
    String table_type = rs1.getString("TABLE_TYPE");
    String table_name = rs1.getString("TABLE_NAME");
    query_Excel = "SELECT * FROM ["+table_name+"]";
    System.out.println("table_cat is:" + table_cat + " table_sch :" + table_sch + " table_name :" + table_name);
    ResultSet rs2 = dbmeta.getColumns(table_cat, table_sch, table_name, "%");
    while (rs2.next()) {
    String column_name=rs2.getString("COLUMN_NAME");
    String type_name =rs2.getString("TYPE_NAME");
    String column_size=rs2.getString("COLUMN_SIZE");
    String is_nullable=rs2.getString("IS_NULLABLE");
    System.out.println("column_name is:" + column_name + " type_name :" + type_name + " column_size :" + column_size + "column_length : " + column_name.length() + " is_nullable :"+ is_nullable);
    ResultSet rs3=stmt_Excel.executeQuery(query_Excel);
    //get information about this Resultset
    //set Column of file
    ResultSetMetaData rsmd = rs3.getMetaData();
    int columnCount = rsmd.getColumnCount();
    String[] columnLabels = new String[columnCount];
    int[] columnWidths = new int[columnCount];
    for(int i = 1; i<=columnCount; ++i)
    columnLabels[i-1]=rsmd.getColumnLabel(i);
    columnWidths[i-1]=Math.max(columnLabels[i-1].length(),rsmd.getColumnDisplaySize(i));
    }//endloopfor1
    for(int i = 1; i<=columnCount; ++i)
    System.out.print(format (rsmd.getColumnLabel(i),columnWidths[i-1]));
    System.out.print(" ");
    }//endloopfor2
    System.out.println();
    // Iterate throught the rows in the Resultset and
    // output the columns for each row.
    String [] field_a = new String[columnCount];
    Object [] value_a = new Object[columnCount];
    while(rs3.next())
    ++qty;
    for(int i = 1; i<=columnCount; ++i)
    String value = rs3.getString(i);
    if(rs3.wasNull())
    value="NULL";
    field_a[i-1] = rsmd.getColumnLabel(i);
    value_a[i-1] =(Object)value;
    System.out.println(format(value,columnWidths[i-1])+" columnLabel: " +field_a[i-1]);
    System.out.println(" ");
    System.out.println(qty);
    // **************************** insert row in iSeries table ********************
    insertSQL_AS400 = "Insert Into " + lib +"." + file + " (";
    for(int j=1;j<=columnCount; ++j)
    String sign = ",";
    if (j==columnCount) sign = ")";
    insertSQL_AS400 += " "+field_a[j-1] + " " + sign;
    insertSQL_AS400 += "Values (";
    for(int j=1;j<=columnCount; ++j)
    String sign = ",";
    if (j==columnCount) sign = ")";
    insertSQL_AS400 += " "+value_a[j-1] + " " + sign;
    System.out.println("insertSQL_AS400 :" + insertSQL_AS400);
    try
    stmt_AS400.executeUpdate(insertSQL_AS400);
    insertSQL_AS400 = "";
    } //endtry
    catch(Exception e)
    System.out.println("");
    System.out.println("ERROR :"+" "+e.getMessage());
    } // endcatch
    } //endtry
    catch(Exception e)
    System.out.println("");
    System.out.println("ERROR :"+" "+e.getMessage());
    } // endcatch
    finally
    if(connect_Excel != null)
    connect_Excel.close();
    if(connect_AS400 != null)
    connect_AS400.close();
    }//endmain method

    Is there a Microsoft Excel driver? If there is, its classname would very definitely not be "sun.jdbc.odbc.JdbcOdbcDriver". This forum has a link to FAQ at the top of the page listing posts, one of the FAQs has a link to a list of many drivers. You might find this driver listed there. Otherwise, don't be surprised if the AS/400 doesn't support ODBC.

  • Pagination support for non-Oracle databases?

    Hi,
    I just read this thread (Pagination Support on pagination support. Is there any way to get pagination with non-Oracle databases? We are using an IBM iSeries / AS/400 DB2 database right now, and we're planning to use some local lightweight database in the near future as well (probably Cloudscape/Derby or "IBM Everyplace database".)
    We currently use code like this:
    String sql = "SELECT art FROM Artikel art" +
                /* dynamically generated where statement is added here */
                + "ORDER BY art.artikelNummer";
    Query q = em.createQuery(sql);
    q.setFirstResult(firstResult);
    q.setMaxResults(maxResults);If I look in the TopLink logs, I see queries like this:
    SELECT ARTNR, ARALT, ARAFJ, ARXII, ARAVJ, ARXIV, ARANJ, AHGCD, ARNVJ, ARCRJ, ARARK, ARFKJ, ARTNK, ARGP1, ASGCD, ARGP2, ARPR1, ARGP3, ARPR2, AREX1, ARPR3, AREX2, ARPR4, AREX3, ARASA, ARINA, ASSCD, ARIA1, ARBAN, ARIN1, ARBAV, ARIA2, ARBAK, ARIN2, ARCES, ARIA3, ARCDT, ARIN3, ARCRE, ARIA4, ARCWK, ARIN4, ARHBH, ARIA5, ARDFA, ARIN5, ARDFG, ARIA6, ARDOS, ARIN6, AREPW, ARINN, ARFOD, ARIAS, ARFOE, ARINS, ARFOF, ARNAB, ARFOI, ARNIB, ARFON, ARNIA, ARFOS, ARNN1, ARFTA, ARNA2, ARVIV, ARNO2, ARGAP, ARNN3, ARGPT, ARNA4, ARGPD, ARNO4, ARGPA, ARNN5, ARGPO, ARNA6, ARHIS, ARNN6, ARISP, ARNIO, ARKHM, ARNNS, MAGCD, AROVJ, MTGCD, ARPL1, ARMXM, ARPL2, MRKCD, ARPL3, ARMVR, ARVKJ, ARMIM, ARV12, ARMDT, ARVVJ, ARMTE, AR#VR, ARMTU, ARZLS, ARMTM, ARIAT, ARMWK, ARAVS, MPCCD, ARNVS, ARBTW, ARFJS, ARXI2, ARG2S, ARXI3, ARE1S, ARXI4, ARE3S, ARXI6, ARIB1, ARXI1, ARIB2, ARXI5, ARIB3, AROPI, ARIB4, ARPRV, ARIB5, SZGCD, ARIB6, ARSPC, ARINO, ARSMF, ARIOS, VEAAN, ARNIS, ARSYN, ARNO1, ARVR1, ARNA3, ARV1S, ARNN4, ARVR2, ARNO5, ARV2S, ARNIN, ARVR3, ARNOS, ARV3S, ARP1S, ARTFA, ARP3S, ARTFG, ARS12, ARUVC, ARZLD, ARUCW, ARAJS, ARBKV, ARCJS, ARVVI, ARG3S, ARVVP, ARINB, VPOCD, ARIO2, VPECD, ARIO4, ARVIH, ARIO6, ARVHG, ARNBS, ARVRW, ARNN2, ARVPR, ARNA5, ARVVR, ARNAS, ARVVS, ARP2S, ARVV1, ARSVV, ARZK1, ARNJS, ARNA1, ARNO3, ARIO1, ARNO6, ARIO5, AROJS, ARE2S, ARVJS, ARIBS, ARIAD, ARIO3, ARG1S FROM ART WHERE ((((ARUVC = 'N') AND (ARHIS = 'N')) AND (ASGCD = 7)) AND (AHGCD = 15)) ORDER BY ARTNR ASC
    (Yeah, I know we have too much columns in the table...)
    So, no pagination in the query. As you can see, we have a mechanism in place to dynamically generate a where clause. This is because the user can set filters. The problem is, if our user sets a filter that causes the result set to be significantly smaller, the performance is way better than when he sets no filter at all. We suppose this is because the whole result set is sent to TopLink, regardless of the values of firstResult and maxResults.
    We are using TopLink Essentials 2.1-10, by the way.
    Message was edited by:
    Bart Kummel

    Hi all,
    I'm trying to subclass <tt>DatabasePlatform</tt> to add pagination support for the AS/400 DB2 database of my customer. To be fair, it is not going very well so far.
    The first problem is, the query Chris found by googling (Re: Pagination support for non-Oracle databases?), does not work for AS/400s version of DB2. In fact, although it is called "DB2", the database on the AS/400 system is a whole other database than the "normal" DB2 database that runs on Windows and *nix. The AS/400 DB2 simply does not have a "ROW_NEXT" function.
    Another option would be to use the <b>row_number() over()</b> mehtod. But, as can be read here, this function is only available from version V5R4 of OS/400. And guess what? We're stuck on V5R3 at this client. (We cannot upgrade, because there's an application in use that's written in Delphi and IBM dropped the Delphi binding from V5R4...)
    So I pretty much ran out of options. On the mailing list I linked to above, someone mentions the option to make a sort of stored procedure that generates a row count number. An example of how to do this can be found here. I implemented it, and ended up with this code:
    package com.myclientsname.persistence;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import org.eclipse.persistence.expressions.ExpressionBuilder;
    import org.eclipse.persistence.internal.databaseaccess.DatabaseCall;
    import org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter;
    import org.eclipse.persistence.internal.expressions.SQLSelectStatement;
    import org.eclipse.persistence.internal.sessions.AbstractSession;
    import org.eclipse.persistence.logging.SessionLog;
    import org.eclipse.persistence.platform.database.DatabasePlatform;
    import org.eclipse.persistence.sessions.SessionProfiler;
    public class AS400Platform extends DatabasePlatform {
        private static final long serialVersionUID = 0L;
        public AS400Platform(){
             super();
             super.setShouldBindAllParameters(false);
        public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement) {
            int max = 0;
            int firstRow = 0;
            if (statement.getQuery()!=null){
                max = statement.getQuery().getMaxRows();
                firstRow = statement.getQuery().getFirstResult();
            if ( !(max>0) && !(firstRow>0) ){
                super.printSQLSelectStatement(call, printer,statement);
                return;
            } else {
                statement.setUseUniqueFieldAliases(true);
                ExpressionBuilder builder = new ExpressionBuilder();
                statement.addField(builder.getField("COUNTER() AS CNTR"));
                printer.printString("SELECT * FROM (");
                call.setFields(statement.printSQL(printer));
                printer.printString(") AS R WHERE R.CNTR >= ");
                printer.printParameter(DatabaseCall.FIRSTRESULT_FIELD);
                if ( max > 0 ){
                    // Use of binding parameters is not allowed here, so use
                    // String concatenation instead...
                    printer.printString(" FETCH FIRST " + max + " ROWS ONLY");
            call.setIgnoreFirstRowMaxResultsSettings(true);
        public boolean wasFailureCommunicationBased(SQLException exception, Connection connection, AbstractSession sessionForProfile){
            if (connection == null || this.pingSQL == null){
                //Without a connection we are  unable to determine what caused the error so return false.
                //The only case where connection will be null should be External Connection Pooling so
                //returning false is ok as there is no connection management requirement
                    //If there is no ping sql then we can not perform the ping.
                return false;
            PreparedStatement statement = null;
            try{
                sessionForProfile.startOperationProfile(SessionProfiler.ConnectionPing);
                if (sessionForProfile.shouldLog(SessionLog.FINE, SessionLog.SQL)) {// Avoid printing if no logging required.
                     sessionForProfile.log(SessionLog.FINE, SessionLog.SQL, getPingSQL(), (Object[])null, null, false);
                statement = connection.prepareStatement(getPingSQL());
                ResultSet result = statement.executeQuery();
                result.close();
                statement.close();
            }catch (SQLException ex){
                try{
                    // Had to add this check because of NullPointerExceptions
                    // (maybe a bug?)
                    if(statement != null){
                        //try to close statement again in case the query or result.close() caused an exception.
                        statement.close();
                } catch (SQLException exception2) {
                    //ignore;
                return true;
            }finally{
                sessionForProfile.endOperationProfile(SessionProfiler.ConnectionPing);
            return false;
    }(As you can see, I had to override the <tt>wasFailureCommunicationBased()</tt> method as well, due to some unexpected NPE's. (A bug, perhaps?))
    This code does work. However, the performance is not very well. The first page comes relatively fast, but as you browse further in the table, each page comes slower. I assume this is because the counter() method has to be evaluated for each row in the table.
    I have to get the performance better and constant. Does anyone have an idea how to optimize this further?
    Best regards,
    Bart Kummel

Maybe you are looking for