Connect to HP Quality Center using Java

Updated:

You can access HP Quality Center using java. To do this you have to use com4j to create the wrapper classes to the OTA library.

here some variables that you will use:

ITDConnection connection = ClassFactory.createTDConnection(); 
 IBugFactory bugFactory; 
 ITDFilter2 filter; 
 IList bugList; 

ex. how to connect to QC:

private void connectQC(){ 
    connection.initConnectionEx("https://youradress:84/qcbin"); 
    connection.connectProjectEx("YOUR_DOMAIN", "YOUR_PROJECT", "UserName", ""); 
 
      bugFactory = (IBugFactory) connection.bugFactory().queryInterface(IBugFactory.class); 
      // retrieve all the fields 
      IList fields = bugFactory.fields(); 
      filter = bugFactory.filter().queryInterface(ITDFilter2.class); 
    } 

ex. how to retrieve the bug inserted between 2 dates:

public List getBugLsa(String dateBegin, String dateEnd){ 
         private ITDFilter2 filter; 
         private IList bugList; 
         filter.clear(); 
         String queryString = ">= "+dateBegin+" and <= " + dateEnd; 
         System.out.append("query: c + queryString); 
         filter.filter("BG_DETECTION_DATE", queryString); 
         IList bugList = filter.newList()); 
         ... 
        return result; 
   } 

Update August 7, 2012

I stopped to use Quality Center at my client working place, for this reason I don’t have time to investigate hot to improve the connection between Java and HPQC. I will publish some code next week on github and I will post here the link, my program simply connect to QC to create some statistical reports (I used Play, JQuery and excel as view), nothing too complex.

The main problems I found to connect my small stats program to QC are related to the version of the JDK (impossible to connect with the 64 bit JDK). I did a prototype with a C# program too and there are definitely less issues in the communication between the components compared to Java. If you have the possibility to use C# it’s the easiest way, the code it’s almost identical to the Java code.


Fullstack Angular / Java application quick start guide.
WebApp built by Marco using SpringBoot 3.2.4 and Java 21. Hosted in Switzerland (GE8).