Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / October 2006

Tip: Looking for answers? Try searching our database.

connection on application initialisation

Thread view: 
filip - 24 Oct 2006 11:38 GMT
Is it a practise to make the connection on application initialisation
(talking about jsp, servlet type app.), so you don't make connections every
time you query database, you have it all the time, and then just grab it
from app. scope/context and execute Statements?
if so, any tips on how to do it.
Oliver Wong - 24 Oct 2006 14:47 GMT
> Is it a practise to make the connection on application initialisation
> (talking about jsp, servlet type app.), so you don't make connections
> every time you query database, you have it all the time, and then just
> grab it from app. scope/context and execute Statements?
> if so, any tips on how to do it.

   I believe what's usually done is a connection pool is established and
shared throughout your webapp. See
http://www.jguru.com/faq/view.jsp?EID=112097

   - Oliver
polilop - 25 Oct 2006 07:35 GMT
it says on the given link
>If you are using a J2EE Server, you should be able to access a connection
>pool via >JNDI and retreive the a connection. If you are not using a J2EE
>Server, you can >download (or write) a connection pool, and install it into
>your JSP/Servlet >application, and share it via the application space.

dose this mean that when i make a datasource (with JNDI) and call
datasource.getConnection(); i am getting a con from the pool not
establishing con to the database?

>> Is it a practise to make the connection on application initialisation
>> (talking about jsp, servlet type app.), so you don't make connections
[quoted text clipped - 7 lines]
>
>    - Oliver
Oliver Wong - 25 Oct 2006 15:25 GMT
> it says on the given link
>>If you are using a J2EE Server, you should be able to access a connection
[quoted text clipped - 6 lines]
> datasource.getConnection(); i am getting a con from the pool not
> establishing con to the database?

http://java.sun.com/j2se/1.5.0/docs/api/javax/sql/DataSource.html
<quote>
The DataSource interface is implemented by a driver vendor. There are three
types of implementations:

  1. Basic implementation -- produces a standard Connection object
  2. Connection pooling implementation -- produces a Connection object that
will automatically participate in connection pooling. This implementation
works with a middle-tier connection pooling manager.
  3. Distributed transaction implementation -- produces a Connection object
that may be used for distributed transactions and almost always participates
in connection pooling. This implementation works with a middle-tier
transaction manager and almost always with a connection pooling manager.
</quote>

   In other words, it depends on your drivers.

   - Oliver
Arne Vajhøj - 26 Oct 2006 00:43 GMT
>> dose this mean that when i make a datasource (with JNDI) and call
>> datasource.getConnection(); i am getting a con from the pool not
[quoted text clipped - 16 lines]
>
>     In other words, it depends on your drivers.

Yes or no.

Explanation:

It does not depend on anything in the JDBC driver.

It depends on the datasource class used in the app server
(or servlet container).

And in practice it will always use a connection pool.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.