permaculture playing cards*
The moose likes JDBC and the fly likes Setting Connection Time Out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Setting Connection Time Out" Watch "Setting Connection Time Out" New topic
Author

Setting Connection Time Out

Tanzy Akhtar
Ranch Hand

Joined: Jul 19, 2009
Posts: 110
Hi,

Is there any way to set the connection object so that it will preserve
for a given time.
For instance, if we create a connection object and this connection object
must not be timed out before half an hour.

I need this because in my module i am creating connection object when connection is null.
Once connection got created, it preserved.

This module executes for more than three hour.
Now what is happening that module becomes idle for some time aqnd then throwing
exception of connection timed out.

This is why i need to set connection preserve time.

Or, Is there any way to avoid connection time out error?

Any clue?

Thanks,
Tanzy.


Roll with punchers, there is always tomorrow.
Techie Blog -- http://jtanzy.blogspot.com/
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Two solution I thought of:
1. Increase the connection time out variable time in your Database environment.
2.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

You are not using a connection pool? Or how you use the Connection (through DriverManager/...) ?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Tanzy Akhtar
Ranch Hand

Joined: Jul 19, 2009
Posts: 110
Hi Sagar,

Thanks for the reply.

Well i did not use first solution ever.
Could you please tell me how to do this.

In second, i am already doing it.


Thanks,
Tanzy.
Tanzy Akhtar
Ranch Hand

Joined: Jul 19, 2009
Posts: 110
Hi Vijitha,

Well i need just one connection object.
So is there any benefit to use connection pool?

Thanks,
Tanzy.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

tanzy akhtar wrote:Well i need just one connection object.So is there any benefit to use connection pool?


Then no need.
Tanzy Akhtar
Ranch Hand

Joined: Jul 19, 2009
Posts: 110
Thank You Vijitha.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

tanzy akhtar wrote:Well i did not use first solution ever.
Could you please tell me how to do this.

It depnds upon the datbase you're using, e.g in MySQL, we use this:
http://www.forum.psoft.net/archive/index.php/t-9752.html

tanzy akhtar wrote:In second, i am already doing it.

For second, I was bit wrong, actully I want to say like this;

Tanzy Akhtar
Ranch Hand

Joined: Jul 19, 2009
Posts: 110
Wow! Good one.

Thank you Sagar.

I will do it in my code.

Well the database we are using is oracle 10g.
So is there any diferent way to set the connection time out?


Thanks,
Tanzy.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

tanzy akhtar wrote:Well the database we are using is oracle 10g.
So is there any diferent way to set the connection time out?

Google JDBC + Oracle 10g + set timeout
between I found this attribute " inactivity-timeout", so you can construct your connection string, like this

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting Connection Time Out
 
Similar Threads
Socket operation timed out before it could be completed
Connection timed out
java.net.ConnectException: Connection timed out: connect
Connection timeout value for DB2 db
ClientAbortException