cancel
Showing results for 
Search instead for 
Did you mean: 

DB Lookup using the Java file error

nisarkhan_n
Active Contributor
0 Kudos

Hi All

I have written an Java file which is taking care of the connection to the DB (Oracle 10g) and on XI server i have loaded the required driver file in the LIB Folder of the JDK of the XI server.

when i run the Java code using the commnad prompt i am able to retirve the value from the Oracle.....

I created the jar file of the .Java & .class file and imnported into the SWCV in IR.

now in the UDF i am calling to an method in Java file with String value and returing string as output

the code in the Java File is ( Imported into Archieve in SWCV)

package com.sap.xirig;

import java.sql.*;

public class Database

{

String Language_Desc;

public String value(String purchaseorderno) throws Exception

{

try

{

Connection connection = null;

Statement stmt = null;

ResultSet rst = null;

String driverName = "oracle.jdbc.driver.OracleDriver";

Class.forName(driverName);

// Create a connection to the database

String serverName = "gscts01.com";

String portNumber = "1521";

String sid = "ORACLEDB";

String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;

String username = "SAPXI";

String password = "SAPXI";

connection = DriverManager.getConnection(url,username, password);

stmt = connection.createStatement();

rst = stmt.executeQuery("select PURCHASE_ORDER_NO from ORDER_HEADER where PURCHASE_ORDER_NO='"purchaseorderno"'");

if (rst.next())

{

Language_Desc = rst.getString(1);

}

}

catch(Exception e)

{

System.out.println(e);

}

return Language_Desc;

}

}

this Code is imported in a Jar file into IR and in UDF i am mnaking this code

Import com.sap.xirig.Database

public String DB(String a,Container container)

{

String s1= a;

return value(s1);

}

i am getting this error:

Source code has syntax error: E:/usr/sap/CE6/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map9ac4aa30f68711dcc76200145e183daa/source/com/sap/xi/tf/_MM_OUt_.java:182: cannot resolve symbol symbol : method value (java.lang.String) location: class com.sap.xi.tf._MM_OUt_ return value(a); ^ 1 error

Kindly let me know where i am gng wrong.....

Edited by: Nisar Khan on Mar 20, 2008 7:45 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

prateek
Active Contributor
0 Kudos

Use

return Database.value(s1);

instead of

return value(s1);

Just to clarify, make sure u r not using "Import com.sap.xirig.Database" inside the UDF code area.

Regards,

Prateek

nisarkhan_n
Active Contributor
0 Kudos

Prateek,

I did try creating the Object of the class and acess the value method but same error

ource code has syntax error: E:/usr/sap/CE6/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map49cd8371f68911dcc92b00145e183daa/source/com/sap/xi/tf/_MM_OUt_.java:183: value() in com.sap.xirig.Database cannot be applied to (java.lang.String) return d1.value(a); ^ 1 error

ource code has syntax error: E:/usr/sap/CE6/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map49cd8371f68911dcc92b00145e183daa/source/com/sap/xi/tf/_MM_OUt_.java:183: value() in com.sap.xirig.Database cannot be applied to (java.lang.String) return Database.value(a); ^ 1 error

Also i am not using the Import com.sap.xirig.Database inside the UDF code but at the Top in the Import Box option......

I have imported the jar file with name DBLookup, in import i am poining to com.sap.xirig.Database and simple String return fucntion....

i am not able to proceed from this step, when i display queue of that UDF it is always pointing to same error.....am i right in the steps i did till now...the code wrks fine from CMD Prompt, i imporeted that as jar and in UDF am i doing anything wrong in calling that Java file and in Import statement?

help is highly appreciated (-: so that i can have peacefull weekend ahead.

nisarkhan_n
Active Contributor
0 Kudos

any clue?

Former Member
0 Kudos

Hi,

I am not sure about it, but you can have a look on this.

You have errors at two places as mentioned below.

1. return d1.value(a);

2. return Database.value(a);

So as Raj suggested you should use

1. return Database.value( s1 );

2. return d1.value( s1 );

Also check where you have used or declared d1.

Regards,

Sarvesh

nisarkhan_n
Active Contributor
0 Kudos

Raj / Sarvesh

How can i check my Java file which i have imporeted into IR is been invoked by my UDF.

also i have one doubt since i am retrving the value from the DB it will be in NON XML format, just an select stament which will give me PO number, do i have to read this in XML format from DB?

I want specifically this method to work for DB as i have around 8 tables to do lookup in various stages...kindly let me know if you have done this requiremtn eariler..would appreciate if you send me some lnks for the same.

regards

Nisar Khan

ravi_raman2
Active Contributor
0 Kudos

add some trace to it..and check the logs...

AbstractTrace trace= (AbstractTrace) param.get(StreamTransformationConstants.MAPPING_TRACE);

trace.addWarning("Calling dbLookup");

Regards

Ravi Raman