ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MbSQLStatement problems with DB2 access from JavaCompute

Post new topic  Reply to topic
 MbSQLStatement problems with DB2 access from JavaCompute « View previous topic :: View next topic » 
Author Message
kayhansefat
PostPosted: Tue Mar 27, 2007 12:57 am    Post subject: MbSQLStatement problems with DB2 access from JavaCompute Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

I am having problems connecting to a DB2 database on the same maching as the broker. I have readup on the help:

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac30494_.htm

I am confused as to whether or not I have to setup the database as an ODBC datasource. I have used the following code:

Code:

MbMessage newMsg = new MbMessage(assembly.getMessage());
MbMessageAssembly newAssembly = new MbMessageAssembly(assembly, newMsg);
MbSQLStatement state = createSQLStatement("LETTERDB","SET OutputRoot.XML.integer[] = PASSTHRU
('SELECT * FROM GPSENT_LETTERS');");

state.setThrowExceptionOnDatabaseError(false);
state.setTreatWarningsAsErrors(true);
state.select(assembly, newAssembly);
int sqlCode = state.getSQLCode();

if (sqlCode != 0)
{
               
}
else
{
    addToLog("Test", "sqlCode = 0, all ok?");               
}


The "assembly" that I am using here is what is passed into the JavaCompute Node from an MQInput which is part of the XMLNSC domain. But this causes an exception when the state.select(assembly, newAssembly) method is run. The exception reads:

Quote:
<com.ibm.broker.plugin.MbDatabaseException class:JNI method:ImbOdbcHandle::checkRcInner source:BIPv600 key:2321 >


Is there anything that I need to do DB2 side to prepare this? Thanks
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Mar 27, 2007 3:08 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Yes you need to set up the Database with the ODBC access....
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kayhansefat
PostPosted: Tue Mar 27, 2007 3:49 am    Post subject: Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

I have followed the manual in the DB2 Info Center titled "Setting up the UNIX ODBC environment". So I have the file /var/mqsi/odbc/.odbc.ini which includes:

Code:
LETTERDB=IBM DB2 ODBC Driver

[ODBC]
Trace=0
TraceFile=/var/mqsi/odbc/odbctrace.out
TraceDll=/opt/mqsi/merant/lib/odbctrac.so
InstallDir=/opt/mqsi/merant
UseCursorLib=0
IANAAppCodePage=4

[LETTERDB]
Driver=/opt/IBM/db2/v8.1/lib/libdb2.so
Description=LETTERDB Broker Database
Database=LETTERDB


The user that runs the toolkit etc has the db2profile run on login so thats not the problem.

So I think I am not doing something correct in db2 to setup the database for ODBC access. In the Control Center, under the Configuration Assistant I can see that the database is "ODBC Registered = No". If I then double click on the DB it takes me into the Change Database Wizard, section 4 Data Source, Register this db for ODBC is ticked as a System Data Source with the name LETTERDB and then click Finish. However it is still set to "No" under the ODBC Registered field in the list view.

Any ideas......
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 27, 2007 3:56 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I've never had to do anything within DB2 on Unix to enable ODBC access.

You might need to bind the db2 database against the client libraries.

You can try
Quote:
db2 bind ~/sqllib/bnd/@db2cli.lst blocking all sqlerror continue messages cli.msg grant public

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kayhansefat
PostPosted: Tue Mar 27, 2007 4:14 am    Post subject: Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

Running that command returns:

Quote:
SQL1024N A database connection does not exist. SQLSTATE=08003
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 27, 2007 4:25 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

well, db2 connect LETTERDB first.

And I don't know that this will solve your problem, as I don't know what your problem is.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kayhansefat
PostPosted: Tue Mar 27, 2007 4:47 am    Post subject: Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

Doing a "db2 connect LETTERDB" returns:

Quote:
SQL0104N An unexpected token "LETTERDB" was found following "CONNECT". Expected tokens may include: "END-OR-STATEMENT". SQLSTATE=42601


My problem is that I am unable to connect to the ODBC DataSource when issuing the select() method on the MbSQLStatement class variable. The code in my first post causes an MbException. The details for the exception state that the ODBC return code was 'null'.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 27, 2007 7:01 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Sorry, I guess it's "db2 connect to LETTERDB".

Do you have a DBA available? You should probably start working with someone local who knows DB2 better than you do.

The DB2 information center for version 8.2 is at

http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp

But there's a lot lot lot of information in there, most of which won't be relevant.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Mar 28, 2007 1:55 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

And if you are using the broker you should still use the merant driver for db2 and not the db2 driver...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Wed Mar 28, 2007 2:16 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

fjb_saper wrote:
And if you are using the broker you should still use the merant driver for db2 and not the db2 driver...


FJ... I'm a little confused. If one is using MbSQLStatement, then one is using the ODBC datasource, which of course has been properly configured to use the right driver.

If one is using Type 4 JDBC, then one shouldn't be using the Merant driver, but the proper Type 4 JDBC Driver for the database.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Mar 28, 2007 2:26 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

kayhansefat wrote:
I have followed the manual in the DB2 Info Center titled "Setting up the UNIX ODBC environment". So I have the file /var/mqsi/odbc/.odbc.ini which includes:

Code:
LETTERDB=IBM DB2 ODBC Driver

[ODBC]
Trace=0
TraceFile=/var/mqsi/odbc/odbctrace.out
TraceDll=/opt/mqsi/merant/lib/odbctrac.so
InstallDir=/opt/mqsi/merant
UseCursorLib=0
IANAAppCodePage=4

[LETTERDB]
Driver=/opt/IBM/db2/v8.1/lib/libdb2.so
Description=LETTERDB Broker Database
Database=LETTERDB




I hope this clears your confusion Jeff.
It appears that he is using the db2 driver for the db and the merant driver for the trace ???
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Wed Mar 28, 2007 2:45 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

fjb_saper wrote:
It appears that he is using the db2 driver for the db and the merant driver for the trace ???


Yes, that appears to be correct.

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/ah14449_.htm
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Mar 28, 2007 2:51 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Thanks for setting me straight ...
I learn every day with you...

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Wed Mar 28, 2007 2:58 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

fjb_saper wrote:
I learn every day with you...


I promise it's mutual.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kayhansefat
PostPosted: Fri Mar 30, 2007 2:37 am    Post subject: Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

If I use the default database that the broker uses, not LETTERDB, then it seems to work fine. Seems like I have to register the new Database with the broker somehow.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MbSQLStatement problems with DB2 access from JavaCompute
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.