473,388 Members | 1,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Error Handling in Java Stored Procedures (V7.2)

I've written several Java stored procedures now (DB2 V7.2) and I'd like to
write down a few "best practices" for reference so that I will have them
handy for future development.

Would the experts here agree with the following? Would they add any other
points?

1. If the shop standard calls for logging of application errors, a stored
procedure should log any error that it encounters immediately upon detecting
it and then return to the calling program without executing any further
statements in the stored procedure. The information logged should include: a
timestamp showing when the error was detected; the full name of the stored
procedure, including the schema name; a stack trace (if a stack trace can be
generated); some identification of which specific statement in the stored
procedure detected the error; SQLState; SQLCode; and number or number and
text of DB2 message associated with the error, for example "SQL0101N" or
"SQL0101N - The statement is too long or too complex" . Sufficient
information should also be returned to the calling program so that it knows
the stored procedure hit an error as well as any information that the shop
standards say should be displayed for the user when an error is encountered.
The calling program should then display the information to the user in the
appropriate way, such as a printout or GUI panel.

2. If the shop standard does not call for logging of application errors, the
stored procedure should return to the calling application immediately
without executing any further statements in the stored procedure. All
information needed to debug the error should be returned to the calling
program, including the SQLState, the SQLCode, the DB2 message associated
with the error (or at least its number), a stack trace (assuming a stack
trace can be generated), and some indication of which statement in the
stored procedure encountered the problem. The latter could be the line
number of the statement in the source code of the stored procedure, the
statement itself, or an application message identifying the statement, for
example "Detected error trying to get connection from calling program" or
"Error encountered while attempting to prepare the query".

Also, would everyone agree with me that the code generated by the wizard in
the Stored Procedure Builder is weak for the following reasons:
- all of the generated code is generally in a single try/catch block, making
it difficult to detect which statement in the try block actually encountered
the error
- the wizard has no provision for returning stack traces or messages coded
by the developer

I'm inclined to recommend that developers take the code generated by the
wizard and split each statement out so that it is in its own try/catch block
and that each catch block returns to the caller after encountering an error
rather than waiting until the end of the procedure. Would everyone agree
that this is a good idea?

Also, I'm curious to know how widely application logging is used. Do most
shops insist on developers writing to application logs when errors are
encountered or do most shop standards simply call for error messages and
debug information to be displayed on consoles, printouts, or on GUI screens?
I tend to agree with the philosophy that the end user should not see any
information that he will not likely understand or need and that everything
needed to debug the error should be written to a log, not to printouts or
GUI screens. But I'm open-minded and would be interested in other points of
view.

--
Rhino
---
rhino1 AT sympatico DOT ca
"If you're getting something for nothing, you're not using your own credit
card."
Nov 12 '05 #1
0 4237

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
1
by: Suresh Tri | last post by:
Hi all, I am in search of any Enterprise level Opensource Project that uses Java Stored Procedures supported by Oracle. I could not find any by googling. Can any one plese point me to any such...
9
by: dtwilliams | last post by:
OK, i'm trying to do some error checking on stored procedures and am following the advise in Erland Sommarskog's 'Implementing Error Handling with Stored Procedures' document. Can anybody help...
1
by: Kumar | last post by:
Hi I am trying to recreate a database under the following environments : From: Solaris with DB2UDB version 7.2 with FP 9 To: Linux with DB2UDB version 7.2 with FP 9 It will be of really a...
2
by: Rafael Faria | last post by:
Hi All, We are starting a large data warehousing project using DB2 8.2 on AIX. There is a direction to move any new internal development to Java and a question was raised: Would it be a good...
2
by: Steve Jorgensen | last post by:
When writing VB or VBA code that works with databases or other external libraries that cannot be trusted to automatically do the right thing when references to their objects are arbitrarily...
5
by: Jurgen Defurne | last post by:
I am currently designing an application which should be accessible from different interfaces. For this I like to be using stored procedures to process the contents of form submissions and dialog...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
1
by: pob | last post by:
>From a form I have some code that calls 4 modules frmMain 1 mod 2 mod 3 mod 4 mod If mod 1 experiences an error the error handling works fine within mod 1 and writes out the error to a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.