473,395 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can't load java class of Java UDF

Dear all smart experts,

I write a simple Java UDF, which should run on DB2 v8 on AIX. But it can't load the Java class. Help ugently needed!! Thanks!

I develop and deploy the Java UDF with these steps:

1. Write the java class, compile and make a jar (see below for source).
2. Call SQLJ.REPLACE_JAR ('file:/home/pws01ta/pws01ta1/examples.jar','test',0)
3. call sqlj.refresh_classes()
4. Create the function by running "create function properties() returns table (property varchar(500), value varchar(500)) external name 'test:com.hase.JVMProperties!dump' language java parameter style db2general fenced no sql disallow parallel scratchpad"


Everything seems ok but when I run the SQL "select * from table (properties()) as t", I got:

SQL4304N Java stored procedure or user-defined function "PWS01TA1.PROPERTIES",
specific name "SQL070118203908600" could not load Java class
"com/hase/JVMProperties", reason code "1". SQLSTATE=42724


This is the source code of the java class:

package com.hase;

import COM.ibm.db2.app.*;
import java.util.*;

public class JVMProperties extends UDF {
Enumeration propertyNames;
Properties properties ;

public void dump (String property, String value) throws Exception
{
int callType = getCallType();
switch(callType) {
case SQLUDF_TF_FIRST:
break;
case SQLUDF_TF_OPEN:
properties = System.getProperties();
propertyNames = properties.propertyNames();
break;
case SQLUDF_TF_FETCH:
if (propertyNames.hasMoreElements()) {
property = (String) propertyNames.nextElement();
value = properties.getProperty(property);
set(1, property);
set(2, value);
} else {
setSQLstate("02000");
}
break;
case SQLUDF_TF_CLOSE:
break;
case SQLUDF_TF_FINAL:
break;
default:
throw new Exception("UNEXPECT call type of "+callType);
}
}
}
Jan 18 '07 #1
1 4514
r035198x
13,262 8TB
Dear all smart experts,

I write a simple Java UDF, which should run on DB2 v8 on AIX. But it can't load the Java class. Help ugently needed!! Thanks!

I develop and deploy the Java UDF with these steps:

1. Write the java class, compile and make a jar (see below for source).
2. Call SQLJ.REPLACE_JAR ('file:/home/pws01ta/pws01ta1/examples.jar','test',0)
3. call sqlj.refresh_classes()
4. Create the function by running "create function properties() returns table (property varchar(500), value varchar(500)) external name 'test:com.hase.JVMProperties!dump' language java parameter style db2general fenced no sql disallow parallel scratchpad"


Everything seems ok but when I run the SQL "select * from table (properties()) as t", I got:

SQL4304N Java stored procedure or user-defined function "PWS01TA1.PROPERTIES",
specific name "SQL070118203908600" could not load Java class
"com/hase/JVMProperties", reason code "1". SQLSTATE=42724


This is the source code of the java class:

package com.hase;

import COM.ibm.db2.app.*;
import java.util.*;

public class JVMProperties extends UDF {
Enumeration propertyNames;
Properties properties ;

public void dump (String property, String value) throws Exception
{
int callType = getCallType();
switch(callType) {
case SQLUDF_TF_FIRST:
break;
case SQLUDF_TF_OPEN:
properties = System.getProperties();
propertyNames = properties.propertyNames();
break;
case SQLUDF_TF_FETCH:
if (propertyNames.hasMoreElements()) {
property = (String) propertyNames.nextElement();
value = properties.getProperty(property);
set(1, property);
set(2, value);
} else {
setSQLstate("02000");
}
break;
case SQLUDF_TF_CLOSE:
break;
case SQLUDF_TF_FINAL:
break;
default:
throw new Exception("UNEXPECT call type of "+callType);
}
}
}
this or this might help.
Jan 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: BlackHawke | last post by:
My name is Nick Soutter, I own a small game development company (www.aepoxgames.net) making our first game (www.andromedaonline.net) in java. I am writing because we are having a very...
4
by: MackS | last post by:
Hi I'm new to Python, I've read the FAQ but still can't get the following simple example working: # file main_mod.py: global_string = 'abc' def main():
2
by: sea | last post by:
I have DB2 UDB Workgroup version 7.2 -- the JDBC-ODBC bridge loads perfectly fine but when I try to use JDBC I get an error, copying and pasting below. I added db2java.zip and db2jdbc.dll to both...
2
by: Mamuninfo | last post by:
Hello all, I want to write java store procedure in db2 universal database by jdbc. After creating the java class, How can i load this class to the database by the sqlj.install_jar() command in...
10
by: technocrat | last post by:
Hi, I am trying to declare and cursor and thn load from that cursor into another table. Since I have almost 4 million records, I cant do it without the cursor which reduces the time by almost...
1
Osoascam
by: Osoascam | last post by:
Hi! I'm trying to do a simple JDOM example, as I have to uste it for a homework... The thing is, it just doesn't work... See, this is the code: public class Ejemplo { public static void...
0
by: Manasi12 | last post by:
Hi, I am trying to load number of jar files. But while giving load java command I am getting a bunch of errors for the jar files. I am using oracle 9i. The jar files are...
6
by: owz | last post by:
I am trying 2 load details about cars from a.txt file and then display the total stock value off all cars. public class Car { // attributes private String manufacturer; private...
13
by: fullofbeans | last post by:
This is one of my web sites. http://www.metcalfeps.ocdsb.ca/ I can't get the applet to load. It's a picture of the school and has a ripple effect. I have www.java.com listed in the security...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.