which scenarios we go for jdbc,and which scenario we go for
connection polling and wat r advantages and disadvantages
using connection pooling.
Answers were Sorted based on User's Feedback
See from first onwards i am speaking
there are two types of connection object one is Direct
Connection object and second is Pooled connection object
The object which is created,managed ,destroyed manually is
called as Direct connection object and if connection object
is collected from connetion pool is called as Pooled
connection object
now let us see each very clearly
When ever we try to create connection object than new
connection will be created ,ok,now when new clint will come
dynamically than he will use readily available connection
object to have interaction with underlying database
software,now , suppose multiple clients will come to use
connection object than what happens, Since, we have only one
connection object than we can provide service to one client
at time , i mean second client has to wait till first client
completes his work , think about large scale application, i
mean if more than two clients will come to use this
connection object e.g. Banking application .Definitely one
connection object can not provide service to multiple
clients , see , it can provide but will take much time to
provide service .ok, now think about our passions ,hardly
how much time we can wait for twenty thirty or forty minutes
but if it exceeds than what will happen , suddenly you will
leave that bank and will close account and which will , in
turn , mishap on organisation who has developed that project.
So , we have to provide service right there exactly
connection pool will come on to the picture.ok, so it is
highly recommended to work with connection pool concept.
now another thing is jdbc see
jdbc is a specification given by sun microsystem and it is
again devided into four types and jdbc connection pool
concept is coming under type-3 ok so don't use jdbc term
separately rather than use type-1 or type-2 or type-4 and my
recommendation is to work with type-4 driver only.
Before going to advantage and disadvantage first what is
conncetion pool?
connection pool is a pool which contains set of readyily
available conncetion objects which can provide service to
more number of clients using less number of conncetion
object.e.g. think about our college , what happens here.
each student occupies chair to seat provided by
administratator , if administrator tells each student to
bring his own chair than what will happen just think and
compare it exactly with Direct connection object ok.
now come to chairs provided by administrator i mean they
think that each session will contain 100 students and
providing 100 chairs at a time and providing service to more
than 100 students.how, each session will contain 100
students so how many sessions can be conducted per day .now,
just imagine how connection pool is compatible with given
example.
Advantage
---------
->Advantage what i have given above not only that programmer
should think it is burden of creating , managing ,destroying
conncetion object , each task responisbility will be taken
care by connection pool
Disadvantage
------------
->I hope you will not get any disadvantage from connection pool
for more information call 9989683928 , i belong to hyd
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / mukundan
First part of the question seems irrelevant as JDBC has to
be used to access RDB irrespective of whether Connection
pooling is used or not.
Advantage of creating and using connection pooling is to
share the number of connections to the database in an
organized and distributed ways when the same RDB is used by
multiple applications.
Using connection pooling is advantageous
(1) the application doesn't overshoot with the number of
connections available/allotted for the application
(2) creating connection with a RDB is a costly operation
where as this is done one time and a pool of connection is
created during the startup of the application
(3) Connections from the pool are readily available for use
and they are reused which is much faster as per (2) above
Disadvantages of Connection pooling:
(1) When multiple application uses a RDB, each application
grabs its share (the allotted number of connections) during
start-up irrespective of its usage of the grabbed
connections. For example, if one application grabs 100
connections up front and its peak usage is only 40 or 50
then they are strictly not available to any other
application who's peak usage may be more than their allocation.
(2) If connections are not released appropriately by the
applications then the performance of the systems could go
haywire.
Is This Answer Correct ? | 4 Yes | 0 No |
How to use JDBC API to call Stored Procedures?
java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I used oracle10G. I set CLASS PATH:C:\oraclexe\app\oracle\product\10.2.0 \server\jdbc\lib\ojdbc14.jar; I write JDBC PROGRAM like import java.sql.*; class Example { public static void main(String args[]) { try { Class.forName ("oracle.jdbc.driver.OracleDriver"); System.out.println("Driver Loaded"); Connection con=DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:xe","system","salmas"); System.out.println("Driver Connected"); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from emp"); while(rs.next()) { System.out.println(rs.getInt(1)); System.out.println(rs.getString(2)); System.out.println(rs.getString(3)); } st.close(); con.close(); } catch(Exception e) { System.out.println(e); } finally { System.out.println("it's finally block executed"); } } }
What are the different types of statements?
What is ODBC and JDBC? How do you connect the Database?
What is jdbc and odbc in java?
List some new features available in jdbc 4.0?
Why is odbc needed?
What are the main components of JDBC ?
How to get the Database server details in java program?
Is jdbc and orm?
What are different types of JDBC Drivers?
What is the function of drivermanager class?