Meaningless Drivel is fun!
The moose likes Servlets and the fly likes Connection Pool  WITHOUT Jdbc, with Jsp/Servlet/Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Connection Pool  WITHOUT Jdbc, with Jsp/Servlet/Java" Watch "Connection Pool  WITHOUT Jdbc, with Jsp/Servlet/Java" New topic

Connection Pool WITHOUT Jdbc, with Jsp/Servlet/Java

Raxit Sheth

Joined: Jun 20, 2007
Posts: 4
I am having following Scenario.

Browser <---> WebLogic <---> DataStore (Not RDBMS) WebLogic using only for jsp/servlet as Web Server (I am not using any hifi facility of application server.)

I am having some core Java + Jsp + Servelet code deploy on WebLogic.As my datastore is not supporting SQL and Jdbc, I can't use Jdbc. (and also not want to use SQL in future.) To connect to Datastore, I am using Socket code of Java.

--client will hit the Jsp/Servlet page.
--It will invoke internally core java code to Connect with Data Store,(i will not create any thread as this is the responsiblity of Jsp/servlet vendor.)

--Request some data from Data Store,
--Disconnect from data store
--pass Data to User Browser

As my Datastore is multithreaded program, and when i run my Java code, i found Bottleneck.
I am everytime opening and closing the Connection for doing Little Work. and so I think something like ConnectionPool stuff.

What I want is My JSP/Servlet/ program should start few ***threads*** which connect to DataStore.

When Request come, it should not Waste the time in creating, opening /closing socket connection,

It should quickly send request, get response and wait for next request.

i know almost all Jdbc providers are giving JdbcPool or simillar stuff.

But when I asked to few people they are suggesting, I can not do thread/socket programming in WebLogic/Servlet. (then how JdbcPooling works with WebLogic.? dont'know)

any Idea how to do that ?

any weblink, or book suggestion will be good help.

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by raxit. sheth.:

To connect to Datastore, I am using Socket code of Java.

How are you using socket to connect to datasource?

Rahul Bhattacharjee
LinkedIn - Blog
Raxit Sheth

Joined: Jun 20, 2007
Posts: 4
Hi Rahul,

The connection code is Very much Separated from Other Logic and It is static class. (and Only this class is doing connection to DataStore , Everyone else using this class to send request to data store.)

string DataStoreResponse = MyClass.sendRequestToDataStore(String request)
MyClass is static class. !

sendRequesToDataStore {
Open Connection.
Send Request
Close Connection
Return ResponseStringToCaller.

Please note : this method is ***indirectly*** called by Jsp/Servlet.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

I'm doing something similar where I work (non SQL/JDBC database).

Before the manufacturer provided a connection pool for use with its middle-ware product we built and used our own. We used the connection pool code in the first edition of Core Servlets and Java Server Pages as a start.

The whole book, with source code, is available as a free download.

See chapter 18.

It shouldn't be difficult for you to modify that connection pool to work with your custom Connetion/Socket objects.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The BlockingQueue in the library is a pretty good pooling mechanism. Put in as many connections as you want at startup then:

If there are no free connections when you get() you block until another thread does a put(). You could use a non-blocking queue and make more connections when it's empty if you don't mind pool growth.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
It is sorta covered in the JavaRanch Style Guide.
subject: Connection Pool WITHOUT Jdbc, with Jsp/Servlet/Java
It's not a secret anymore!