How to set timeout

hi all,
i have a method that should be executed in a certain time...
void method(String param){
return result; // if result is not there after 2 minutes, throw an exception ??
how can i do that?
regards

If you look at URLConnection, it has facilities for doing thing
Or you could use my TimeOut class
http://forums.sun.com/thread.jspa?threadID=5315374

Similar Messages

  • How to set timeout during call oci api

    hi all :
    in my program i use OCIInitialize and OCIEnvInit to connect oracle 10g ,but sometime the db does not return ,whether ok or error , at the same time i use sqlplus to connect db ,it is the same .
    so i want to set timeout in my program , does oracle support set timeout in the such scene , if support ,how can i do ?
    thanks a lot
    Message was edited by:
    user549861

    print code :
    if(OCIInitialize(OCI_THREADED ,0, 0, 0, 0)!=OCI_SUCCESS)
         return -1;
         if(OCIEnvInit( (OCIEnv **) &(p_env), OCI_DEFAULT, 0, 0 )!=OCI_SUCCESS)
         return -1;
    if (OCIHandleAlloc ((dvoid *)p_env, (dvoid **)&p_srv,
    OCI_HTYPE_SERVER, 0, (dvoid **) 0)!=OCI_SUCCESS)
         return -1;
         if(OCIHandleAlloc(p_env, (dvoid **) & (p_err), OCI_HTYPE_ERROR, 0, 0)!=OCI_SUCCESS)
         return -1;
    if (OCIServerAttach (p_srv, p_err, (text *)strNodeName,
    strlen (strNodeName), OCI_DEFAULT)!=OCI_SUCCESS)
         return -1;
         if(OCIHandleAlloc(p_env, (dvoid **) & (p_svc), OCI_HTYPE_SVCCTX, 0, 0)!=OCI_SUCCESS)
         return -1;
         if (OCIHandleAlloc ((dvoid *)p_env, (dvoid **)&p_ses,
    OCI_HTYPE_SESSION, 0, (dvoid **) 0)!=OCI_SUCCESS)
         return -1;
         if (OCIAttrSet ((dvoid *)p_svc, OCI_HTYPE_SVCCTX,
    (dvoid *)p_srv, (ub4) 0, OCI_ATTR_SERVER, p_err)!=OCI_SUCCESS)
         return -1;
         if (OCIAttrSet ((dvoid *)p_ses, OCI_HTYPE_SESSION,
    (dvoid *)strUserName, (ub4)strlen(strUserName),
    OCI_ATTR_USERNAME, p_err)!=OCI_SUCCESS)
         return -1;
    if (OCIAttrSet ((dvoid *)p_ses, OCI_HTYPE_SESSION,
    (dvoid *)strPasswd, (ub4)strlen(strPasswd),
    OCI_ATTR_PASSWORD, p_err)!=OCI_SUCCESS)
         return -1;
    if (OCISessionBegin (p_svc, p_err, p_ses,
    OCI_CRED_RDBMS, OCI_DEFAULT)!=OCI_SUCCESS)
         return -1;
    if (OCIAttrSet ( (dvoid *)p_svc, OCI_HTYPE_SVCCTX,
    (dvoid *)p_ses, (ub4) 0, OCI_ATTR_SESSION, p_err)!=OCI_SUCCESS)
         return -1;
    how can i set timeout in the these code

  • How to set TimeOut period in Portal

    Hi,
    I am running a report in the portal which is taking more than 1 min to display the results. After this one min the page is getting timedout. Can any one please let me know how to administrate the timeout interval. I found this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b7/60b54066ea8531e10000000a1550b0/frameset.htm
    but where in the portalapp.xml should I set the parameter "com.sap.portal.page.PageTimeout".
    Thanks,
    Sudhir

    Hi Sudhir
    This link will help you:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b7/60b54066ea8531e10000000a1550b0/frameset.htm
    Maybe you could consider changing the page properties to increase the cache validity.
    Check the following thread for more details:
    iView Session Timeout
    Cheers.
    Please award points for helpful answers.

  • How to set timeout when BPEL Invokes EBS API in 10G

    I am invoking a EBS API through Oracle Applications Adapter in my BPEL, During the execution of my BPEL Process, if my EBS API call takes more than 10s, i want it to timeout. Can you please let me know how can i achieve it. I tried using the <property name="timeout">10</property> <property name="optSoapShortcut">false</property> in the partnerlink defintion, but it didnt help.

    Thanks Arik and vijay for your response,
    syncMaxWaitTime needs to be set at the domain level, then it would timeout all the services that are deployed on my environment. Property transaction-timeout and syncMaxWaitTime will not resolve the issue, because i need to achieve the timeout for a particular service only (Sorry, I should have mentioned in the problem statement that i need to implement the timeout for a specific service).
    I tried the PartnerLink timeout property along with optSoapShortcut but timeout is not happening.
    If you could provide me any other alternative solutions that would help me to timeout the call to EBS using a Oracle Applications Adapter in BPEL 10g Invoke activity.
    Wish you a belated Happy Christmas and advanced New Year wishes.
    Regards,
    Sivananda
    Edited by: 978071 on Dec 26, 2012 2:43 AM
    Edited by: 978071 on Dec 26, 2012 2:44 AM

  • TCP Client Server - how to set timeout and bandwidth option

    Hi Friends,
    I am writing a simple TCP based client-server app and I would like the connection to be dropped after a certain time of inactivity and also I would like to control the connection's bandwidth. I would appreciate if someone can throw some pointers as to how this can be done.
    I have tried this so far, for Timeout I am trying to do this:
    sock.setSoTimeout(10000);But I think this is not the right way as this will disconnect the server from all client connections I guess. I think the better way would be to write a timer or something for each connection but I don't know how...
    Any help?

    Micks80 wrote:
    Hi Friends,
    I am writing a simple TCP based client-server app and I would like the connection to be dropped after a certain time of inactivity and also I would like to control the connection's bandwidth. I would appreciate if someone can throw some pointers as to how this can be done.
    I have tried this so far, for Timeout I am trying to do this:
    sock.setSoTimeout(10000);But I think this is not the right way as this will disconnect the server from all client connections I guess.Wrong in a couple of ways.
    1) That doesn`t disconnect anything. It causes a read that reaches that time in blocking to be unblocked and an exception (java.net.SocketTimeoutException) is thrown. The Socket is still just fine and can be used (all other things being equal). At any rate you then decide what you want to do after a timeout. One possibility is to close the socket because to you that timeout means it is abandoned.
    2) setSoTimeout of ServerSocket applies to the accept* method. setSoTimeout of Socket applies to reads from that sockets input stream. Neither of those apply anything to all connections.
    I think the better way would be to write a timer or something for each connection No setSoTimeout is correct. You will also then need to actually attempt to read something for that timeout exception to ever be thrown.
    As far as the bandwidth question goes, you will need to define your goals better. Please do not just restate "control bandwidth" because that is not actually a very specific goal. Do you want to limnit the bandwidth used at one time (tricky) or do you want to limit the total bandwidth used. Either way requires some work but they are different things.

  • Can some one give me clear answer how to set timeouts on URLConnection ?

    I am amazed why Sun did not specify a simple method like setReadTimeout
    on URLConnection or provide a way to get refernce to the underlying socket objet. By default the timeout is infinite!
    I am using JDK 1.4 and these appraoches:
    -Dsun.net.client.defaultConnectTimeout=<value in milliseconds>
    -Dsun.net.client.defaultReadTimeout=<value in milliseconds>
    also don't work.
    I do not have access to Socket object. Please help.
    I am using URLConnection in my client application on HTTPS and doing heavy load form POST processing. I tried
    Sockets as well but they don't work. URLConnection works perfectly fine except for the timeouts nightmare.

    OK this might sound crazy but you may have been onto it right from the start. I was having the exact same (frustrating) problem with the URLConnection waiting forever on a dead server and no way to terminate it. I tried something like what you said in your first post:
    System.setProperty("sun.net.client.defaultReadTimeout", "10000");
    and it worked. I played around with the number and it it was apparent to the naked eye that it was working (if you can believe that...).
    Of course, I'm using JDK 1.4.1_01 by now, so this might be different now.
    ttfn.

  • How to set TimeOut in URL

    Hi everyone,
    " URL u = new URL(url);
    InputStream is = u.openStream();
    BufferedReader dis = new BufferedReader(new InputStreamReader(is)); "
    My problem is,
    1. if host is down,my program waits for dafult time to connect
    2. After connecting to server, there 's some problem to get response from Host.
    my program wait for response long time.
    I want to change these two timeout. Also, i 'm using jdk1.3.if it's 1.5 i can use setConnectTimeout method .
    If u have solution, please revert to me.
    Thanks
    JaiGanesh.R

    http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2004-01/3271.html

  • How to set HttpURLConnection timeout while reading a stream?

    I want it got time out if the connection if lose while i read a stream from URL
    try {
         int timeout = 700;
         HttpURLConnection connection = (HttpURLConnection) downloadURl.openConnection();
         connection.setConnectTimeout(timeout);
         connection.setRequestProperty("Range","bytes=" + downloaded + "-");
         connection.connect();
         if (connection.getResponseCode() / 100 != 2) {
              error();
         int contentLength = connection.getContentLength();
         if (contentLength < 1) {
              error();
         if (status == DOWNLOADING){
              if (size == -1) {
                   size = contentLength;
              file = new RandomAccessFile(saveTmpName+".tmp", "rw");
              file.seek(downloaded);
         byte buffer[];
         stream = connection.getInputStream();
    connection.setReadTimeout(timeout);
         while (status == DOWNLOADING) { 
              if (size - downloaded > MAX_BUFFER_SIZE) {
                   buffer = new byte[MAX_BUFFER_SIZE];
              } else {
                   buffer = new byte[(int)(size - downloaded)];
              int read = stream.read(buffer); // how to set timeout while it is reading stream
              if (read <= 0)
                   break;
              file.write(buffer, 0, read);
              downloaded += read;
         if (status == DOWNLOADING) {
              status = COMPLETE;
    } catch (SocketTimeoutException  e) {
         error();
    } catch (IllegalArgumentException e) {
         error();
    } catch (Exception e) {
         error();
    } finally {
         if (file != null) {
              try {
                   file.close();
              } catch (Exception e) {}
         if (stream != null) {
              try {
                   stream.close();
              } catch (Exception e) {}
    }I try to set "setReadTimeout()" but is still not through timeout Exception

    ejp wrote:
    Because, there's no FTP client command that allows to do such thing.Socket.setSoTimeout().I agree with you on this one but the OP is talking about the FTPClient API from Apache.
    To the OP,
    BTW, I have reread the Javadoc about the [*API*|http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html] : indeed, there's no setTimeout method, but there is a setDataTimeout method : +Sets the timeout in milliseconds to use when reading from the data connection+ .

  • How to set the keepalive timeout and nativepoll in application server 8.2

    Hi,
    I would like to know how to set "keepalive timeout" and "nativepoll" on application server 8.2.
    Thanks,

    These parameters were set in Application server 7 as per the following documentation:
    http://docs.sun.com/source/817-2180-10/pt_chap4.html
    However I am not able to find any documentation with regards to application server 8.2
    Please advice..
    Thanks

  • How to get remaining time for baton after setting timeOut property

    Hello,
    Is it possible to get the remaining time for baton after setting timeOut, or do I have to maintain a separate Timer for that?
    Been following this excellent tutorial here http://tv.adobe.com/watch/adc-presents/create-shared-forms-in-livecycle-collaboration-serv ice/

    Thanks Nigel, before reading your reply, I came up with something like this, but it seems extending the Baton class is not enough, as I would need my own BatonProperty as well that uses this extended Baton class...
    Also attempted to get some help here http://stackoverflow.com/questions/7116814/actionscript3-lccs-how-to-access-property-paren t-class-protected-var/7116882#7116882
    Could this be made into a feature request for Baton and BatonProperty, se we could easily get the remaining time please?   I guess I can wait for a future release.
    /custom as file /
    package com.mysite.BatonExtender
         import com.adobe.rtc.sharedModel.Baton;
         import flash.events.TimerEvent;
         public class BatonExtender extends Baton
              public function BatonExtender()
              super();
              _autoPutDownTimer.addEventListener(TimerEvent.TIMER,countDown);    
              trace("CURRENT TIMER:"+_autoPutDownTimer.currentCount);
              trace("BATONEXTENDER added");
              public function countDown(p_evt:TimerEvent):void {
                   trace("TRACING START countDown....");
                   if (_autoPutDownTimer.running) {
                        trace(_autoPutDownTimer.currentCount);
                        //sharedTimer.value = String(90 - _autoPutDownTimer.currentCount);
                   trace("TRACING END....");

  • How do set operation timeout in tomcat server?

    hi all
    suppose i have one endless loop program(jsp) that program run under tomcat server,
    so it's keep on runing in tomcat server.
    i want, after some time the server send error message like operation timeout.
    how do set operation timeout in tomcat server?
    if anybody know help me.
    my mail id [email protected]

    Well, the server.xml file has connection time outs, but that is for idle time, I think... I'm not sure what would happen in a loop... , especially if you are sending some data back to the client in each iteration. Generally you shouldn't be starting a loop that will really run forever. Maybe have some type of counter to break out if something hasn't occurred within x iterations, or create a separate thread that can sleep for x seconds and set a flag to break the loop after that time.

  • How to set Oracle Data Integrator Timeout paramter value as unlimited

    Hi
    Can any one help me how to set Oracle Data Integrator Timeout (ODI menu>User Paramter>Oracle Data Integrator Timeout > paramter value as unlimited.
    By default it is 30 and i want to change it as unlimited.
    I am connecting linux box through windows using citrix and opened ODI and start the scenario execution (my scenario execution in loop and it will execute continuesly) after execution starts I an logout from citrix (I am not closing ODI) and after some time like 50 min my odi execution is stoped due to timeout.
    my ODI execution should continue in my absence that to unlimited.
    Please help me it is urgent
    Regards,
    Phanikanth

    Thanks Bhabani
    Is it work for unlimited in linux box because I have given operator dispplay limit(0=no limit) as 1000000 and I am unable to see the execution session details on Operator>session list
    later i have changed to 10000 and click on ok and just refreshed and it is working fine
    If I give mensioned below it will not impact on ODI ?
    windows it is working but I have doubt on linux version
    Please help me
    Regards,
    Phanikanth

  • How to set Crystal Report  command timeout in runtime ?

    Hi, All !
    I have a report that is generating timeout error during execution command (Crystal Report command with SQL query). How can I set timeout  for the  command from application code ? I am using CR 12 and C#  (.NET framework 2.0)
    I have investigated CommandTableClass (CrystalDecisions.ReportAppServer.DataDefModel.CommandTableClass) but I didn't find timeout property or simething like that.
    Please help.
    Thank you in advance.
    Edited by: Bonowow on Feb 24, 2010 11:38 AM
    Edited by: Bonowow on Feb 24, 2010 11:42 AM

    I do not believe there is such an API. How long does it take before you get the timeout?
    Ludek

  • RMI - How to set a client timeout?

    Hey folks,
    please don't crucify me, but i googled for "rmi client timeout" and i only found confusing and / or really dated information.
    Could somebody enlighten me on how to set a timeout for an RMI-client?
    Even an RTFM would be fine, but which?

    Hi,
    thanks for your insistence.....:-)
    ejp wrote:
    1. Are you using rmic? UnicastRemoteObject? or some JBoss API?Ehm, for the client?
    The client's sourcecode for connecting to the Jboss-Server / my EJB-application is:
    Hashtable<String, String> props = new Hashtable<String, String>();
    props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
    props.put(Context.PROVIDER_URL,"jnp://" + "myhost");
    props.put(Context.SECURITY_PRINCIPAL, "myuser");
    props.put(Context.SECURITY_CREDENTIALS, "mypassword");
    Context ctx = new InitialContext(props);
    // get RMI stub
    ISendCommand sendCommand = (ISendCommand) ctx.lookup(myjndiname);
    String result = sendCommand.sendCommand(myArgs);So i think this corrensponds to "UnicastRemoteObject" from your enumeration?
    ejp wrote:
    2. How do you know JBoss terminates the connection?Because i have a timeout configured in my EJB-application, but in the example i try to get working, the client shall use its own timeout which is before the EJB-timeout.
    The EJB-timeout works, but not the client timeout.....(as described above)
    ejp wrote:
    3. What happens at the client? An exception? Nothing?"Nothing", i.e. the client terminates when the connection times out (from the JBoss / EJB-side!)
    ejp wrote:
    4. Are you ignoring any exceptions at the client?No.
    Shouldn't this client timeout be totally independent from any server / Jboss / whatever stuff?
    Any more ideas?

  • How to set transaction (or statement) timeout in PL/SQL program

    Hi to all.
    I need to set a timeout before executing a very long transaction so if it take longer than a specified value, it should be broken.
    Is there something like transaction timeout or statement timeout?
    Here is a brief pseudo code of what I'm trying to do:
    BEGIN
    set timeout = 1 hour
    perform some long operations
    END;
    Thanks a lot in advance. Any help will be appreciated!
    Best regards, Beroetz

    There is no transaction timeout period.
    One option would be to create a profile for the user that terminated that user's sessions if a particular statement or session used too much CPU/ IO/ some combination. This would probably require a dedicated user for this sort of job, but that's probably not too big a deal.
    If you will be doing a lot of small operations, you could also register for an alert, submit a background job that signals the alert in an hour, and look for the alert periodically in your code.
    Justin

Maybe you are looking for

  • Laptop Fan Noise

    Hi, whenever i turn on my laptop, there's this buzzing noise coming from the cpu fan. i sent it to a repair shop to clean the fan, but the problem still exists. i suspect it's more of a hardware issue than the fan, and if so, where can i get a replac

  • Copy from a set of attribute to a different set

    Hi All I've a requirement in which i've to copy data from a set of values (which has some attributes attached to it). Let's say if i have a group Hyperion i would like to copy that to another group SAP. I have set of attributes Hyperion and SAP. Is t

  • Xcelsius and SQL Server 2008 Reporting Services

    I am totally and utterly p1$$3d off and surely I cannot be the only person to be using a similar setup i.e. Xcelsius along with SQL Server 2008 Reporting Services. I have installed and tried to get working the XRS gateway and get connectivity to Repo

  • Udev problems still - 060-3 won't process my custom rules

    Following the problems with 060-1, I went back to 058-4 - everything was fine, as expected. When I saw 060-2 and then 060-3 in current, I figured I'd give it another shot. It looked fine initially i.e. it didn't break my network. However, none of my

  • Model for max 1966

    Does anybody have the model(extension .txt) for the Max 1966 or 1967?