Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2009
    Posts
    4

    Unanswered: Connector SQL Error

    Hi Everyone,

    I'm trying to export a table into a text file and I'm getting connector error at the run time. I have tried with 2 versions of db2jcc.jar connector jars. But getting the following errors. Please help.

    C:\JDK5\TryJava>javac ExportDB.java

    C:\JDK5\TryJava>java ExportDB
    exportCMD = EXPORT TO K:\20091222\orp_TIPDEFGRUPO.txt OF DEL MESSAGES K:\2009122
    2\errors.txt SELECT * FROM OR4ADM.ORP_TIPDEFGRUPO
    com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, S
    QLERRMC: K:\20091222\errors.txt;MESSAGES;ON
    at com.ibm.db2.jcc.b.nh.b(nh.java:1376)
    at com.ibm.db2.jcc.b.nh.c(nh.java:1363)
    at com.ibm.db2.jcc.a.db.k(db.java:352)
    at com.ibm.db2.jcc.a.db.e(db.java:96)
    at com.ibm.db2.jcc.a.t.e(t.java:83)
    at com.ibm.db2.jcc.a.sb.h(sb.java:167)
    at com.ibm.db2.jcc.b.nh.p(nh.java:1336)
    at com.ibm.db2.jcc.b.oh.d(oh.java:2474)
    at com.ibm.db2.jcc.b.ph.W(ph.java:94)
    at com.ibm.db2.jcc.b.ph.execute(ph.java:77)
    at ExportDB.main(ExportDB.java:52)

    CODE:
    Connection conn = null;
    CallableStatement cstmt = null;
    String url = "jdbc:db2://dbxxxxs2.unix.ammmm.co.uk:50000/DUT01";
    String driver = "com.ibm.db2.jcc.DB2Driver";
    String userName = "durp";
    String password = "xxxxx";
    try {
    Class.forName(driver).newInstance();
    System.out.println("Connected to the database2");
    conn = DriverManager.getConnection(url,userName,password) ;
    System.out.println("Connected to the database3");
    cstmt = conn.prepareCall("CALL SYSPROC.ADMIN_CMD (?)");

    String exportCMD = "EXPORT TO K:\\20091222\\orp_TIPDEFGRUPO.txt OF DEL MESSAGES K:\\20091222\\errors.txt SELECT * FROM OR4ADM.ORP_TIPDEFGRUPO";
    cstmt.setString(1,exportCMD);
    System.out.println ("exportCMD = " + exportCMD );
    cstmt.execute();

    cstmt.close();
    conn.close();

    } catch (Exception e) {
    e.printStackTrace();
    }

    }

    Thanks
    Pradeep
    Last edited by pradeepcheers; 12-23-09 at 07:13.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    I doubt that the directory K:\20091222 exists on db2bks2.unix.anplc.co.uk.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Dec 2009
    Posts
    4
    The SQL will work fine with DB2 Control Center. This K:\20091222 is a shared folder where I need to export the table. I tried changing the location to C:\20091222 but still fails with the same error

    exportCMD = EXPORT TO C:\20091222\orp_TIPDEFGRUPO.txt OF DEL MESSAGES C:\2009122
    2\errors.txt SELECT * FROM OR4ADM.ORP_TIPDEFGRUPO
    com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, S
    QLERRMC: C:\20091222\errors.txt;MESSAGES;ON
    at com.ibm.db2.jcc.b.nh.b(nh.java:1376)
    at com.ibm.db2.jcc.b.nh.c(nh.java:1363)
    at com.ibm.db2.jcc.a.db.k(db.java:352)
    at com.ibm.db2.jcc.a.db.e(db.java:96)
    at com.ibm.db2.jcc.a.t.e(t.java:83)
    at com.ibm.db2.jcc.a.sb.h(sb.java:167)
    at com.ibm.db2.jcc.b.nh.p(nh.java:1336)
    at com.ibm.db2.jcc.b.oh.d(oh.java:2474)
    at com.ibm.db2.jcc.b.ph.W(ph.java:94)
    at com.ibm.db2.jcc.b.ph.execute(ph.java:77)
    at ExportDB.main(ExportDB.java:52)

    Please help.

    Thanks
    Pradeep

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    ADMIN_CMD() runs on the server; it has no idea what "C:" or "K:" might be. EXPORT must refer to a server local path, which you would know if you'd read the manual.
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Dec 2009
    Posts
    4
    Thanks for your help.

    Is there some other way of exporting tables to the files into local folder?

    Thanks
    Pradeep

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Run the "EXPORT" utility at the client and don't use the ADMIN_CMD stored procedure.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  7. #7
    Join Date
    Dec 2009
    Posts
    4
    Thanks a lot for the reply.

    But I don't understand. Could you please explain this to me.

    Can you provide the code please?

    Regards
    Pradeep

  8. #8
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Unless you want to write the functionality yourself in your Java application, you can install the DB2 client, connect your application through that client to the DB2 server, and then run the EXPORT command that the DB2 client has built-in locally at the client. It's straight-forward and "just" requires the implementation part. (The only critical point is that your Java application must be run with an authorization that allows you to use the DB2 client.)
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  9. #9
    Join Date
    Dec 2009
    Posts
    1
    if upgrading just the db - it should be no problem

  10. #10
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Quote Originally Posted by cubbatjum View Post
    if upgrading just the db - it should be no problem
    ??? I didn't mention anything about upgrading, and even a newer version of DB2 can't resolve the fundamental issue that code running on the server cannot really write to the file system on the client system.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •