Author |
Message
|
er_pankajgupta84 |
Posted: Mon Jan 23, 2012 11:44 am Post subject: Java database connection pooling |
|
|
 Master
Joined: 14 Nov 2008 Posts: 203 Location: charlotte,NC, USA
|
We are using extensive java and looking for the option of maintaining connection pool.
1. One option is to use Broker JDBCProvider for type 4 connections.
2. Use apache connection pool logic.
Basically all the connection pool & db connection related stuff would remain in an external JAR.
I would like to go with option 1 if it is full proof. Can anybody suggest any limitation of it.
I have read in info center that they have problems / can't be used on Z\OS. Has someone seen any such behaviour.
Anyone with sucessful implementation of getJDBCType4Connection in production.
Throw some light. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Jan 23, 2012 11:46 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Option 1 should be your only logical choice for WMB code. If you choose Option 2, also choose a different ESB than WMB please. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jan 23, 2012 12:22 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
er_pankajgupta84 |
Posted: Mon Jan 23, 2012 12:51 pm Post subject: |
|
|
 Master
Joined: 14 Nov 2008 Posts: 203 Location: charlotte,NC, USA
|
I am on 6.1 with fixpack 3.
Is there anything that is missing for using JDBC Type 4 on ZOS in v6.1?
Moreover Can i write that (JDBC connection pooling) code outside of JavaCompute node by passing its reference to non - JavaCompute node class? |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jan 23, 2012 12:54 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
er_pankajgupta84 wrote: |
Can i write that (JDBC connection pooling) code outside of JavaCompute node by passing its reference to non - JavaCompute node class? |
Sounds rather like this discussion may be relevant.
Why do you want / need to pass the database connection reference between different classes? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jan 23, 2012 12:58 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The same link in the 6.1 info center.
Yes, you can abstract the connection pooling and connection logic into a separate java project and a separate java class file, and then use that from within your JCN code.
But you can't have Broker run any Java code that is not initiated from a JCN.
So what you end up with is a model where your JCN acts as an interface layer to retrieve needed information from the input message, and pass this into a data object layer that then deals with connections and etc.
If you're using getJDBCtype4Connection, you would call that from your JCN class, and pass this into your data object layer.
As in all java code, regardless of where you deploy it, you want to keep your code with as few layers as possible. So keep it as simple as you can. |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Jan 23, 2012 1:14 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
mqjeff wrote: |
As in all java code, regardless of where you deploy it, you want to keep your code with as few layers as possible. So keep it as simple as you can. |
Sadly, I know a number of Java devs who would totally disagree with you. They are from the school that says, 'If a class has more than a half a dozen lines it is too complicated. If this is the case, you must make more classes out of it.' There are tomes on Java Dev that support this approach.
One bit of code I reviewed in a JBOSS setup went down more than 20 classes deep.
Personally I find that approach almost impossible to understand. The code is so obfuscated that it gets  _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jan 23, 2012 1:26 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
smdavies99 wrote: |
One bit of code I reviewed in a JBOSS setup went down more than 20 classes deep. |
Did they get paid based on the length of the stacktrace?
yes, I'm well aware of this school of java dev. I'm well aware of how prevalent, and poorly thought out, it is. |
|
Back to top |
|
 |
adubya |
Posted: Mon Jan 23, 2012 1:33 pm Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
A developer on my current project was allowed to implement a CSV file transformation flow using a JCN rather than good old ESQL. He went object crazy as described above and trying to understand the code and find where the "nitty gritty" actually takes place is not easy.
That won't be happening again  |
|
Back to top |
|
 |
er_pankajgupta84 |
Posted: Mon Jan 23, 2012 1:41 pm Post subject: |
|
|
 Master
Joined: 14 Nov 2008 Posts: 203 Location: charlotte,NC, USA
|
Quote: |
Why do you want / need to pass the database connection reference between different classes? |
The code to interact with database will go in an external jar.
Currenlty they are using Spring based connection pooling (custom developed code) for the tables used by broker. All the Database related stuff lies in an external jar.
I was trying to see if we can fit JDBC Type 4 based connection pooling in there. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jan 23, 2012 1:44 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
er_pankajgupta84 wrote: |
Quote: |
Why do you want / need to pass the database connection reference between different classes? |
The code to interact with database will go in an external jar.
Currenlty they are using Spring based connection pooling (custom developed code) for the tables used by broker. All the Database related stuff lies in an external jar.
I was trying to see if we can fit JDBC Type 4 based connection pooling in there. |
Yes, you should be able to replace the Spring framework connection pools with jdbcType4connections.
You are encouraged to do so.
You will have to pay attention to what the infocenter says about JDBC drivers, however. And you should look at putting any external jars in shared-classes (at 6.1 and earlier) instead of in the BAR file. At 7.0, you should put them in a configurable service. At 8.0, you should consider including them in an Application. |
|
Back to top |
|
 |
er_pankajgupta84 |
Posted: Tue Jan 24, 2012 7:13 am Post subject: |
|
|
 Master
Joined: 14 Nov 2008 Posts: 203 Location: charlotte,NC, USA
|
Thanks Guys,
I will develop a prototype and post my observation here.
Quote: |
you should look at putting any external jars in shared-classes (at 6.1 and earlier) instead of in the BAR file. At 7.0, you should put them in a configurable service. At 8.0, you should consider including them in an Application. |
We never put any external jar in EG / barfile. But it would be nteresting to know the option of configurable service and Application with version 7 & 8 resp.
I will look into it. |
|
Back to top |
|
 |
er_pankajgupta84 |
Posted: Tue Jan 24, 2012 3:03 pm Post subject: Another problem. |
|
|
 Master
Joined: 14 Nov 2008 Posts: 203 Location: charlotte,NC, USA
|
Is it advisable to create an instance of JCN at runtime to call getJDBCType4Connection method or rather this thing is possible by implementing a java class extending JCN and then using that reference.
The problem is the current code that use the connection pooling implemented thru external jar reside in NON-JavaCompute java node, and is called from esql node.
How can I make a JCN reference availabe in a Java class which is called from esql file. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Jan 25, 2012 5:53 am Post subject: Re: Another problem. |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
er_pankajgupta84 wrote: |
Is it advisable to create an instance of JCN at runtime to call getJDBCType4Connection method or rather this thing is possible by implementing a java class extending JCN and then using that reference.
The problem is the current code that use the connection pooling implemented thru external jar reside in NON-JavaCompute java node, and is called from esql node.
How can I make a JCN reference availabe in a Java class which is called from esql file. |
Your answer is in the InfoCentre or in the WM663 class. If you would spend your own time looking at either or both, we would be greatly appreciative. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
|