473,396 Members | 1,914 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,396 software developers and data experts.

Java Stored Procedures in DB2 V7.2

I am trying to get a sense of requirements and best practices for Java
stored procedures in DB2 V7.2 for Windows.

1. Is it required or recommended that any of the following be closed before
leaving the stored procedure: open Statement and PreparedStatement objects;
open ResultSet objects; open JDBC connections? Although the stored procedure
will still run succesfully if these open objects and connections are not
closed, are there any negative performance or other consequences from not
closing these things manually?

2. What is the best way to do error handling? For example, if a
PreparedStatement object's executeQuery() method fails for some reason, what
should be returned to the client? I think that the procedure should pass
back at least the SQLCode, SQLState, and SQLMessage and would strongly
prefer to pass back a programmer-written message identifying where the error
took place, e.g. during executeQuery() of statement such-and-such. Do best
practices dictate that anything more, such as a stacktrace, be passed back
as well or that information of this kind be written to an external file?

3. Is there a practical limit on how many parameters and/or result sets can
be passed back to the client? Will there be any performance or other
advantages in limiting the number of parameters and result sets to a
particular number? If yes, what is that number? I'm just writing small
stored procedures for now but I can easily imagine writing much bigger ones.
However, I don't want to overdo things and make a stored procedure the
solution to every problem.

4. I understand that stored procedures can access other programs on the
database server. That gives me thoughts of generating faxes or PDFs,
exporting data to spreadsheets, etc. etc. What sorts of things have people
done that take advantage of this capability? Can anyone point me to examples
of these uses?

--

Rhino
---
rhino1 AT sympatico DOT ca
"If you want the best seat in the house, you'll have to move the cat."
Nov 12 '05 #1
1 2314
Comments to 2 of your points inline:

Rhino wrote:
I am trying to get a sense of requirements and best practices for Java
stored procedures in DB2 V7.2 for Windows.

1. Is it required or recommended that any of the following be closed before
leaving the stored procedure: open Statement and PreparedStatement objects;
open ResultSet objects; open JDBC connections? Although the stored procedure
will still run succesfully if these open objects and connections are not
closed, are there any negative performance or other consequences from not
closing these things manually? If a cursor is actually meant to be a result set, then you must not
close it (or its statement) inside the sp...if you do, no result set
will make it back to the client. I think JDBC disconnect is a noop when
issued from within the SP...

The same work will get done if you close these things manually, or leave
them for cleanup. The only issue is when they get done (in v7, gc in a
db2dari process is syncronous, so a later sps performance may be
affected by an earlier sp being lazy when cleaning up). In v8, gc is
asyncronous, and in general you run in a threaded process, so leaving
more records for manual cleanup could hurt you more...
2. What is the best way to do error handling? For example, if a
PreparedStatement object's executeQuery() method fails for some reason, what
should be returned to the client? I think that the procedure should pass
back at least the SQLCode, SQLState, and SQLMessage and would strongly
prefer to pass back a programmer-written message identifying where the error
took place, e.g. during executeQuery() of statement such-and-such. Do best
practices dictate that anything more, such as a stacktrace, be passed back
as well or that information of this kind be written to an external file?

3. Is there a practical limit on how many parameters and/or result sets can
be passed back to the client? Will there be any performance or other
advantages in limiting the number of parameters and result sets to a
particular number? If yes, what is that number? I'm just writing small
stored procedures for now but I can easily imagine writing much bigger ones.
However, I don't want to overdo things and make a stored procedure the
solution to every problem. We have a limit of 90 paramters for Java routines...I think the result
set limit is 254. :-)

From a performance perspective, fewer parms are better...in particular
for String objects, as each parm must be marshelled/unmarshalled using
JNI, which is an expensive operation. Numerics are faster. Of course,
the more SQL you do in the SP, the less interesting the parm marshalling
overhead becomes.

4. I understand that stored procedures can access other programs on the
database server. That gives me thoughts of generating faxes or PDFs,
exporting data to spreadsheets, etc. etc. What sorts of things have people
done that take advantage of this capability? Can anyone point me to examples
of these uses?

Nov 12 '05 #2

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

Similar topics

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...
7
by: Alex | last post by:
Hi all, I am trying to install a java stored procedure via the windows development centre. The linux box is running 8.1 FP4 as is the windoze platform. If I am on the linux box i can install...
3
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default"...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
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...
1
by: Alex | last post by:
Hi all, Just been dabbling with java stored procedures and I'm having problems replacing System: db2 8.1.4 on RH 7.1 linux system 1). Look at java jdbc samples as supplied with db2 and run...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
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...
1
by: esmith2112 | last post by:
We all of a sudden find ourselves in dire straits, because we have one of those mysteries where everything used to work, and apparently, all of a sudden everything went to pot just in time for a...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.