473,466 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Java Stored Procedures (V7.2)

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 Throwable as an OUT
parameter and what datatype should I use in the CREATE PROCEDURE and DROP
PROCEDURE statements?

Here's what I tried:
- the method signature for the stored procedure included: Throwable[]
throwable
- every catch block in the stored procedure included: throwable[0] =
sql_excp
- the calling program included: callStmt.registerOutParameter(5,
Types.OTHER);
- the calling program included: Throwable throwable = (Throwable)
callStmt.getObject(5);
- the CREATE PROCEDURE and DROP PROCEDURE statements used VARCHAR(4000) as
the datatype for the Throwable

My calling program and stored procedure both compiled just fine and the
preparation procedure which included DROP PROCEDURE for the old version of
the stored proc and CREATE PROCEDURE for the new version of the stored proc
worked without errors. Unfortunately, I got a CLI0123E error (SQL data type
out of range) at runtime, specifically when I call the execute() method on
the CallableStatement.

I can't see anything in the documentation that suggests any other approach
so it seems to me that:
a) it simply isn't permissible to pass a Throwable from a Java stored
procedure to its calling program
-OR-
b) some datatype other than VARCHAR(4000) should be used in the CREATE
PROCEDURE and DROP PROCEDURE statements.

Since I don't see anything remotely resembling Throwable in Table 31 (SQL
Data Types Mapped to Java Declarations) in the Application Building Guide,
I'm strongly inclined to think that a) is the truth. I'd just like to be
sure that's right before I give up on passing a Throwable to the caller.

--
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
4 3168
I'm surprised that the JVM found a match for the method with a throwable
type in the signature...we generate the method signature based on the
cataloged parameter types (for a varchar it'll be a String type), so
this must mean that the classloader is treating the throwable like a
string?!? Sounds wierd...is it really a string? If not, maybe you can
pass it as a byte array?? (If this is a real structure couldn't you have
problems with endian differences etc)?

Rhino wrote:
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 Throwable as an OUT
parameter and what datatype should I use in the CREATE PROCEDURE and DROP
PROCEDURE statements?

Here's what I tried:
- the method signature for the stored procedure included: Throwable[]
throwable
- every catch block in the stored procedure included: throwable[0] =
sql_excp
- the calling program included: callStmt.registerOutParameter(5,
Types.OTHER);
- the calling program included: Throwable throwable = (Throwable)
callStmt.getObject(5);
- the CREATE PROCEDURE and DROP PROCEDURE statements used VARCHAR(4000) as
the datatype for the Throwable

My calling program and stored procedure both compiled just fine and the
preparation procedure which included DROP PROCEDURE for the old version of
the stored proc and CREATE PROCEDURE for the new version of the stored proc
worked without errors. Unfortunately, I got a CLI0123E error (SQL data type
out of range) at runtime, specifically when I call the execute() method on
the CallableStatement.

I can't see anything in the documentation that suggests any other approach
so it seems to me that:
a) it simply isn't permissible to pass a Throwable from a Java stored
procedure to its calling program
-OR-
b) some datatype other than VARCHAR(4000) should be used in the CREATE
PROCEDURE and DROP PROCEDURE statements.

Since I don't see anything remotely resembling Throwable in Table 31 (SQL
Data Types Mapped to Java Declarations) in the Application Building Guide,
I'm strongly inclined to think that a) is the truth. I'd just like to be
sure that's right before I give up on passing a Throwable to the caller.

Nov 12 '05 #2
First, let me apologize for being so late getting back to this thread. I got
snarled up in some other things.

I'm not quite sure what you are telling me. Are you suggesting that it *is*
possible to pass a Throwable from a stored procedure to a calling program?
For what it's worth, I've tried defining the throwable as a VARCHAR(4000)
and as a VARCHAR(4000) FOR BIT DATA in the CREATE PROCEDURE statement; the
statement executed without errors but both had the same runtime error,
CLI0123E. If there is a way to pass a Throwable back to my calling program,
I'd be interested in trying it.

Basically, I'd like to return more than just the SqlState, SqlCode, and
SqlMessage back to my calling program; I think it would improve the quality
of the error handling if a Throwable could be passed back so that a
stackTrace could be obtained. I've already satisfied myself that a
stackTrace can be obtained within the stored procedure, converted to a
String, and then passed back but now I'd like to see if there is some way to
pass the Throwable itself back so that the calling program could get the
stackTrace from it. Otherwise, I'd have to have a small extra method in each
stored procedure for turning the stacktrace into a String.

Any pointers you could offer would be greatly appreciated; you appear to be
*the* stored procedures expert at the Toronto lab.

