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 » How to Cache database connections using JDBC in MB v6

Post new topic  Reply to topic
 How to Cache database connections using JDBC in MB v6 « View previous topic :: View next topic » 
Author Message
ydsk
PostPosted: Fri Aug 17, 2007 11:54 am    Post subject: How to Cache database connections using JDBC in MB v6 Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

Hi,

I have a Java Compute Node in a flow running on a Windows/AIX broker that connects using a JDBC connection to an external database running on AS400.

The code is working but as of now it is connecting to the database every time.

I want to connect to the database just once and cache the connection for further processing of messages.

Any suggestions on how to cache the connection and reuse it ?

Thanks.
ydsk.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Aug 17, 2007 2:34 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

The same way you would do this with any other JDBC connection, that is not running in an Application Server.

You likely, by the way, have very little good reason for using JDBC here. It should be entirely possible to use ODBC.

Remember, also, that every execution group is it's own JVM. So do not expect to be able to cache connections across execution groups.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mymq
PostPosted: Sat Aug 18, 2007 7:18 pm    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2007
Posts: 101
Location: US-Greenwille

U can better to have some adapters to do so.
_________________
--SRK--
Back to top
View user's profile Send private message Send e-mail
ydsk
PostPosted: Mon Aug 20, 2007 9:44 am    Post subject: Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

The ODBC option was explored already and it was decided that ODBC can't be used. So, we are using JDBC.

Is there no way of achieving it programmatically rather than using some adapters ?

Of course, we use a JDBC driver ( a jar file). The code is working for now but as I said it is making a JDBC connection for every message.

Any suggestions ?

Thanks.
ydsk.
Back to top
View user's profile Send private message
ydsk
PostPosted: Wed Aug 22, 2007 10:06 pm    Post subject: code in MbJavaComputeNode's constructor executing twice Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

Finally, I think I implemented some sort of caching by putting the following 2 lines of code in the constructor of the class that extends MbJavaComputeNode :

DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
conn = DriverManager.getConnection("jdbc:as400://" + system, AS400props);

I added a println statement in between the 2 statements above BUT I see it getting executed TWICE ( implying the 2 statements above are getting executed twice ) whenever I deploy the msgflow to an execution group. There are NO additional instances of the flow in the bar file, and just 1 execution group.

To add, I verified that the 2 statements above are getting executed TWICE whenever I deploy the flow by introducing some more println statements in the constructor.

I don't have any other way of verifying the execution of code inside the constructor because it gets executed just after deployment only and NOT for every message that gets processed. The debugger doesn't show the execution of the constructor so I resorted to a bunch of println statements.

Can somebody please explain why the code in the contructor is getting executed twice ? It's happening consistently just after deploying the bar file. I tried restarting my broker and the box a few times but the behavior is still the same.


Thanks.
ydsk.
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 » How to Cache database connections using JDBC in MB v6
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.