0

I'm using DashDB (Bluemix service) and I need to export the tables data in my Java code. For that purpose I wrote the following ...

        String sql = "CALL SYSPROC.ADMIN_CMD(?)";
        callStmt1 = conn.prepareCall(sql);
        query = "export to exportData.IXF of IXF select * from nombres";
        callStmt1.setString(1, query);          
        callStmt1.execute();      
        rs1 = callStmt1.getResultSet();

But it's not working. The file exportData.ixf is not generated, but I'm not getting any error code. I used to execute this code on DB2. Do you know if it's possible to do what I'm doing with DashDB? If the answer is yes. Do you have any suggestion? Thank you!!!

Macana
  • 1
  • Did you execute it locally on DB2? You are remote to dashDB and files are typically created on the server, if you have the privileges. – data_henrik Aug 23 '16 at 19:30
  • I executed that using CLPPlus too, but I can't find where the result file is located. The command is : export to myfile.ixf of ixf select * from NOMBRES and the result : Total number of rows exported:5 - The command completed successfuly. But I'm not being able to locate the file myfile.ixf. I can't find where it's created. – Macana Aug 24 '16 at 13:18
  • CLPPlus can be remote to the server, too. Export is always on the server – data_henrik Aug 24 '16 at 14:34

2 Answers2

2

The EXPORT command is run in dashDB and exports the file to a directory local to the dashDB server. So if you want to use EXPORT you need an additional step to download the file. One way to do this is to use the REST API here: https://developer.ibm.com/clouddataservices/wp-content/themes/projectnext-clouddata/dashDB/ (GET call to /home/... endpoint). Another way would be to use the CLPPlus IDA command: https://www.ibm.com/support/knowledgecenter/SS6NHC/com.ibm.swg.im.dashdb.clpplus.doc/doc/r0061925.html

1

Here is a more specific procedure that I verified successfully:

  1. Create a writable directory in your users home directory using the /rscript endpoint:

    curl --user "<user>:<password>" -H "Content-Type: application/json" -d "{\"rScript\" : \"system('mkdir files;chmod 777 files')\"}" -X POST "https://<server>:8443/dashdb-api/rscript"

  2. Run an EXPORT command (e.g. in clpplus) with qualified output dir:

    export to /mnt/blumeta0/home/<user>/files/out.del of del select * from <your table>;

  3. Download the output file:

    curl --user "<user>:<password>" -X GET "https://<server>:8443/dashdb-api/home/files/out.del"