Rhino
"Sean McKeough" <mc******@nospam.ca.ibm.com> wrote in message
news:c5**********@hanover.torolab.ibm.com...
I'm surprised that the JVM found a match for the method with a throwable
type in the signature...we generate the method signature based on the
cataloged parameter types (for a varchar it'll be a String type), so
this must mean that the classloader is treating the throwable like a
string?!? Sounds wierd...is it really a string? If not, maybe you can
pass it as a byte array?? (If this is a real structure couldn't you have
problems with endian differences etc)?

Rhino wrote:
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 Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements?

Here's what I tried:
- the method signature for the stored procedure included: Throwable[]
throwable
- every catch block in the stored procedure included: throwable[0] =
sql_excp
- the calling program included: callStmt.registerOutParameter(5,
Types.OTHER);
- the calling program included: Throwable throwable = (Throwable)
callStmt.getObject(5);
- the CREATE PROCEDURE and DROP PROCEDURE statements used VARCHAR(4000) as the datatype for the Throwable

My calling program and stored procedure both compiled just fine and the
preparation procedure which included DROP PROCEDURE for the old version of the stored proc and CREATE PROCEDURE for the new version of the stored proc worked without errors. Unfortunately, I got a CLI0123E error (SQL data type out of range) at runtime, specifically when I call the execute() method on the CallableStatement.

I can't see anything in the documentation that suggests any other approach so it seems to me that:
a) it simply isn't permissible to pass a Throwable from a Java stored
procedure to its calling program
-OR-
b) some datatype other than VARCHAR(4000) should be used in the CREATE
PROCEDURE and DROP PROCEDURE statements.

Since I don't see anything remotely resembling Throwable in Table 31 (SQL Data Types Mapped to Java Declarations) in the Application Building Guide, I'm strongly inclined to think that a) is the truth. I'd just like to be
sure that's right before I give up on passing a Throwable to the caller.

Nov 12 '05 #3
I used to be the stored procedures guy (in a former life). :-)

With parameter style java, we went to a standard argument method called
SQLJ part1...it defines what types can be used in an sp interface etc.,
and the only one that isn't a base sql type is the result set object. So
we're pretty constrained by these rules. I think you'll be stuck with
passing the callstack info around as database type parameters.

Rhino wrote:
First, let me apologize for being so late getting back to this thread. I got
snarled up in some other things.

I'm not quite sure what you are telling me. Are you suggesting that it *is*
possible to pass a Throwable from a stored procedure to a calling program?
For what it's worth, I've tried defining the throwable as a VARCHAR(4000)
and as a VARCHAR(4000) FOR BIT DATA in the CREATE PROCEDURE statement; the
statement executed without errors but both had the same runtime error,
CLI0123E. If there is a way to pass a Throwable back to my calling program,
I'd be interested in trying it.

Basically, I'd like to return more than just the SqlState, SqlCode, and
SqlMessage back to my calling program; I think it would improve the quality
of the error handling if a Throwable could be passed back so that a
stackTrace could be obtained. I've already satisfied myself that a
stackTrace can be obtained within the stored procedure, converted to a
String, and then passed back but now I'd like to see if there is some way to
pass the Throwable itself back so that the calling program could get the
stackTrace from it. Otherwise, I'd have to have a small extra method in each
stored procedure for turning the stacktrace into a String.

Any pointers you could offer would be greatly appreciated; you appear to be
*the* stored procedures expert at the Toronto lab.

Rhino
"Sean McKeough" <mc******@nospam.ca.ibm.com> wrote in message
news:c5**********@hanover.torolab.ibm.com...
I'm surprised that the JVM found a match for the method with a throwable
type in the signature...we generate the method signature based on the
cataloged parameter types (for a varchar it'll be a String type), so
this must mean that the classloader is treating the throwable like a
string?!? Sounds wierd...is it really a string? If not, maybe you can
pass it as a byte array?? (If this is a real structure couldn't you have
problems with endian differences etc)?

Rhino wrote:
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 Throwable as an
OUT
parameter and what datatype should I use in the CREATE PROCEDURE and
DROP
PROCEDURE statements?

Here's what I tried:
- the method signature for the stored procedure included: Throwable[]
throwable
- every catch block in the stored procedure included: throwable[0] =
sql_excp
- the calling program included: callStmt.registerOutParameter(5,
Types.OTHER);
- the calling program included: Throwable throwable = (Throwable)
callStmt.getObject(5);
- the CREATE PROCEDURE and DROP PROCEDURE statements used VARCHAR(4000)
as
the datatype for the Throwable

My calling program and stored procedure both compiled just fine and the
preparation procedure which included DROP PROCEDURE for the old version
of
the stored proc and CREATE PROCEDURE for the new version of the stored
proc
worked without errors. Unfortunately, I got a CLI0123E error (SQL data
type
out of range) at runtime, specifically when I call the execute() method
on
the CallableStatement.

I can't see anything in the documentation that suggests any other
approach
so it seems to me that:
a) it simply isn't permissible to pass a Throwable from a Java stored
procedure to its calling program
-OR-
b) some datatype other than VARCHAR(4000) should be used in the CREATE
PROCEDURE and DROP PROCEDURE statements.

