Skip to Content
avatar image
Former Member

Reg:Error in JDBC Lookup Table

Hi All,

My actual requirement is,A project ID is being triggered to PI which will pull the data from the database(SQL Server 2000) ,from different tables and it has to post to file.Receiver side I will be using the File Adapter.

For this I am using JDBC Lookup table through an User Defined function.

// code

String Query = " ";

Channel channel = null;

DataBaseAccessor accessor = null;

DataBaseResult resultSet = null;

//Build the Query String

Query = "Select proj_id, proj_short_name from PROJECT where proj_id = '"proj_id[0]"'";

try{

channel = LookupService.getChannel("bs_test" ,"cc_test");

//Get a system accessor for the channel. As the call is being made //to an DB, an DatabaseAccessor is obtained.

accessor = LookupService.getDataBaseAccessor(channel);

//Execute Query and get the values in output

resultSet = accessor.execute(Query);

Iterator rows = null;

rows = resultSet.getRows();

while(rows.hasNext())

{

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

// String proj_id = rowMap.get("proj_id");

// String project_name = rowMap.get("proj_short_name");

result.addValue((String)rowMap.get("proj_id "));

result.addValue((String)rowMap.get("project_short_name "));

//result.addValue(proj_id);

//result.addValue(project_short_name);

}

}

catch(Exception ex)

{

result.addValue(ex.getMessage());

}

finally{

try{

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

}

catch(Exception e)

{

result.addValue(e.getMessage());

}

//@@end

}

While testing in test tab of Message Mapping,I am getting the value as 'NULL' for the project id and am not able to see the other field.

Please suggest me in this.

Thanks in Advance,

Lavanya.B

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 04, 2008 at 02:14 PM

    Hi Lavanya Balanandham,

    While you are testing in the Message Mapping you would get Null Value only.

    So Complete all the required steps. Then test the Whole scenario and try.

    Regards,

    Varun

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      HI

      I have sent you a tested Code.

      Run complete scenario and check your ID config as well. JDBC channel etc. if the channel is not getting connected then also it will return null.

      Thanks

      Gaurav

  • Dec 05, 2008 at 06:12 AM

    The problem can be in:

    result.addValue((String)rowMap.get("proj_id "));

    result.addValue((String)rowMap.get("project_short_name "));

    this step. Kindly check. There is aspace after proj_id...this could be the problem.

    Use something like this, and check..

    result.addValue("" + rowMap.get("proj_id")); OR using String.valueOf( rowMap.get("proj_id") );

    Regards

    Add comment
    10|10000 characters needed characters exceeded