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 > Acessing MQ Queue from DB2 Java Stored Procedure.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-12-03, 11:26
pagadala pagadala is offline
Registered User
 
Join Date: Oct 2003
Posts: 1
Acessing MQ Queue from DB2 Java Stored Procedure.

Hi all,

I need to put some messages into MQ Queue using DB2 Java Stored Procedure. I wrote the following code. But it is not putting them in MQ. Please advise.

/**
* JDBC Stored Procedure James.PROCEDURE1
*/

import java.sql.*; // JDBC classes
import com.ibm.mq.*; // Include the WebSphere MQ classes for Java package
import java.util.Hashtable;

public class PROCEDURE1 {

private static String qManager = "ITSOTestQM"; // define name of queue

// manager to connect to.
private static MQQueueManager qMgr; // define a queue manager

public static void pROCEDURE1(ResultSet[] rs1)
throws SQLException, Exception {

// Get connection to the database
Connection con = DriverManager.getConnection("jdbc:default:connecti on");
PreparedStatement stmt = null;
boolean bFlag;
String sql;

Hashtable properties;
String transport = "MQSeries";
String host = "9.182.88.173";
String channel = "java.channel";
String port = "1420";

properties = new Hashtable();
properties.put("hostname", host);
properties.put("transport", transport);
properties.put("channel", channel);
properties.put("port", new Integer(Integer.parseInt(port)));

qMgr = new MQQueueManager(qManager);

MQQueue queue = qMgr.accessQueue("ITSOTestQ", 17);

MQMessage mqmessage = new MQMessage();
mqmessage.characterSet = 1208;

mqmessage.writeUTF("Hello World!");

queue.put(mqmessage, new MQPutMessageOptions());

sql = "SELECT PROCSCHEMA, PROCNAME FROM SYSCAT.PROCEDURES";
stmt = con.prepareStatement(sql);
bFlag = stmt.execute();

rs1[0] = stmt.getResultSet();
}
}

Please advise. I added com.ibm.mq.jar, connector.jar and jta.jar in the classpath of the Stored Procedure. Do I need to any dlls into its path??

Please advise.

Thanks and Regards,
James
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