Quantcast
Channel: Quality Center / ALM Practitioners Forum topics
Viewing all articles
Browse latest Browse all 5491

Execute SQL query using java and retrieve records with column detail in each row

$
0
0
Hi all,

Need help on running SQL query using java API for getting Defect Status:

After Conenction/project details and credentials below is the code snapshot.

====================================================================
ITDConnection connection;
connection = ClassFactory.createTDConnection();
connection.initConnectionEx(QC_URL);
connection.connectProjectEx(QC_DOMAIN, QC_PROJECT, QC_USER, QC_PWD);

ICommand cmd = (connection.command()).queryInterface(ICommand.class);
qcSqlQuery = "SELECT * FROM AUDIT_LOG WHERE AU_ENTITY_ID = 1529 AND AU_ENTITY_TYPE='BUG' AND AU_ACTION='UPDATE' ";

cmd.commandText(qcSqlQuery);
IRecordset recordes =(cmd.execute()).queryInterface(IRecordset.class);

IColumnInfo columns = null;
System.out.println("Records Count ="+ recordes.recordCount() + " | Column Count" + recordes.colCount());

for (int j =0 ;j<recordes.colCount();j++)
System.out.print("Key: "+recordes.colName(j)+" Val:"+recordes.fieldValue(recordes.colName(j)) +" \n");


====================================================================

Code is working without any technical error

Issue is :
this returns only first one row with respective column details, multiple rows are not coming in result.

if i verify record count = 10 and Column in 1 record is 10 , and out put only shows all columns of first record

~~
I want for example

For each record
for each record
System.out.prinln("Record (RecordIndex).ColumnIndex(current)");

to show all columns returned for each row of SQL.

Viewing all articles
Browse latest Browse all 5491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>