Skip to Content
0
Jan 20, 2006 at 08:24 AM

Querying a RDBMS database

28 Views

Hi all,

I am trying to connect to a RDBMS (SQL server) table and read data. I have written the following code :-

IConnectorGatewayService cgservice =

(IConnectorGatewayService) PortalRuntime

.getRuntimeResources()

.getService(

IConnectorService.KEY);

ConnectionProperties cp =

new ConnectionProperties(request.getLocale(), request.getUser());

try {

con = null;

con = cgservice.getConnection(this.getSystemName(), cp);

message = message + "connection con <BR>";

} catch (Exception e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

try {

iquery = con.newQuery();

System.out.println("After new query");

} catch (CapabilityNotSupportedException e3) {

// TODO Auto-generated catch block

e3.printStackTrace();

}

String query =

"SELECT sight_code , loc_city , loc_state , car_status , clm_date_time "

+ " FROM RT_TRIP where "

+ " car_no = '016905' and "

+ " cust_no = '842591198546' and "

+ " trip_no = 'SA20040424021'";

try {

exestatus = iquery.execute(query);

} catch (QueryExecutionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

try {

recordSet = iquery.retrieveRecordSet();

setRecordSet(recordSet);

} catch (ConnectorException e2) {

// TODO Auto-generated catch block

e2.printStackTrace();

}

try {

con.close();

} catch (Exception e4) {

// TODO Auto-generated catch block

e4.printStackTrace();

}

1)

Above code executes fine for the first time. But starts throwing the following exception from the second time :-

"[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt".

<b>Even though i have closed the EP connection, I guess some internal DNS connection is not getting closed</b>. Can some one tell me how to solve this problem.

2) The API which I am currently using uses "IQuery" which is a deprecated API. I was trying to use "IExecution" interface.

But to use IExecution.execute(IOperation e) - how to I create the object of IOperation???

Please help me in this.

Regards,

NArahari