Author |
Message
|
sai kumar adduri |
Posted: Wed Nov 06, 2013 4:28 am Post subject: Data Base Failover Sceneario |
|
|
Acolyte
Joined: 04 Apr 2013 Posts: 73
|
Hi,
I am trying out to connect to a secondary data base if the primary one fails .
So to do this I have used sql code function to know the code.
But this function is retuning a default value.
Hope the approach is correct , if not any ideas to do this |
|
Back to top |
|
 |
Vitor |
Posted: Wed Nov 06, 2013 5:49 am Post subject: Re: Data Base Failover Sceneario |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sai kumar adduri wrote: |
I am trying out to connect to a secondary data base if the primary one fails . |
This sounds suspicously like this recent post; working together?
sai kumar adduri wrote: |
But this function is retuning a default value. |
What value?
sai kumar adduri wrote: |
Hope the approach is correct , if not any ideas to do this |
It is, though as I indicated in the other post it's a bit odd in this modern world to implement this through code (ESQL). Given that there are patently 2 databases & the second is expected to be available & valid when the first is not (indicating separate hardware and replicated data) it's surprising that the last HA step has not been performed. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sai kumar adduri |
Posted: Wed Nov 06, 2013 7:19 am Post subject: |
|
|
Acolyte
Joined: 04 Apr 2013 Posts: 73
|
The default value is 00000 For sql state |
|
Back to top |
|
 |
Vitor |
Posted: Wed Nov 06, 2013 8:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sai kumar adduri wrote: |
The default value is 00000 For sql state |
And you're certain the underlying database is failed? And that your connection is not automatically being failed over to the 2nd database you're trying to use in the way I was surprised wasn't in use above? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sai kumar adduri |
Posted: Thu Nov 07, 2013 4:34 am Post subject: |
|
|
Acolyte
Joined: 04 Apr 2013 Posts: 73
|
I am using continue handler to handle the db failover .
But the problem is I need to un select the the THROW EXCEPTION ON DATABASE ERROR so that I can handle it using HANDLER.
And at the same time I should not specifiy the DSN name in the compute node properties .
How to achieve ,
UNselecting the THROW EXCEPTION ON DATABASE ERROR while not specifiying the DSN name in the compute node properties . |
|
Back to top |
|
 |
dogorsy |
Posted: Thu Nov 07, 2013 4:41 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
sai kumar adduri wrote: |
I am using continue handler to handle the db failover .
But the problem is I need to un select the the THROW EXCEPTION ON DATABASE ERROR so that I can handle it using HANDLER.
And at the same time I should not specifiy the DSN name in the compute node properties .
How to achieve ,
UNselecting the THROW EXCEPTION ON DATABASE ERROR while not specifiying the DSN name in the compute node properties . |
NO !, if you unselect the THROW EXCEPTION ON DATABASE ERROR, then that is what you get, no exception whatsoever. You want to throw the exception so you can then handle it.
What does the name 'EXCEPTION HANDLER' suggests ?... if you do not throw and exception, what are you going to handle ?!
Another suggestion is to read what the options are, before just selecting or not them.
You also need to understand the difference between CONTINUE and EXIT handlers. Do you really want to use a continue handler ?
And YOU NEED TO SPECIFY THE DSN name in the compute node properties.
Last edited by dogorsy on Thu Nov 07, 2013 4:52 am; edited 1 time in total |
|
Back to top |
|
 |
sai kumar adduri |
Posted: Thu Nov 07, 2013 4:51 am Post subject: |
|
|
Acolyte
Joined: 04 Apr 2013 Posts: 73
|
YES I have read what are they and started using it
Seems you dint get me correctly .
By unselectling it the system does not throw an error but so that I can through and catch it using HANDLER.
Diff B/W Continue and Exit Handler:
Continue Handler handles the exception and then shifts the control back to the step after the step which raiesd exception.
But Exit handler does not do it , it just handles the exception and propagates . |
|
Back to top |
|
 |
mgk |
Posted: Thu Nov 07, 2013 4:52 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Also worth pointing out that when using handler, the SQLCODE, SQLSTATE etc are only "filled in" with value when you are in the HANDLER block itself, as that's where there is an inflight exception. Once you leave the HANDLER block, these values are reset to the defaults...
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
dogorsy |
Posted: Thu Nov 07, 2013 4:53 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
sai kumar adduri wrote: |
YES I have read what are they and started using it
Seems you dint get me correctly .
By unselectling it the system does not throw an error but so that I can through and catch it using HANDLER.
Diff B/W Continue and Exit Handler:
Continue Handler handles the exception and then shifts the control back to the step after the step which raiesd exception.
But Exit handler does not do it , it just handles the exception and propagates . |
Yes, I did get what you are saying.
WHAT DOES EXCEPTION HANDLER suggest ?!
if and exception is not thrown, WHAT ARE YOU GOING TO HANDLE ? |
|
Back to top |
|
 |
sai kumar adduri |
Posted: Thu Nov 07, 2013 4:56 am Post subject: |
|
|
Acolyte
Joined: 04 Apr 2013 Posts: 73
|
if there is no exception then , then handler block does not exceute. |
|
Back to top |
|
 |
dogorsy |
Posted: Thu Nov 07, 2013 5:01 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
sai kumar adduri wrote: |
if there is no exception then , then handler block does not exceute. |
Why code a HANDLER then ?... you will never get a database exception !
If you do not understand that, then you seriously need to review your concepts |
|
Back to top |
|
 |
sai kumar adduri |
Posted: Thu Nov 07, 2013 5:08 am Post subject: |
|
|
Acolyte
Joined: 04 Apr 2013 Posts: 73
|
Let me tell u my approach.
I need to connect to a secondary db when my primary one fails .
I would determine this by using sql state.
Now once sql states returns an error code that I am looking for then I will through a user exception .
This will be caught by handler and here I will connect to the secondary db .
For doing this I need to uncheck the throw exception and I should not specify the dsn at the compute node because if I give the dsn of the primary db here and if it is down then it straight away throws an error . |
|
Back to top |
|
 |
dogorsy |
Posted: Thu Nov 07, 2013 5:20 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
sai kumar adduri wrote: |
Let me tell u my approach.
I need to connect to a secondary db when my primary one fails .
I would determine this by using sql state.
Now once sql states returns an error code that I am looking for then I will through a user exception .
This will be caught by handler and here I will connect to the secondary db .
For doing this I need to uncheck the throw exception and I should not specify the dsn at the compute node because if I give the dsn of the primary db here and if it is down then it straight away throws an error . |
You have not said anything new. I understood your approach.
If you are not going to take the advice you are given on board, why you bother asking ?
Go and get some education
Quote: |
For doing this I need to uncheck the throw exception |
WRONG !!!
Quote: |
I should not specify the dsn at the compute node |
WRONG !!! |
|
Back to top |
|
 |
|