Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2012
    Posts
    30

    Post Unanswered: Error during execute external java function

    Hi All!

    I need to implement Guid into db2 table column. Implementation of it is in external java file.
    Code:
    import java.util.UUID;
     
    public class UUIDUDF
    {
    	public static String randomUUID()
    	{
    		return UUID.randomUUID().toString();
    	}
    }
    After compiling it becomes an *.jar file for instalation into db2.

    Code:
    call sqlj.install_jar('file:d\UUIDUDF.jar', 'UUIDUDFJAR')
    But while I try to create function with external call
    Code:
    CREATE OR REPLACE FUNCTION RANDOMUUID()
      RETURNS VARCHAR(36)
      LANGUAGE JAVA
      PARAMETER STYLE JAVA
      NOT DETERMINISTIC NO EXTERNAL ACTION NO SQL
      EXTERNAL NAME 'UUIDUDFJAR:UUIDUDF.randomUUID' ;
    I get the -20204. THE USER-DEFINED FUNCTION OR PROCEDURE routine-name WAS UNABLE TO MAP TO A SINGLE JAVA METHOD mistake.


    Where the mistake? Java compiled and installed without any error with jre 6 (goes with db2). Seems that db2 can't find java fuinction in imported jar-file

    Os: Win 7x64
    DB2: 9.7
    JRE: 6

    Thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by Black Moon View Post

    Code:
    call sqlj.install_jar('file:d\UUIDUDF.jar', 'UUIDUDFJAR')
    This does not look like a correct path specification.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Oct 2012
    Posts
    30
    with correct path
    call sqlj.install_jar('file:d:\UUIDUDF.jar', 'UUIDUDFJAR')
    got same error
    HTML Code:
    sqlcode: -20204
    sqlstate: 46008

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by Black Moon View Post
    with correct path


    got same error
    HTML Code:
    sqlcode: -20204
    sqlstate: 46008
    File URIs in Windows - IEBlog - Site Home - MSDN Blogs
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Oct 2012
    Posts
    30
    Using this link
    update jar-path

    Code:
    call sqlj.install_jar('file:///D:/UUIDUDF.jar', 'UUIDUDFJAR')

    Mistake
    HTML Code:
    sqlcode: -20204
    
     sqlstate: 46008
    still exists.

    Where DB2 default path in Windows - path with
    'file: ./UUIDUDF.jar'
    URI?

  6. #6
    Join Date
    Oct 2012
    Posts
    30
    solved.

    First i think that db2 can't find method in jar cause it compiled by another jdk (there jdk 1.7.07 and db2/java/jre 6 on machine). But real reason was that jar file compiled and archieved on the path d:\ , and folder d: added into jar. Compiled java in right folder solved mistake.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •