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 / General / August 2006

Tip: Looking for answers? Try searching our database.

tip: how to control time to try getting connection?

Thread view: 
John_Woo - 05 Aug 2006 13:04 GMT
Hi,

I want some tips for, ex

Connection con = DriverManager.getConnection(url,"met", "pass"); //A

System.out.println(con); //B

It may take 10-20 seconds to know what con is. I'm wondering, how to
limit the time, say in 5 seconds, if line A will have NOT yet finished,
just stop it and execute line B.

any idea?

--
Thanks
John
Toronto
Moiristo - 05 Aug 2006 15:55 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> limit the time, say in 5 seconds, if line A will have NOT yet finished,
> just stop it and execute line B.

maybe you could use DriverManager.setLoginTimeout(int seconds)?
John_Woo - 05 Aug 2006 19:44 GMT
> > Hi,
> >
[quoted text clipped - 9 lines]
>
> maybe you could use DriverManager.setLoginTimeout(int seconds)?

Thanks, but what I wanted was to limit the time to get a connection,
not the time of keeping connected.

John
EJP - 06 Aug 2006 05:21 GMT
>>maybe you could use DriverManager.setLoginTimeout(int seconds)?
>
> Thanks, but what I wanted was to limit the time to get a connection,
> not the time of keeping connected.

Try the Javadoc next time. setLoginTimeout() 'sets the maximum time in
seconds that a driver will wait while attempting to connect to a
database'. It is exactly what you want, and it has nothing to do with
'the time of keeping connected'.
John_Woo - 06 Aug 2006 13:42 GMT
> >>maybe you could use DriverManager.setLoginTimeout(int seconds)?
> >
[quoted text clipped - 5 lines]
> database'. It is exactly what you want, and it has nothing to do with
> 'the time of keeping connected'.

Yes, the javadoc did say that.
guessed I have not yet got a good example illustrated what I wanted to
stop the attempting to get connection.
in my case:

DriverManager.setLoginTimeout(2); //A
System.out.println(DriverManager.getLoginTimeout());
Connection con = DriverManager.getConnection(url,"me", "pass"); //C

no matter what values set to line A (-1,0,1,,10),
it'll take 10-20 seconds to execute line C.

I still want to stop the execution of line c within 5 seconds.

Thanks
John


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



©2009 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.