- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
wrist!
Admin
been a while since I did anything serious in Java, but since when does Java provide connection pooling out of the box? I'm talking of course Java SE, don't know about JEE
Admin
I suspect nobody thought about anything when developing this code.
Admin
if(commentIndex() == "thrid") Application.Exit(0);
Admin
It's also been a long minute for me, but my recollection is that most JDBC drivers implement it internally. I suppose they could be using a JDBC driver that doesn't, but that seems implausible to me.
Admin
A bad developer ignores built in solutions in favor of his own.
A real expert rolls his own and makes sure to completely follow all the interfaces of the built in stuff and use similar names (same names different namespace for best results). And than makes his version do half the things and with double the bugs. Also, make sure to only ever use the custom stuff as a recompiled library and loose or better yet partially loose the source.
Don't ask me how I know...
Admin
Most JDBC drivers I know don't support connection pooling. However, considering that this is a JEE service, it should be running on an application service like JBoss/WildFly, Glassfish, WebLogic, etc. All of these provide database connection management, including connection pooling. After that all you need to do is inject a DataSource, and get its connections from there
Admin
I'd like to give bonus points for terrible formatting. No space after the "if", but instead extra spaces between each pair of brackets. And don't forget the extra parentheses on the first line...
Admin
*lose *lose
Admin
Agree the spaces after
(
and befioe)
are unusual; I'm not sure I've ever seen that in the wild.But here they're employed consistently and they do serve the purpose of clearly separating the operand from the statement/operator. I find I sort of like that look & feel. Makes visually scanning the code for whatever you're seeking a bit easier than the "cram it all as tightly together as the parser will accept" method.
Admin
JDBC drivers do not have connection pooling built in. You have to adopt some implementation of connection pooling if you want it.
Further, if this code were written in say 2000 or so, then you really did have to build your own connection pooling unless you really wanted to use one of the commercial products or server products.
Admin
"makes his version do half the things"
Don't forget he also adds some subtle "extensions", too, making it a nightmare to port back to the built-in functions.
Admin
There was a connection leak. This is an epic kludge fix.
Admin
He's half right though. If there are too many connections, we should do something and not just keep opening more and more. This is a problem we encounter frequently. What they did, of course, is the absolute worst solution. What would be good is to reject traffic over some threshold, so that at least traffic under the threshold can still be served. But that's difficult to do correctly I guess.
Admin
It's how I do mine.
My ( and ), [ and ], { and } demand their own airspace, no infringing on it!!!