Solved

AS400 - How to test for connectivity

Posted on 2013-12-02
5
537 Views
Last Modified: 2013-12-02
I have a Java program that interacts with an AS400 database.  I am trying to code a work-around for a connectivity problem I am facing.  Sometimes for various reason, after I establish a connection to the database, the connection will be lost (idle timeout, loss of network connection, etc.).  In those cases, I need to be able to check whether the connection is still active, and if not, then I need to re-connect.  In order to test for connectivity, I would like to simply execute some generic SQL statement and check whether it was successful.  Is there any kind of generic "dummy" SQL statement or command that can be run on any AS400 system which will allow me to know whether the connection object is still valid or now?

For example, here is how I do this same operation using both Oracle and MSSQL:

Oracle:   "select 'success' from dual"
MSSQL:  "select 'success'"

Both of those statements work fine for Oracle and MSSQL.  I am looking for something roughly equivalent on the AS400.

Thanks.
0
Comment
Question by:jbaird123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
daveslash earned 500 total points
ID: 39690917
Simple enough ...

select 'success'
  from sysibm.sysdummy1

Open in new window


HTH,
DaveSlash
0
 

Author Closing Comment

by:jbaird123
ID: 39690962
Perfect!  Thanks!
0
 
LVL 35

Expert Comment

by:Gary Patterson
ID: 39691051
How long is the period of time before you experience a connection drop?  Usually this is due to an intermediate firewall, though there is an IBM i TCP connection timer that will eventually drop a connection due to inactivity.  This is a system-wide setting.

Check your firewall log (may need to enable logging of inactive session timeout events), and the QTCP message queue on the IBM i for relevant messages.

Sometimes you can fix this by specifying a longer timeout on the host or firewall.

If you are writing the application, you could just run a small request like the one above just frequently enough to keep the connection "alive" - provided you can determine the idle timeout period.

Also, you can look at the connection in NETSTAT, option 3 on the iSeries and watch the change in status as the connection gets older and older.

This is a common issue, and it can be tricky to resolve unless you are the programmer writing the application - then you can include some sort of (I suggest configurable, since the value could change at the whim of a network admin) keepalive timer.
0
 

Author Comment

by:jbaird123
ID: 39691075
Gary,

Thanks for the info.  I am essentially working on the keep alive timer that you suggest.  I have a situation where a connection is established and then sits idle for a couple of hours while an unrelated process completes.  The issue is that the unrelated process could take anywhere from a couple of seconds to several hours (and there is no way to know in advance how long it will take), and since this connection is used prior to this unrelated process, I cannot wait until after the process is complete to establish the connection.  I basically just need to check whether it is still active after sitting idle for so long and if not, then establish a new connection, otherwise, use the old connection.

Thanks.
0
 
LVL 35

Expert Comment

by:Gary Patterson
ID: 39691193
Here is my suggestion:

1) Connect
2) Submit job
3) Disconnect
3) Set up some sort of notification mechanism in job - put a message on a data queue when it it done (IBM has PC data queue APIs for Java, legacy Windows (C/VB), and .NET).  Even better, just send a little text file via FTP to the client system
4) Watch for the notification event, and reconnect and move on - no overhead on the host, and easy to implement.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
rpg d specs 5 118
Fill Field in Displayfile with variable name 7 112
IBM i - CL Array 5 123
Windows Server 2008 hosting IBM MQ V7.1-Cipher Upgrade 2 76
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
Adults who share images on social media aren’t the only ones who need to worry about their privacy. Our culture’s tendency to share every move and celebration affects the privacy of our children, too.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question