Author |
Message
|
Girirsh K N |
Posted: Mon May 23, 2016 9:49 pm Post subject: Checking the Database connectivity |
|
|
Newbie
Joined: 26 Apr 2016 Posts: 6
|
Hi,
My Scenario : I'm trying to insert the data in to the database table, but before performing the database insertion i want to check whether the database is active or not in the esql file. If the database is active then will perform the insertion else throw the user defined exception "Database is inactive".
Is there any possible way to do this ,if so kindly share your knowledge.
Thanks in advance! |
|
Back to top |
|
 |
maurito |
Posted: Mon May 23, 2016 10:17 pm Post subject: Re: Checking the Database connectivity |
|
|
Partisan
Joined: 17 Apr 2014 Posts: 358
|
Girirsh K N wrote: |
Hi,
My Scenario : I'm trying to insert the data in to the database table, but before performing the database insertion i want to check whether the database is active or not in the esql file. If the database is active then will perform the insertion else throw the user defined exception "Database is inactive".
Is there any possible way to do this ,if so kindly share your knowledge.
Thanks in advance! |
Why? why not just try the insert, catch the failure if any with a HANDLER, anylize it and throw the exception. |
|
Back to top |
|
 |
kash3338 |
Posted: Mon May 23, 2016 11:34 pm Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
Why do you need to do this? Your query is not very clear. If your motive is to check for the DB connectivity first before making a INSERT, then you can have a dummy SELECT query run before doing the INSERT. Even in that case you have a possibility of failure between the SELECT and INSERT queries.
Best way is to handle the error on the INSERT as mentioned by "maurito". |
|
Back to top |
|
 |
Girirsh K N |
Posted: Tue May 24, 2016 2:05 am Post subject: |
|
|
Newbie
Joined: 26 Apr 2016 Posts: 6
|
The main intention of using this method is to check the database connectivity first and then do the insertion.If the connectivity is not there, will retry for some count and if still the same scenario persists the user exception in thrown. |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue May 24, 2016 3:54 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Lets turn this on its head
Why do you think that the DB won't be there?
Both Systems and DB's are pretty reliable these days.
What is the MTBF for your DB System (Hardware and software)?
Is there some dodgy network between them?
FWIW, I know of a system where the IIB Server is 1500Km from the DB server. Sure the traffic is low volume but in three years, we have not seen a failure due to DB non availability. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue May 24, 2016 4:12 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
What happens if you check the DB, the DB is available, but then it crashes before you try to use it?
In every programming environment, you get some option to handle any exceptions that are thrown by a given programming statement.
IIB is no different. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|