on 03-20-2008 2:14 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.