Try block inside a try block - who is throwing StaleConnectionException?

int retry = 0;
try{ //MAIN TRY
//GET Datasource from context<---is this throwing?
boolean retry = false;
do {
     try {
          retry = false;
GET CONNECTION FROM DATASOURCE<--or shld this be?
     }catch(SQLException e) {
     //FIRST CATCH
     if (retryattempts++ < 3){
          retry = true;
} while (retry);
//DO something which requires try block
}catch(SQLException e)
{//Second catch
When I do this the StaleConnectionException is caught by the second catch... does this mean that the staleconnectionexception is thrown when getting datasource from initialcontext and not while getting connections?
Edited by: wannaBeACsGrad on Jan 10, 2008 9:09 AM

I am not sure what your are trying to do. Your code as posted is incomplete and could not possibly compile. The Try/catches do not seem to be nested.
More importantly, why in the world would you ever want to have a try inside a try? You can have a single try, then several different calls in loops or whatever that can potentially throw Exceptions and then have mulitple catch statements to handle them. For instance, you could have something like this:
try {
} catch (NullPointerException ne) {
   // handle null issues here
} catch (NumberFormatException nfe) {
   // handle number format issues here
} catch (Exception e) {
   // everything else falls here
}Keep in mind that you don't want to do any "Error Hiding". Make sure you handle each case appropriately.

Similar Messages

  • About the finally block of the try catch.

    I know that finally block contains the code that will be executed in any condition of the try catch.
    However, I think it is unneccessary, since the stack after the try catch stack will be executed any way.
    Any one can help?
    for example
    try{
    System.in.read();
    catch(Exception e){}
    finally
    { System.out.println("does this matter?");}and
    try{
    System.in.read();
    catch(Exception e){}
    System.out.println("does this matter?");

    However, I think it is unneccessary, since the stackafter the try catch
    stack will be executed any way.That does assume that you catch and handle the error
    appropriately.
    Of course this is valid as well, and demonstrates
    when you would WANT a finally clause.
    Connection con = null;
    Statement stmt = null;
    try{
    con  = Database.getConnection();
    stmt = con.createStatement("Select * from dual");
    // maybe something throws an exception here?
    finally{
    if (stmt != null){
    stmt.close();
    if (con != null){
    con.close();
    The finally block here might throw a null pointer exception itself use
    null!=stmt null!=stmt

  • Exception handling in static block

    How to handle and exception raised in static block, pls answer

    Yeah, you are right, but I was just quoting the example on how to use it.
    Now, come to your problem,
    1. Static blocks are executed first time, when a class is loaded, i.e. when first reference of class is made.
    2. So, handle the situation there.
    E.g.
    You have test class:
    public class Test {
         static{
              try{
                   String s = null;
                   File f = new File(s);
              }catch(Throwable ne)
                   System.out.println("Eror");
                   throw new RuntimeException(); // Or use Error depends on your implementation
         public static void abc(){
              System.out.println("Hello");
    Now,
    calling it from another class:
    public class Test1 {
         public static void main(String[] args) {
              try{
              Test.abc(); *// This is the first instance where class for Test will be load and hence the static block will be executed*
              }catch(Throwable th) // Or catch Error
                   th.printStackTrace(); // Do the handling
              System.out.println("Done");
    This is a standard practice. From static block, instead of throwing Error exception, use some of your inherited class from Error. (i.e. create a exception framework inside your application)
    Hope this explains my point.

  • Non-blocking SSLEngine example

    Since the example of using SSLEngine with non-blocking IO that comes with Java is quite limited, I have decided to release my own for anyone who wants to see how I solved the various problems that you must face. The example is designed to be a generic non-blocking server that supports SSL.
    This is only meant to be an example, as I wrote this mostly in order to learn how to use the SSLEngine, and therefore has certain limitations, and is not thouroughly tested.
    You can download the file at: http://members.aol.com/ben77/nio_server2.tar.gz
    Here is also the code for SecureIO, which is roughly analagous to the Java example's ChannelIOSecure:
    package nio_server2.internalio;
    import java.io.IOException;
    import java.nio.ByteBuffer;
    import java.nio.channels.*;
    import java.util.concurrent.*;
    import javax.net.ssl.*;
    import static javax.net.ssl.SSLEngineResult.HandshakeStatus.*;
    * Does IO based on a <code>SocketChannel</code> with all data encrypted using
    * SSL.
    * @author ben
    public class SecureIO extends InsecureIO {
          * SSLTasker is responsible for dealing with all long running tasks required
          * by the SSLEngine
          * @author ben
         private class SSLTasker implements Runnable {
               * @inheritDoc
              public void run() {
                   Runnable r;
                   while ((r = engine.getDelegatedTask()) != null) {
                        r.run();
                   if (inNet.position() > 0) {
                        regnow(); // we may already have read what is needed
                   try {
                        System.out.println(":" + engine.getHandshakeStatus());
                        switch (engine.getHandshakeStatus()) {
                             case NOT_HANDSHAKING:
                                  break;
                             case FINISHED:
                                  System.err.println("Detected FINISHED in tasker");
                                  Thread.dumpStack();
                                  break;
                             case NEED_TASK:
                                  System.err.println("Detected NEED_TASK in tasker");
                                  assert false;
                                  break;
                             case NEED_WRAP:
                                  rereg(SelectionKey.OP_WRITE);
                                  break;
                             case NEED_UNWRAP:
                                  rereg(SelectionKey.OP_READ);
                                  break;
                   } catch (IOException e) {
                        e.printStackTrace();
                        try {
                             shutdown();
                        } catch (IOException ex) {
                             ex.printStackTrace();
                   hsStatus = engine.getHandshakeStatus();
                   isTasking = false;
         private SSLEngine engine;
         private ByteBuffer inNet; // always cleared btwn calls
         private ByteBuffer outNet; // when hasRemaining, has data to write.
         private static final ByteBuffer BLANK = ByteBuffer.allocate(0);
         private boolean initialHandshakeDone = false;
         private volatile boolean isTasking = false;
         private boolean handshaking = true;
         private SSLEngineResult.HandshakeStatus hsStatus = NEED_UNWRAP;
         private boolean shutdownStarted;
         private static Executor executor = getDefaultExecutor();
         private SSLTasker tasker = new SSLTasker();
         private ByteBuffer temp;
          * @return the default <code>Executor</code>
         public static Executor getDefaultExecutor() {
              return new ThreadPoolExecutor(3, Integer.MAX_VALUE, 60L,
                        TimeUnit.SECONDS, new SynchronousQueue<Runnable>(),
                        new DaemonThreadFactory());
         private static class DaemonThreadFactory implements ThreadFactory {
              private static ThreadFactory defaultFactory = Executors
                        .defaultThreadFactory();
               * Creates a thread using the default factory, but sets it to be daemon
               * before returning it
               * @param r
               *            the runnable to run
               * @return the new thread
              public Thread newThread(Runnable r) {
                   Thread t = defaultFactory.newThread(r);
                   t.setDaemon(true);
                   return t;
          * @return the executor currently being used for all long-running tasks
         public static Executor getExecutor() {
              return executor;
          * Changes the executor being used for all long-running tasks. Currently
          * running tasks will still use the old executor
          * @param executor
          *            the new Executor to use
         public static void setExecutor(Executor executor) {
              SecureIO.executor = executor;
          * Creates a new <code>SecureIO</code>
          * @param channel
          *            the channel to do IO on.
          * @param sslCtx
          *            the <code>SSLContext</code> to use
         public SecureIO(SocketChannel channel, SSLContext sslCtx) {
              super(channel);
              engine = sslCtx.createSSLEngine();
              engine.setUseClientMode(false);
              int size = engine.getSession().getPacketBufferSize();
              inNet = ByteBuffer.allocate(size);
              outNet = ByteBuffer.allocate(size);
              outNet.limit(0);
              temp = ByteBuffer.allocate(engine.getSession()
                        .getApplicationBufferSize());
         private void doTasks() throws IOException {
              rereg(0); // don't do anything until the task is done.
              isTasking = true;
              SecureIO.executor.execute(tasker);
          * Does all handshaking required by SSL.
          * @param dst
          *            the destination from an application data read
          * @return true if all needed SSL handshaking is currently complete.
          * @throws IOException
          *             if there are errors in handshaking.
         @Override
         public boolean doHandshake(ByteBuffer dst) throws IOException {
              if (!handshaking) {
                   return true;
              if (dst.remaining() < minBufferSize()) {
                   throw new IllegalArgumentException("Buffer has only "
                             + dst.remaining() + " left + minBufferSize is "
                             + minBufferSize());
              if (outNet.hasRemaining()) {
                   if (!flush()) {
                        return false;
                   switch (hsStatus) {
                        case FINISHED:
                             handshaking = false;
                             initialHandshakeDone = true;
                             rereg(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
                             return true;
                        case NEED_UNWRAP:
                             rereg(SelectionKey.OP_READ);
                             break;
                        case NEED_TASK:
                             doTasks();
                             return false;
                        case NOT_HANDSHAKING:
                             throw new RuntimeException(
                                       "NOT_HANDSHAKING encountered when handshaking");
              SSLEngineResult res;
              System.out.println(hsStatus + "1" + handshaking);
              switch (hsStatus) {
                   case NEED_UNWRAP:
                        int i;
                        do {
                             rereg(SelectionKey.OP_READ);
                             i = super.read(inNet);
                             if (i < 0) {
                                  engine.closeInbound();
                                  handshaking = false;
                                  shutdown();
                                  return true;
                             if (i == 0 && inNet.position() == 0) {
                                  return false;
                             inloop: do {
                                  inNet.flip();
                                  temp.clear();
                                  res = engine.unwrap(inNet, temp);
                                  inNet.compact();
                                  temp.flip();
                                  if (temp.hasRemaining()) {
                                       dst.put(temp);
                                  switch (res.getStatus()) {
                                       case OK:
                                            hsStatus = res.getHandshakeStatus();
                                            if (hsStatus == NEED_TASK) {
                                                 doTasks();
                                            // if (hsStatus == FINISHED) {
                                            // // if (!initialHandshakeDone) {
                                            // // throw new RuntimeException(hsStatus
                                            // // + " encountered when handshaking");
                                            // initialHandshakeDone = true;
                                            // handshaking=false;
                                            // key.interestOps(SelectionKey.OP_READ
                                            // | SelectionKey.OP_WRITE);
                                            // TODO check others?
                                            break;
                                       case BUFFER_UNDERFLOW:
                                            break inloop;
                                       case BUFFER_OVERFLOW:
                                       case CLOSED:
                                            throw new RuntimeException(res.getStatus()
                                                      + " encountered when handshaking");
                             } while (hsStatus == NEED_UNWRAP
                                       && dst.remaining() >= minBufferSize());
                        } while (hsStatus == NEED_UNWRAP
                                  && dst.remaining() >= minBufferSize());
                        if (inNet.position() > 0) {
                             System.err.println(inNet);
                        if (hsStatus != NEED_WRAP) {
                             break;
                        } // else fall through
                        rereg(SelectionKey.OP_WRITE);
                   case NEED_WRAP:
                        do {
                             outNet.clear();
                             res = engine.wrap(BLANK, outNet);
                             switch (res.getStatus()) {
                                  case OK:
                                       outNet.flip();
                                       hsStatus = res.getHandshakeStatus();
                                       if (hsStatus == NEED_TASK) {
                                            doTasks();
                                            return false;
                                       // TODO check others?
                                       break;
                                  case BUFFER_OVERFLOW:
                                       outNet.limit(0);
                                       int size = engine.getSession()
                                                 .getPacketBufferSize();
                                       if (outNet.capacity() < size) {
                                            outNet = ByteBuffer.allocate(size);
                                       } else { // shouldn't happen
                                            throw new RuntimeException(res.getStatus()
                                                      + " encountered when handshaking");
                                  case BUFFER_UNDERFLOW: // engine shouldn't care
                                  case CLOSED:
                                       throw new RuntimeException(res.getStatus()
                                                 + " encountered when handshaking");
                        } while (flush() && hsStatus == NEED_WRAP);
                        break;
                   case NEED_TASK:
                        doTasks();
                        return false;
                   case FINISHED:
                        break; // checked below
                   case NOT_HANDSHAKING:
                        System.err.println(hsStatus + " encountered when handshaking");
                        handshaking = false;
                        initialHandshakeDone = true;
                        rereg(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
              if (hsStatus == FINISHED) {
                   // if (!initialHandshakeDone) {
                   // throw new RuntimeException(hsStatus
                   // + " encountered when handshaking");
                   initialHandshakeDone = true;
                   handshaking = false;
                   rereg(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
              System.out.println(hsStatus + "2" + handshaking);
              return !handshaking;
          * Attempts to flush all buffered data to the channel.
          * @return true if all buffered data has been written.
          * @throws IOException
          *             if there are errors writing the data
         @Override
         public boolean flush() throws IOException {
              if (!outNet.hasRemaining()) {
                   return true;
              super.write(outNet);
              return !outNet.hasRemaining();
          * @return the largest amount of application data that could be read from
          *         the channel at once.
         @Override
         public int minBufferSize() {
              return engine.getSession().getApplicationBufferSize();
          * Begins or proceeds with sending an SSL shutdown message to the client.
          * @return true if all needed IO is complete
          * @throws IOException
          *             if there are errors sending the message.
         @Override
         public boolean shutdown() throws IOException {
              if (!shutdownStarted) {
                   shutdownStarted = true;
                   engine.closeOutbound();
              if (outNet.hasRemaining() && !flush()) {
                   return false;
              SSLEngineResult result;
              do {
                   outNet.clear();
                   result = engine.wrap(BLANK, outNet);
                   if (result.getStatus() != SSLEngineResult.Status.CLOSED) {
                        throw new IOException("Unexpected result in shutdown:"
                                  + result.getStatus());
                   outNet.flip();
                   if (outNet.hasRemaining() && !flush()) {
                        return false;
              } while (result.getHandshakeStatus() == NEED_WRAP);
              return !outNet.hasRemaining();
          * Reads all possible data into the <code>ByteBuffer</code>.
          * @param dst
          *            the buffer to read into.
          * @return the number of bytes read, or -1 if the channel or
          *         <code>SSLEngine</code> is closed
          * @throws IllegalStateException
          *             if the initial handshake isn't complete *
          * @throws IOException
          *             if there are errors.
          * @throws IllegalStateException
          *             if the initial handshake isn't complete
          * @throws IllegalArgumentException
          *             if the remaining space in dst is less than
          *             {@link SecureIO#minBufferSize()}
         @Override
         public int read(ByteBuffer dst) throws IOException {
              if (!initialHandshakeDone) {
                   throw new IllegalStateException("Initial handshake incomplete");
              if (dst.remaining() < minBufferSize()) {
                   throw new IllegalArgumentException("Buffer has only "
                             + dst.remaining() + " left + minBufferSize is "
                             + minBufferSize());
              int sPos = dst.position();
              int i;
              while ((i = super.read(inNet)) != 0
                        && dst.remaining() >= minBufferSize()) {
                   if (i < 0) {
                        engine.closeInbound();
                        shutdown();
                        return -1;
                   do {
                        inNet.flip();
                        temp.clear();
                        SSLEngineResult result = engine.unwrap(inNet, temp);
                        inNet.compact();
                        temp.flip();
                        if (temp.hasRemaining()) {
                             dst.put(temp);
                        switch (result.getStatus()) {
                             case BUFFER_UNDERFLOW:
                                  continue;
                             case BUFFER_OVERFLOW:
                                  throw new Error();
                             case CLOSED:
                                  return -1;
                             // throw new IOException("SSLEngine closed");
                             case OK:
                                  checkHandshake();
                                  break;
                   } while (inNet.position() > 0);
              return dst.position() - sPos;
          * Encrypts data and writes it to the channel.
          * @param src
          *            the data to write
          * @return the number of bytes written
          * @throws IOException
          *             if there are errors.
          * @throws IllegalStateException
          *             if the initial handshake isn't complete
         @Override
         public int write(ByteBuffer src) throws IOException {
              if (!initialHandshakeDone) {
                   throw new IllegalStateException("Initial handshake incomplete");
              if (!flush()) {
                   return 0;
              int written = 0;
              outer: while (src.hasRemaining()) {
                   outNet.clear(); // we flushed it
                   SSLEngineResult result = engine.wrap(src, outNet);
                   outNet.flip();
                   switch (result.getStatus()) {
                        case BUFFER_UNDERFLOW:
                             break outer; // not enough left to send (prob won't
                        // happen - padding)
                        case BUFFER_OVERFLOW:
                             if (!flush()) {
                                  break outer; // can't remake while still have
                                  // stuff to write
                             int size = engine.getSession().getPacketBufferSize();
                             if (outNet.capacity() < size) {
                                  outNet = ByteBuffer.allocate(size);
                             } else { // shouldn't happen
                                  throw new RuntimeException(hsStatus
                                            + " encountered when handshaking");
                             continue; // try again
                        case CLOSED:
                             throw new IOException("SSLEngine closed");
                        case OK:
                             checkHandshake();
                             break;
                   if (!flush()) {
                        break;
              return written;
         private boolean hasRemaining(ByteBuffer[] src) {
              for (ByteBuffer b : src) {
                   if (b.hasRemaining()) {
                        return true;
              return false;
          * Encrypts data and writes it to the channel.
          * @param src
          *            the data to write
          * @return the number of bytes written
          * @throws IOException
          *             if there are errors.
          * @throws IllegalStateException
          *             if the initial handshake isn't complete
         @Override
         public long write(ByteBuffer[] src) throws IOException {
              if (!initialHandshakeDone) {
                   throw new IllegalStateException("Initial handshake incomplete");
              if (!flush()) {
                   return 0;
              int written = 0;
              outer: while (hasRemaining(src)) {
                   outNet.clear(); // we flushed it
                   SSLEngineResult result = engine.wrap(src, outNet);
                   outNet.flip();
                   switch (result.getStatus()) {
                        case BUFFER_UNDERFLOW:
                             break outer; // not enough left to send (prob won't
                        // happen - padding)
                        case BUFFER_OVERFLOW:
                             if (!flush()) {
                                  break outer; // can't remake while still have
                                  // stuff to write
                             int size = engine.getSession().getPacketBufferSize();
                             if (outNet.capacity() < size) {
                                  outNet = ByteBuffer.allocate(size);
                             } else { // shouldn't happen
                                  throw new RuntimeException(hsStatus
                                            + " encountered when handshaking");
                             continue; // try again
                        case CLOSED:
                             throw new IOException("SSLEngine closed");
                        case OK:
                             checkHandshake();
                             break;
                   if (!flush()) {
                        break;
              return written;
         private void checkHandshake() throws IOException {
              // Thread.dumpStack();
              // System.out.println(engine.getHandshakeStatus());
              outer: while (true) {
                   switch (engine.getHandshakeStatus()) {
                        case NOT_HANDSHAKING:
                             initialHandshakeDone = true;
                             handshaking = false;
                             rereg(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
                             return;
                        case FINISHED:
                             // this shouldn't happen, I don't think. If it does, say
                             // where.
                             System.err.println("Detected FINISHED in checkHandshake");
                             Thread.dumpStack();
                             break outer;
                        case NEED_TASK:
                             if (isTasking) {
                                  while (isTasking) { // TODO: deal with by reg?
                                       Thread.yield();
                                       try {
                                            Thread.sleep(1);
                                       } catch (InterruptedException ex) {
                                            // TODO Auto-generated catch block
                                            ex.printStackTrace();
                                  break;
                             doTasks();
                             break;
                        case NEED_WRAP:
                             rereg(SelectionKey.OP_WRITE);
                             break outer;
                        case NEED_UNWRAP:
                             rereg(SelectionKey.OP_READ);
                             break outer;
              handshaking = true;
              hsStatus = engine.getHandshakeStatus();
          * @return true if the channel is open and no shutdown message has been
          *         recieved.
         @Override
         public boolean isOpen() {
              return super.isOpen() && !engine.isInboundDone();
    }

    That's the reason for checkHandshake(), it is called on every read and write and detects a new handshake and configures the setup properly. As far as the server requesting a new handshake, I did not put that in. It would be simple enough though, you would just need to call SSLEngine.beginHandshake() + then call checkHandshake().
    Also, my echo server example had a bug, I forgot to call bu.flip() before queueWrite(), so I fixed that, as well as adding an onConnect method that is called when a connection has been established. The new version should be up at the origional address shortly.

  • Blocking a nuisance call

    I keep getting a call from someone and their ID shows up as 4231. Clearly this isn't a real number as when I try to redial it I get a message telling me it wants a 10 digit number. I've called VW and they cannot help me telling me they cannot track who the real caller is. Clearly it's someone who is clever enough to block who they really are. When I answer the call no-one ever answers, but they still call me. How can I track who they really are or how can I block this call when I don't have their real number?
    Thanks
    John

    Lionheart, receiving unwanted calls is very annoying especially when you can't locate a way to stop them. Although we can't control who calls and text you, we do offer our customers some options for blocking. We have our usage control feature that is great for blocking unwanted calls and text. Verizon Wireless’ Usage Controls $4.99 per month for each wireless number enrolled. 
    With the blocking feature,  you can block Up to 20 ten-digit numbers, Private calls, Restricted calls, and Unavailable calls which are not counted towards the 20 number block list because its a stand alone option. YOu can also block 800 and 900 numbers. Also, calls to 411, #411, *411 and 1-411 can now be blocked.
    Although, trusted Numbers and short numbers, such as 911, 611, and #ROAD, cannot be blocked, if you are able to locate a phone number for this company or they start to call you private or restricted I think this will be a good option.
    To register and/or manage Usage Controls, please sign in to “My Verizon” using your Account Owner ID and password and click on “More Actions” link located near the bottom left of your “My Verizon” home page. Next, click on “Set Usage Controls” link, which is located underneath “Safety and Security” in the “I Want To” section in the middle of the page. 
     

  • OutOfMemory Exceptions on Servlets, Try-Catch unable to help

    Hi, I'm playing with Java servlets right now and I seem to be getting some OutOfMemory errors. The weird thing is that even though I had identify the souce of error and tried to enclose it with a try-catch, the exception still occurs. Why is that so?

    OutOfMemoryError is actually a java.lang.Error, not a RuntimeException. So if you use a try/catch like this
    try {
      // stuff
    } catch (Exception e) {..}Errors will fall through, since Error is not a subtype of Exception. (Check the API.)
    You can catch it by catching Error or Throwable, like this:
    try {
      // stuff
    } catch (Error e) { //  this is rarely a good idea
    }But you normally wouldn't want to do this. When there's no memory left, there's not a whole lot you can do about it, and most of the code you might want to put inside the catch block will merely throw another OutOfMemoryError.
    As voronetskyy said, you're either creating too many (or too large) objects (typically in an endless loop), or you have specified too little memory for your application.

  • Handling multiple exceptions with a single catch block

    In the following code:
    try{
    catch (NumberFormatException a) {
    catch (UserDefinedException b) {
    The code for both catch blocks are identical. Is there no way I can combine these into one block?
    For example, could I not do:
    catch ( (NumberFormatException a) || (UserDefinedException b) ){
    or anything similar?
    I did think of:
    try{
    try{
    catch (NumberFormatException a) {
    throw new UserDefinedException("");
    catch (UserDefinedException b){
    but this just seems to be a waste of code. Any ideas?

    I would use the fundamental way to combine identical sections of code--put the code in a new method:
        try {
        catch (NumberFormatException a) {
          myExceptionHandlingMethod(a);
        catch (UserDefinedException b) {
          myExceptionHandlingMethod(b);
      private void myExceptionHandlingMethod(Throwable t) {
      }

  • Error with PL/SQL block

    Hi
    If I run PL/SQL block
    DECLARE
    CURSOR C1 is SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T where CLM_CASE_NO=XXXX;
    BEGIN
    FOR X in C1 loop
    INSERT INTO POSTL_ADDRS_ARCHIVE P (SELECT A.* FROM CLAIM_OBJECT.POSTL_ADDRS A, CLAIM_OBJECT.CLM_INVLVD_PRTY_T C WHERE
    C.CLNT_NO = A.CLNT_NO AND C.CURR_ROW_IND='A' AND C.CLM_CASE_NO =X.CLM_CASE_NO );
    end loop;
    end;
    there is no error with the above block
    If I remove where clause in cursor and run block
    DECLARE
    CURSOR C1 is SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T;
    BEGIN
    FOR X in C1 loop
    INSERT INTO POSTL_ADDRS_ARCHIVE P (SELECT A.* FROM CLAIM_OBJECT.POSTL_ADDRS A, CLAIM_OBJECT.CLM_INVLVD_PRTY_T C WHERE
    C.CLNT_NO = A.CLNT_NO AND C.CURR_ROW_IND='A' AND C.CLM_CASE_NO =X.CLM_CASE_NO );
    end loop;
    end;
    ERROR at line 1:
    ORA-01013: user requested cancel of current operation
    ORA-06512: at line 12
    I searched for ORA-06512
    Cause:
         This error message indicates the line number in the PLSQL code that the error resulted.
    SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T has over 800,672 records.
    SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T where CLM_CASE_NO=XXXX; has 2 records.
    I am not not understanding why block 2 is throwing error (with no where clause in cursor)
    Any help will be greatly appreciated
    Thanks in advance

    As the error message indicates clearly the process was cancelled as you pressed CTRL+C. And yes you can’t see any data you insert in one session from other session until it gets committed. And as others have mentioned row by row operation is very expensive think about revising your approach.
    Instead of having a cursor why don’t you join it directly in you select in the insert statement and try?
    Thanks,
    Karthick.
    Message was edited by:
    karthick_arp

  • Return in finally block hides exception in catch block

    Hi,
    if the line marked with "!!!" is commented out, the re-thrown exception is not seen by the caller (because of the return in the finally block). If the line is commented in, it works as I would expect. Is this is bug or a feature? I assume the return removes the call to troubleMaker() from the call stack - including the associated exception...
    Christian Treber
    [email protected]
    public class ExceptionDemo extends TestCase
    public void testException()
    String lResult = "[not set]";
    try
    lResult = troubleMaker();
    System.out.println("No exception from troubleMaker()");
    } catch(Exception e)
    System.out.println("Caught an exception from troubleMaker(): " + e);
    System.out.println("Result: " + lResult);
    public String troubleMaker()
    boolean lErrorP = false;
    try
    if(6 > 5)
    throw new RuntimeException("Initial exception");
    return "normal";
    } catch (RuntimeException e)
    System.out.println("Caught runtime exception " + e);
    lErrorP = true;
    throw new RuntimeException("Exception within catch");
    } finally
    System.out.println("Finally! Error: " + lErrorP);
    if(!lErrorP)
    return "finally";

    This is specified in the Java Language Specification, section 14.19.2 .
    -- quote
    If execution of the try block completes abruptly because of a throw of a value V, then there is a choice:
    * If the run-time type of V is assignable to the parameter of any catch clause of the try statement, then the first (leftmost) such catch clause is selected. The value V is assigned to the parameter of the selected catch clause, and the Block of that catch clause is executed. Then there is a choice:
    o If the catch block completes normally, then the finally block is executed. Then there is a choice:
    + If the finally block completes abruptly for any reason, then the try statement completes abruptly for the same reason.
    -- end quote
    "completing abruptly" (in this instance) means a throw or a return, as specified in section 14.1
    Ok? It's not a bug, it's the defined behaviour of the language. And when you think about it, this behaviour gives you the option to do what you want in your finally block.

  • Implementing Exception Handling Application Block in custom web parts, event receivers

    hi,
      I am currently implementing try {} catch(Exception expp) { throw expp;} to handle exceptions in my intranet appln.
    I have several custom web parts, event receivers, few console applciations as timer jobs etc. If i want to implement a  robust exception handling what should be  the approach. by searching, i saw, ms patterns n practices provides the
    appln blocks.
    But I think[ pls correct me if i am wrong ] those  appln blocks are meant for asp.net applns ONLY.
    if not, anyone has implemented those appln blocks in SP development? if yes, can anyone provide one sample /  link to implement Exception Handling in SP.
    help is appreciated! 

    Hi,
    Here are some articles for your reference:
    Handling Error Centrally in a SharePoint Application
    http://www.codeproject.com/Articles/26236/Handling-Error-Centrally-in-a-SharePoint-Applicati
    Using Microsoft Enterprise Library Application Block in SharePoint
    http://www.codeproject.com/Articles/21389/Using-Microsoft-Enterprise-Library-Application-Blo
    Exception Handling in SharePoint
    http://spmatt.wordpress.com/2012/02/01/exception-handling-in-sharepoint/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Error, while runing anonymous block

    Hi All,
    I am running following anonymous block and that throwing following errors. Failed to understand why ?
    ===
    SQL> set serveroutput on size 100000
    SQL> declare
    v_paswd  varchar2(30) ;
    begin
      2    3    4  for i in ( select distinct owner from dba_db_links) loop
      5  select password into v_paswd from dba_users where username = i.owner;
      6  dbms_output.put_line('connect / ' ) ;
      7  dbms_output.put_line ( ' alter user '||i.owner||' identified by a; ') ;
      8  dbms_output.put_line('connect '||i.owner||'/a' ) ;
      9  dbms_output.put_line(' alter user '||i.owner||' identified by values '''||v_paswd||''' ;' );
    10   for ii in ( select db_link from dba_Db_links where owner=i.owner ) loop
    11       dbms_output.put_line(' drop database link '||ii.db_link||' ; ');
    12     end loop;
    13   end loop;
    14   end;
    15  /
    declare
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 5
    ++++
    OWNER                          DB_LINK
    PUBLIC                         MSSQL.US.DB.COM
    STS                            CORE.US.DB.COM
    STS                            CREAM.US.DB.COM
    STS                            CREAM_NYSTSU.US.DB.COM
    STS                            DBI_FIDM.US.DB.COM
    STS                            DBI_MBS.US.DB.COM
    STS                            DBMTG.US.DB.COM
    STS                            DBMTG_DEV.US.DB.COM
    STS                            DBMTG_NEW.US.DB.COM
    STS                            DBMTG_UAT.US.DB.COM
    STS                            DONOTUSE_PROD.US.DB.COM
    STS                            DTE.US.DB.COM
    STS                            FICS_PROD.US.DB.COM
    SQL>  select distinct owner from dba_db_links ;
    OWNER
    PUBLIC
    STS_RO
    SMS
    CREAM
    CORE
    STS
    ====hare krishna

    Modify your code like this and try
    declare
      v_paswd  varchar2(30) ;
    begin
      for i in ( select password,
                        username
                   from dba_users
                  where username in (select distinct owner from dba_db_links)) loop
        dbms_output.put_line('connect / ' ) ;
        dbms_output.put_line ( ' alter user '||i.username||' identified by a; ') ;
        dbms_output.put_line('connect '||i.username||'/a' ) ;
        dbms_output.put_line(' alter user '||i.username||' identified by values '''||i.password||''' ;' );
        for ii in ( select db_link from dba_Db_links where owner=i.username) loop
           dbms_output.put_line(' drop database link '||ii.db_link||' ; ');
        end loop;
      end loop;
    end;

  • Try catch throw with doScript()

    Hi,
    Today is my InDesign Scripting Bug Day... grrr. In the following example, the Error e in line 6 is undefined. When I run the Function run() without doScript() it works as expected. It looks like, throw isn't implemented correct with doScript(). At least the throw statement works but does not carry the Error. This is not working in CS4 and CS5.5.
    try {
        app.doScript(run, ScriptLanguage.JAVASCRIPT , undefined, UndoModes.ENTIRE_SCRIPT, "PX_TEMP");
    //~    run()
    catch (e) {
      $.writeln("Caught: " + e.message);
    function run() {
            throw new Error("Im an error");

    The try...catch structure is very specific in that it creates (and destroys) at runtime its own variable scope to target the Error object. I don't know exactly how app.doScript is implemented but there are some reason to believe that the error thrown in the inner script cannot go back to the outer try...catch scope. The error object is probably lost when the inner script returns.
    An ugly solution is to catch the error within app.doScript, to backup the object in a safe place and to re-throw the same error in the outer try block:
    function run(){ throw new Error("Im an error"); }
    run.error = null;
    try {
        app.doScript('try{ run(); } catch(eInner){ run.error=eInner; }');
        if( run.error ){ throw run.error; }
        // you can throw other errors here
    catch(e)
        alert( "Caught: " + e );
    But I hope you have a really good excuse to do such a thing!
    @+
    Marc

  • How finally block can be evaded??

    i want to write a finally block but don't want to execute it.
    plz dont suggest application.exit(). i want to continue with my program
    plz answer

    I want to write a finally block but don't want to execute it.You have several options.
    - don't enter into the try block associated with your finally block
    - embed the content of the finally block with "if (false) { ... }" - well the finally block is executed, but the contents of the if block is not
    - throw an exception right at the start of the finally block - almost the same as above
    - investigate if this is of any use for your objective: "An application should not normally try to catch ThreadDeath unless it must do some extraordinary cleanup operation (note that the throwing of ThreadDeath causes finally clauses of try statements to be executed before the thread officially dies). If a catch clause catches a ThreadDeath object, it is important to rethrow the object so that the thread actually dies." from: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#stop()

  • Difference: "throws xyException" and "try/catch"

    Is there a difference? Which is it? Would thus be the same for a function:
    "functionName throws xyException"
    or
    "functionName{
    try{
    catch(xyException){
    }

    functionName throws xyException
    Calling code must call this function in a try and catch block or code won't compile.
    functionName{
    try{
    catch(xyException){
    Calling code does not have to put the call to this function in a try and catch block.
    public void methodName() throws xEcxeption{
              try{
                        // something
              }catch(Exception e){
                        // try to clean up something
                        // trhow xEcxeption to calling code so that code can do something as well.
                        // like trying an alternative, informing the user or stop executing
    }

  • Blocking session query

    What's the query to find this kind of info, blocking session? eg
    535 session blocking one other session 1962, they are both coming from SP:

    This query will tell you who's blocking who...
    select (select username
              from v$session
             where sid = a.sid) blocker
         , a.sid
         , ' is blocking '
         , (select username
              from v$session
             where sid = b.sid) blockee
         , b.sid
      from v$lock a
         , v$lock b
    where a.block = 1
       and b.request 0
       and a.id1 = b.id1
       and a.id2 = b.id2query by Tom Kyte

Maybe you are looking for

  • How to configure the flat file in 11G

    Hi, I am using OWB 11.1.0.6.0. For a map in OWB 10G having a source a flat file. I used to go and right click on the map--> then click Configure-->then Under "Source Data File" type the file name-->then give the location details and the exact flat fi

  • BEA Weblogic AS 9.2 close pool connections - messages BEA-001128 in logs

    Hello, We have problems with BEA Weblogic AS 9.2 SP3. From time to time servers stop responding and seem to be stuck. In logs there are plenty of messages like this: ####<Jun 16, 2009 3:08:49 PM CEST> <Info> <JDBC> <SRV-WLS3> <PRD-J> <[ACTIVE] Execut

  • Text to Graphic

    Does iWeb 2.0 also have this weird bug where iWeb randomly transforms text into graphics and then posts it? It is very annoying and I would happily pay for the upgrade to get rid of the bug (since Apple apparently never bothered to fix it for free).

  • How to initiate two simultaneous tasks? First waits on second.

    I'm looking for guidance. I feel my problem is likely very common. It involves performing two tasks simultaneously. I have a digitizer (pxi5105) and a waveform generator (pxi5412). I need to generate a pulse and record the response simultaneously. My

  • Mini says start up disk full

    I have had my mini for about a year now. I do like it but here recently it has been causing issues. I installed the leopard operating system when it came out. I do like it but i really dont need it. I cant download bigger files anymore. On startup an