Since I don't see anything remotely resembling Throwable in Table 31
(SQL
Data Types Mapped to Java Declarations) in the Application Building
Guide,
I'm strongly inclined to think that a) is the truth. I'd just like to be
sure that's right before I give up on passing a Throwable to the caller.


Nov 12 '05 #4
Fair enough! Thanks for the information, Sean!

Rhino

"Sean McKeough" <mc******@nospam.ca.ibm.com> wrote in message
news:c5**********@hanover.torolab.ibm.com...
I used to be the stored procedures guy (in a former life). :-)

With parameter style java, we went to a standard argument method called
SQLJ part1...it defines what types can be used in an sp interface etc.,
and the only one that isn't a base sql type is the result set object. So
we're pretty constrained by these rules. I think you'll be stuck with
passing the callstack info around as database type parameters.

Rhino wrote:
First, let me apologize for being so late getting back to this thread. I got snarled up in some other things.

I'm not quite sure what you are telling me. Are you suggesting that it *is* possible to pass a Throwable from a stored procedure to a calling program? For what it's worth, I've tried defining the throwable as a VARCHAR(4000) and as a VARCHAR(4000) FOR BIT DATA in the CREATE PROCEDURE statement; the statement executed without errors but both had the same runtime error,
CLI0123E. If there is a way to pass a Throwable back to my calling program, I'd be interested in trying it.

Basically, I'd like to return more than just the SqlState, SqlCode, and
SqlMessage back to my calling program; I think it would improve the quality of the error handling if a Throwable could be passed back so that a
stackTrace could be obtained. I've already satisfied myself that a
stackTrace can be obtained within the stored procedure, converted to a
String, and then passed back but now I'd like to see if there is some way to pass the Throwable itself back so that the calling program could get the
stackTrace from it. Otherwise, I'd have to have a small extra method in each stored procedure for turning the stacktrace into a String.

Any pointers you could offer would be greatly appreciated; you appear to be *the* stored procedures expert at the Toronto lab.

Rhino
"Sean McKeough" <mc******@nospam.ca.ibm.com> wrote in message
news:c5**********@hanover.torolab.ibm.com...
I'm surprised that the JVM found a match for the method with a throwable
type in the signature...we generate the method signature based on the
cataloged parameter types (for a varchar it'll be a String type), so
this must mean that the classloader is treating the throwable like a
string?!? Sounds wierd...is it really a string? If not, maybe you can
pass it as a byte array?? (If this is a real structure couldn't you have
problems with endian differences etc)?

Rhino wrote:

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 Throwable as an


OUT
parameter and what datatype should I use in the CREATE PROCEDURE and


DROP
PROCEDURE statements?

Here's what I tried:
- the method signature for the stored procedure included: Throwable[]
throwable
- every catch block in the stored procedure included: throwable[0] =
sql_excp
- the calling program included: callStmt.registerOutParameter(5,
Types.OTHER);
- the calling program included: Throwable throwable = (Throwable)
callStmt.getObject(5);
- the CREATE PROCEDURE and DROP PROCEDURE statements used VARCHAR(4000)


as
the datatype for the Throwable

My calling program and stored procedure both compiled just fine and the
preparation procedure which included DROP PROCEDURE for the old version


of
the stored proc and CREATE PROCEDURE for the new version of the stored


proc
worked without errors. Unfortunately, I got a CLI0123E error (SQL data


type
out of range) at runtime, specifically when I call the execute() method


on
the CallableStatement.

I can't see anything in the documentation that suggests any other


approach
so it seems to me that:
a) it simply isn't permissible to pass a Throwable from a Java stored
procedure to its calling program
-OR-
b) some datatype other than VARCHAR(4000) should be used in the CREATE
PROCEDURE and DROP PROCEDURE statements.

Since I don't see anything remotely resembling Throwable in Table 31


(SQL
Data Types Mapped to Java Declarations) in the Application Building


Guide,
I'm strongly inclined to think that a) is the truth. I'd just like to

besure that's right before I give up on passing a Throwable to the caller.


Nov 12 '05 #5

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"...
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...
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:
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.