on 10-08-2009 7:27 AM
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.
> 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.