cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC Lookup error.

former_member644654
Participant
0 Kudos

Hi,

Kindly correct me if I'm wrong in writing this code:

DataBaseAccessor accessor = null;

DataBaseResult JDBCOutPayload = null;

String BusinessSystem="clarify_dev_bizsys";

//give your business system having channel name

String CommunicationChannel="JDBC_TO_CDEV";

//give your channel name

String InputPayload= " SELECT X_TXN_PRE_SITE_XFACE.nextval from dual;";

//give your sql query

try {

Channel channel = LookupService.getChannel("BusinessSystem","CommunicationChannel");

accessor = LookupService.getDataBaseAccessor(channel);

DataBaseResult resultSet = accessor.execute(InputPayload);

for(Iterator rows = resultSet.getRows();rows.hasNext();)

{

Map rowMap = (Map)rows.next();

}

OBJID.addValue("OBJID");

}

catch (Exception e) {}

result.addValue(e.getMessage()) ;

finally {

if (accessor != null) accessor.close();

}

try{

catch(Exception e)

OBJID.addValue(e.getMessage()) ;

}

I'm getting an error while testing it. The error is:

/usr/sap/XIX/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Mape0565840b3d311debbbb001560de7906/source/com/sap/xi/tf/_MM_CLARIFY_MODELS_.java:138: 'finally' without 'try' finally {

Thanks in Advance.

Sreedhar.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

> DataBaseAccessor accessor = null;
> DataBaseResult JDBCOutPayload = null;
> String BusinessSystem="clarify_dev_bizsys";
> //give your business system having channel name
> String CommunicationChannel="JDBC_TO_CDEV";
> //give your channel name
> String InputPayload= " SELECT X_TXN_PRE_SITE_XFACE.nextval from dual;";
> //give your sql query
> try {
> Channel channel = LookupService.getChannel("BusinessSystem","CommunicationChannel");
> accessor = LookupService.getDataBaseAccessor(channel);      
> DataBaseResult resultSet = accessor.execute(InputPayload);
>      for(Iterator rows = resultSet.getRows();rows.hasNext();)
>            {   
>              Map rowMap = (Map)rows.next();
>             }
>        OBJID.addValue("OBJID");
> }
catch(Exception e){
> OBJID.addValue(e.getMessage()) ;
> }
>       catch (Exception e1) {
> result.addValue(e1.getMessage()) ; }
>   finally {
>                if (accessor != null)  accessor.close();
>                }
> 

There are couple of errors

1. OBJID where did you delcare this..what is thetype of this?

2. why did you used second try block and kept catch block in that

3. After a first catch block you added a statement

remove all these then it work

Rajesh

former_member644654
Participant
0 Kudos

Hi,

I've modified the code as per the sample you gave me like this:

DataBaseAccessor accessor = null;

DataBaseResult JDBCOutPayload = null;

String BusinessSystem="clarify_dev_bizsys";

//give your business system having channel name

String CommunicationChannel="JDBC_TO_CDEV";

//give your channel name

String InputPayload= " SELECT X_TXN_PRE_SITE_XFACE.nextval from dual;";

//give your sql query

try {

Channel channel = LookupService.getChannel("BusinessSystem","CommunicationChannel");

accessor = LookupService.getDataBaseAccessor(channel);

DataBaseResult resultSet = accessor.execute(InputPayload);

for(Iterator rows = resultSet.getRows();rows.hasNext();)

{

Map rowMap = (Map)rows.next();

}

OBJID.addValue("OBJID");

}

catch(Exception e){

OBJID.addValue(e.getMessage()) ;

}

// catch (Exception e1) { OBJID.addValue(e1.getMessage()) ; }

finally {

if (accessor != null) accessor.close();

}

But Now it gives an error like this:

usr/sap/XIX/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Map83a893d0b3d611de89eb001560de7906/source/com/sap/xi/tf/_MM_CLARIFY_MODELS_.java:141: unreported exception com.sap.aii.mapping.lookup.LookupException; must be caught or declared to be thrown if (accessor != null) accessor.close();

How do I correct this error?

Sreedhar.

former_member187339
Active Contributor
0 Kudos

Hi,

Try this code


DataBaseAccessor accessor = null;
DataBaseResult JDBCOutPayload = null;
String BusinessSystem="clarify_dev_bizsys";
//give your business system having channel name
String CommunicationChannel="JDBC_TO_CDEV";
//give your channel name
String InputPayload= " SELECT X_TXN_PRE_SITE_XFACE.nextval from dual";
//give your sql query
try {
Channel channel = LookupService.getChannel(BusinessSystem,CommunicationChannel);
accessor = LookupService.getDataBaseAccessor(channel);
DataBaseResult resultSet = accessor.execute(InputPayload);
for(Iterator rows = resultSet.getRows();rows.hasNext();)
{
Map rowMap = (Map)rows.next();
}
OBJID.addValue("OBJID");
}
catch(Exception e){
OBJID.addValue(e.getMessage()) ;
}
// catch (Exception e1) { OBJID.addValue(e1.getMessage()) ; }
finally {
if (accessor != null) accessor.close();
}

BTW declare OBJID (i have also not declared it!!!!

Regards

Suraj

Edited by: S.R.Suraj on Oct 8, 2009 2:55 AM

Former Member
0 Kudos

Hello Shreedhar

Change the code in finally block as follows:

finally{

try{

if (accessor!=null) accessor.close() ;

}

catch(Exception e)

{

result.addValue(e.getMessage()) ;

}

}

let me know if any errors

Cheers

uday

former_member644654
Participant
0 Kudos

Hi Uday,

I've changed the last block but still I'm getting an error like this:

/usr/sap/XIX/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Mapf839c550b3e211de9193001560de7906/source/com/sap/xi/tf/_MM_CLARIFY_MODELS_.java:143: 'finally' without 'try' finally {

Sreedhar

Former Member
0 Kudos

Please check the code written in this blog.

Will be a good reference

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler