Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

Tools
Tools covers the tools and utilities you use to work with Teradata and its supporting ecosystem. You'll find information on everything from the Teradata Eclipse plug-in to load/extract tools.
Teradata Employee

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

This is a better question for the Database forums

http://forums.teradata.com/forum/database

Teradata Employee

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

Hello I am trying to create a Java UDF, that calls the Google Gecoding service and returns me the coordinates of a given address. 

I prepared and tested my project, it is working as a charm. After I install it into Teradata though it gives me "java.net.UnknownHostException: maps.googleapis.com". The strange thing is that the host is reachable from eclipse and the terminal. At first I started investigating the possibility that something is wrong with the DNS, but even if I try something like this(and I deploy to teradata) I still the host is unreachable. Basically the only reachable host is 127.0.0.1:

public static void test(){

  String ipAddress = "74.125.69.95";

  netAddress inet = InetAddress.getByName(ipAddress);

  if(inet.isReachable(5000)){

   

    throw new SQLException("Host is reachable: " + ipAddress);

  } else{

    throw new SQLException("Host is NOT reachable: " + ipAddress);

  }

}

Do you have any idea what may cause this ?

I use:

 - Eclipse Kepler

 - TDExpress 14.10

 - Java 6 - 1.6.0_43

Teradata Employee

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

Hi,

I'm trying to create and install a Java UDF (ExtractValue.java) but I keep getting an error.

I've already successfully installed the ExtractValue_JAR in SQLJ so now, I'm running the CREATE FUNCTION statement. However, I keep running into an error. It says,

Failure 7970 Create/Replace Java XSP/UDF passed an unacceptable signature. Correct the signature

I'm using the following query and I've already ensured that the syntax is correct. I've also made the Java method as static, just to make sure it will run as expected.

CREATE FUNCTION humedica_benchmark.extract_value

(p_txt VARCHAR(8000) CHARACTER SET UNICODE, p_debug NUMBER)

RETURNS NUMBER

LANGUAGE JAVA

NO SQL

PARAMETER STYLE JAVA

DETERMINISTIC

RETURNS NULL ON NULL INPUT
EXTERNAL NAME 'ExtractValue_JAR:ExtractValue.extract_value(java.lang.String, java.lang.int) returns java.lang.Number';

Can anyone help me find what's wrong with my query?

Teradata Employee

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

What version of Java are you using?

What version of the Teradata Database are you using?

What version of the Teradata Plug-in for Eclipse are you using?

Teradata Employee

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

Your EXTERNAL NAME clause is incorrect. You specified the second parameter as "java.lang.int", which cannot be correct.

Please post the method signature for the ExtractValue.extract_value method, so that we can help you correct the EXTERNAL NAME clause.

Teradata Employee

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

Please in the Java User Defined Function Editor please select the correct data type for Integer.

Enthusiast

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

Hi JS..

Just wondering if we have to use Eclipse or other GUI's to setup Java UDF's and XSP's, or can we write the code natively as have the JRE installed.  It would mean writing the code from the SOURCE tab and the SQL table and then running the SQL code to create the UDF/XSP.

Cheers

Steven

Teradata Employee

Re: Creating a Simple Java User Defined Function using the Teradata Plug-in for Eclipse

You can do it your self but there are many steps invovled. The  Eclipse Plug-in for Teradata JUDF Wizard and Editor really walks you through the process. It also creates an ant build script so that you can run outside of Eclipse for Deployment and Automation.