If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Package not found while executing java stored procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-21-11, 14:57
ramesh_rcp ramesh_rcp is offline
Registered User
 
Join Date: Aug 2011
Posts: 2
Unhappy Package not found while executing java stored procedure

Hi,

I am using DB2v8.1 to do some POC. I want to execute a java stored procedure. I used the development centre tool to create the java stored procedure and also to installing in the JAR file manually by SQLJ.INSTALL, But failed in both.



There are two problems here:

1)The development centre tool works fine, if you want to just create a simple produre. But if you modify the java program by lets say, put import com.ibm.mq.* then it throws error package couldn't be found. I included the jar file in the CLASSPATH also.

package PKG110720044512120;

import java.sql.*; // JDBC classes
import java.io.*;
import com.ibm.mq.*;

public class PROCEDURE2
{
public static void pROCEDURE2 ( String empid ) throws SQLException, Exception
{
....................................
.............................................


DB2ADMIN.PROCEDURE2 - Build started.
DROP SPECIFIC PROCEDURE DB2ADMIN.SQL110820164732311
DB2ADMIN.PROCEDURE2 - Drop stored procedure completed.
C:\PROGRA~1\IBM\SQLLIB\java\jdk\bin\javac -classpath ".;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROG RA~1\IBM\SQLLIB\java\runtime.zip;C:\PROGRA~1\IBM\S QLLIB\java\sqlj.zip" PKG110720044512120\PROCEDURE2.java
PKG110720044512120\PROCEDURE2.java:8: package com.ibm.mq does not exist
import com.ibm.mq.*;
^
1 error
DB2ADMIN.PROCEDURE2 - Build failed.
DB2ADMIN.PROCEDURE2 - Roll back completed successfully.



2) If I manually create my java program and put the JAR file using the SQLJ.INSTALL command, it gives error

Below is the Procedure definition executed in db2admin schema:
CREATE PROCEDURE PROCEDURE4 (IN empid CHAR(5))
NOT DETERMINISTIC
LANGUAGE JAVA
EXTERNAL NAME 'SQLJAR1.PROCEDURE4.pROCEDURE4'
FENCED
THREADSAFE
PARAMETER STYLE JAVA

call procedure4('123')
SQL4304N Java stored procedure or user-defined function "DB2ADMIN.PROCEDURE4",
specific name "SQL110821133934913" could not load Java class
"SQLJAR1/procedure4", reason code "1". SQLSTATE=42724

SQL4304N Java stored procedure or user-defined function "DB2ADMIN.PROCEDURE4", specific name "SQL110821133934913" could not load Java class "SQLJAR1/procedure4", reason code "1 ".

Explanation:

The Java class given by the EXTERNAL NAME clause of a CREATE
PROCEDURE or CREATE FUNCTION statement could not be loaded. The
reason codes are:


1 The class was not found on the CLASSPATH.

2 The class did not implement the required interface
("COM.ibm.db2.app.StoredProc" or "COM.ibm.db2.app.UDF") or lacked
the Java "public" access flag.

3 The default constructor failed or was unavailable.

4 Could not load driver for "jdbc:default:connection".

5 Could not establish default context.

User Response:

Ensure that the compiled ".class" file is installed in the
CLASSPATH, for example under "sqllib/function". Ensure it
implements the required Java interfaces and is "public".

sqlcode : -4304

sqlstate : 42724
Reply With Quote
  #2 (permalink)  
Old 08-22-11, 09:05
marc_ marc_ is offline
Registered User
 
Join Date: Aug 2011
Location: Glasgow, UK
Posts: 36
Think you need to reference the MQ classes specifically in your CLASSPATH. See: https://publib.boulder.ibm.com/iseri...s/csqzaw07.pdf page 11

Reply With Quote
  #3 (permalink)  
Old 09-14-11, 10:52
gsp0117 gsp0117 is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
db2 technician

I am trying to compile the following java program:

import com.ibm.mq.*;
import java.io.*;
public class CaptureErrorQueue {......
...
...


and receiving the error: package com.ibm.mq not found
I am using AIX/WB v 6 and db2 v9.5 on sun solaris/unix

Could anyone tell me why I am getting this error.
Thank You
Govardhan
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On