 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
bigbinc Guest
|
Posted: Sun Dec 28, 2003 6:04 pm Post subject: one time hit database connection. |
|
|
I dont know what the type of connection is called, but I know it is
the worst kind. Through a servlet, lets say I open a oracle 9.2
connection, run the query and then close the connection, will this
hurt the oracle server in terms of performance. I know this is the
least efficient way to run oracle queries but everybody does it. I
read somewhere that you can open the database connection at the start
of a session and then close the connection at the end of the session.
So the question, how much am I hurting the oracle server by the
one-time-hit-connection, if I have 10-20 users on the servlet hours at
a time. I have been doing it in asp for years.
pseduo-code:
goConnection() {
conn
try {
openconnection()
runquery();
getdata();
conn.close();
} catch() {
conn.close();
} finally() {
conn.close();
}
}
|
|
| Back to top |
|
 |
J Guest
|
Posted: Mon Dec 29, 2003 3:36 pm Post subject: Re: one time hit database connection. |
|
|
On Sun, 28 Dec 2003 13:04:43 -0500, bigbinc wrote
(in message <d1b33313.0312281004.57b27533 (AT) posting (DOT) google.com>):
| Quote: | I dont know what the type of connection is called, but I know it is
the worst kind. Through a servlet, lets say I open a oracle 9.2
connection, run the query and then close the connection, will this
hurt the oracle server in terms of performance. I know this is the
least efficient way to run oracle queries but everybody does it. I
read somewhere that you can open the database connection at the start
of a session and then close the connection at the end of the session.
So the question, how much am I hurting the oracle server by the
one-time-hit-connection, if I have 10-20 users on the servlet hours at
a time. I have been doing it in asp for years.
pseduo-code:
goConnection() {
conn
try {
openconnection()
runquery();
getdata();
conn.close();
} catch() {
conn.close();
} finally() {
conn.close();
}
}
|
Dont do that. Use a connection pool where the connections are never closed.
Read about connection pools at Apache.org. Their's is really good and easy
to use. One suggestion is to create a wrapper class around what ever pooling
library you pick. then if you need to switch between them, it makes it much
easier and safer.
J
|
|
| Back to top |
|
 |
bigbinc Guest
|
Posted: Mon Dec 29, 2003 5:52 pm Post subject: Re: one time hit database connection. |
|
|
J <webstuff (AT) fluidic (DOT) com> wrote
| Quote: | On Sun, 28 Dec 2003 13:04:43 -0500, bigbinc wrote
(in message <d1b33313.0312281004.57b27533 (AT) posting (DOT) google.com>):
I dont know what the type of connection is called, but I know it is
the worst kind. Through a servlet, lets say I open a oracle 9.2
connection, run the query and then close the connection, will this
hurt the oracle server in terms of performance. I know this is the
least efficient way to run oracle queries but everybody does it. I
read somewhere that you can open the database connection at the start
of a session and then close the connection at the end of the session.
So the question, how much am I hurting the oracle server by the
one-time-hit-connection, if I have 10-20 users on the servlet hours at
a time. I have been doing it in asp for years.
pseduo-code:
goConnection() {
conn
try {
openconnection()
runquery();
getdata();
conn.close();
} catch() {
conn.close();
} finally() {
conn.close();
}
}
Dont do that. Use a connection pool where the connections are never closed.
Read about connection pools at Apache.org. Their's is really good and easy
to use. One suggestion is to create a wrapper class around what ever pooling
library you pick. then if you need to switch between them, it makes it much
easier and safer.
J
|
But you have to admit that most people do it the bad way.
Berlin Brown
http://www.retroevolution.com
|
|
| Back to top |
|
 |
bigbinc Guest
|
Posted: Mon Dec 29, 2003 5:53 pm Post subject: Re: one time hit database connection.? |
|
|
J <webstuff (AT) fluidic (DOT) com> wrote
| Quote: | On Sun, 28 Dec 2003 13:04:43 -0500, bigbinc wrote
(in message <d1b33313.0312281004.57b27533 (AT) posting (DOT) google.com>):
I dont know what the type of connection is called, but I know it is
the worst kind. Through a servlet, lets say I open a oracle 9.2
connection, run the query and then close the connection, will this
hurt the oracle server in terms of performance. I know this is the
least efficient way to run oracle queries but everybody does it. I
read somewhere that you can open the database connection at the start
of a session and then close the connection at the end of the session.
So the question, how much am I hurting the oracle server by the
one-time-hit-connection, if I have 10-20 users on the servlet hours at
a time. I have been doing it in asp for years.
pseduo-code:
goConnection() {
conn
try {
openconnection()
runquery();
getdata();
conn.close();
} catch() {
conn.close();
} finally() {
conn.close();
}
}
Dont do that. Use a connection pool where the connections are never closed.
Read about connection pools at Apache.org. Their's is really good and easy
to use. One suggestion is to create a wrapper class around what ever pooling
library you pick. then if you need to switch between them, it makes it much
easier and safer.
J
arg,Why do I use google.posting |
Berlin Brown
http://www.retroevolution.com
|
|
| Back to top |
|
 |
J Guest
|
Posted: Sun Jan 04, 2004 4:42 am Post subject: Re: one time hit database connection. |
|
|
On Mon, 29 Dec 2003 12:52:15 -0500, bigbinc wrote
(in message <d1b33313.0312290952.177ba177 (AT) posting (DOT) google.com>):
| Quote: |
Dont do that. Use a connection pool where the connections are never
closed.
Read about connection pools at Apache.org. Their's is really good and
easy
to use. One suggestion is to create a wrapper class around what ever
pooling
library you pick. then if you need to switch between them, it makes it
much
easier and safer.
J
But you have to admit that most people do it the bad way.
Berlin Brown
http://www.retroevolution.com
|
A lot of people use to use GOTO in programs. Doesn't mean you should do it.
Using a connection pool is easier than using createConnection() everywhere.
J
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|