It's all about the answers!

Ask a question

Need help saving Query Results to .csv file automatically daily using RTC java api


Brandy Guillory (5311925) | asked Apr 22 '14, 4:54 p.m.
Problem: I need the write java code to find my RTC query, run my RTC query, save my RTC query results to a .csv file automatically/daily using a windows scheduler

I have been working on my classes to extend RTC in java and I have this code:


while (resolvedResults.hasNext(monitor)) {
        IResolvedResult result = resolvedResults.next(monitor);
        IWorkItem workItem =  (IWorkItem)result.getItem();
        // do something with the work item<---- I am trying to figure out what should go here in order to save my data to csv file. I am sort of new or getting back into Java coding so any help would be appreciated
        processed++;
    }

So basically i need it to do the file-->export--> choose query-->choose csv file automatically/daily through the api and a windows scheduler

One answer



permanent link
sam detweiler (12.5k6195201) | answered Apr 22 '14, 5:41 p.m.
well, I can't help with the CSV part, altho there are csv reader/writer classes available as opensource..

but here is my sample pgm, which executes a named query and then displays all the workitem attributes.

see the accepted answer here
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes

note that the forum messes with text case, quotes etc.. so there will be a few errors to correct after you cut/paste the code into eclipse.

takes 4 parms
server/ccm
userid
password
query to execute


Comments
sam detweiler commented Apr 22 '14, 5:44 p.m.

you can also go to the web UI, execute your query, go to the top right and select the print view. then copy that URL, and you can execute it with curl or whatever too.
not exactly csv format, but close (lose the 1st two lines)

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.