leave connection open or close
Hello
I have an agent(s) that updates my database every week. The agents taks around 3-4 hours to do it job and update the database. The problem is that it must update each term one by one, there are 5000 terms for each agent . Which method is better:
1: for each term
open connection, update, close connection
2: open connection
update each term
close connection.
which has less cost and less stress on the network...
thanks,
Ehsan
[495 byte] By [
Ehsan.Sa] at [2007-11-27 7:32:38]

# 1
How do you update a "term"?Do you mean a table- row with a term or what?Do want to open the database connection to update each row or for 5000 row's once a week?
# 2
How do you update a "term"?
Do you mean a table- row with a term or what?
I have no control over the structure of the database, its a RDF repository created by JENA. so I just tell it to update the jena model. But I do have control over when to create a connection.
Do want to open the database connection to update each row or for 5000 row's once a week?
I am asking this question, should I open a new connection for each term or should I open the connection , update the repository and then close the connection.
I want to know which one uses less resources. Both work fine in testing but in the long run I don't know.
cheers,
Ehsan
# 3
I've still not understood you problem completely.But I would never connect 5000 times in 3 hours to a database and update something if I could do that within one connection/session.Why you want to connect each time?
# 4
Consider connection pooling.
# 5
> I want to know which one uses less resources. Both> work fine in testing but in the long run I don't> know.Is it not obvious that doing something uses more resources than doing nothing?
# 6
Hellodosen't connection pooling mean that you create a permanent connection and tell the other programs to jump in whenever they want? cheers,ehsan
# 7
I'd see it this way - if I have understood your question correctly:
Having an open connection during the whole process is definitely less heavy network wise. This means in essence, that you won't have as much overhead per changed value then with the other option, which would be to close the connection and open a new one every time you change a "term".
However, having an open connection over a longer period of time makes the risk higher to have a connection drop (in a linear way - over time), and if you don't check for an open connection every time you change something, you might end up in troubles.
Which is the only reason why, in my opinion, the later option, to close and open the connection for each "term" will give you a safer way - as in, you are quite sure that you have a working connection for every change you are making.
What this means to you in essence, is that you have to either decide whether to go the safer (though more resource intensive) or the faster (and less safe) way.
I do hope I understood the reason behind your question, and hope to have answered it in a decent and useful way.
Bob
# 9
my porject is java flatform.
i have 10 windows .. each windows access the database ..
tell me which way is efficient...
1.when i log into the project ob that time open the connection and close the connection after all my work get completed..
2.when i open the each window on that time i open the window and close the connection when i close that particular win...
so for this 2 method require totally 10 open and close connection...
in above 2 methods which is best method.. and which is efficiency..
today date:15-05-2007
day:friday
by
bharanikumar
# 10
my porject is java flatform.
i have 10 windows .. each windows access the database ..
tell me which way is efficient...
1.when i log into the project ob that time open the connection and close the connection after all my work get completed..
2.when i open the each window on that time i open the window and close the connection when i close that particular win...
so for this 2 method require totally 10 open and close connection...
in above 2 methods which is best method.. and which is efficiency..
today date:15-05-2007
day:friday
by
bharanikumar
# 11
my porject is java flatform.
i have 10 windows .. each windows access the database ..
tell me which way is efficient...
1.when i log into the project ob that time open the connection and close the connection after all my work get completed..
2.when i open the each window on that time i open the window and close the connection when i close that particular win...
so for this 2 method require totally 10 open and close connection...
in above 2 methods which is best method.. and which is efficiency..
today date:15-05-2007
day:friday
by
bharanikumar
# 12
my porject is java flatform.
i have 10 windows .. each windows access the database ..
tell me which way is efficient...
1.when i log into the project ob that time open the connection and close the connection after all my work get completed..
2.when i open the each window on that time i open the window and close the connection when i close that particular win...
so for this 2 method require totally 10 open and close connection...
in above 2 methods which is best method.. and which is efficiency..
today date:15-05-2007
day:friday
by
bharanikumar
# 13
my porject is java flatform.
i have 10 windows .. each windows access the database ..
tell me which way is efficient...
1.when i log into the project ob that time open the connection and close the connection after all my work get completed..
2.when i open the each window on that time i open the window and close the connection when i close that particular win...
so for this 2 method require totally 10 open and close connection...
in above 2 methods which is best method.. and which is efficiency..
today date:15-05-2007
day:friday
by
bharanikumar
# 14
my porject is java flatform.
i have 10 windows .. each windows access the database ..
tell me which way is efficient...
1.when i log into the project ob that time open the connection and close the connection after all my work get completed..
2.when i open the each window on that time i open the window and close the connection when i close that particular win...
so for this 2 method require totally 10 open and close connection...
in above 2 methods which is best method.. and which is efficiency..
today date:15-05-2007
day:friday
by
bharanikumar
# 15
my porject is java flatform.
i have 10 windows .. each windows access the database ..
tell me which way is efficient...
1.when i log into the project ob that time open the connection and close the connection after all my work get completed..
2.when i open the each window on that time i open the window and close the connection when i close that particular win...
so for this 2 method require totally 10 open and close connection...
in above 2 methods which is best method.. and which is efficiency..
today date:15-05-2007
day:friday
by
bharanikumar