db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject Re: Regarding DERBY-2658: Converting jdbcapi/parameterMetaDataJdbc30.java to JUnit
Date Thu, 07 Jun 2007 16:55:17 GMT
Ramin Moazeni wrote:
> Hello,
>
> The following piece of code gives two different results when it is run
> as embedded
> and net client and therefore, I am getting test failures. The results
>
I think there is a bug here but I am not totally sure whether it is in 
embedded, client or both.
It seems to me maybe the correct thing is to throw an exception in this 
case, since the CallableStatement has not been executed after the 
parameter is set. Does that sound correct?    If a value should be 
returned, I think the client behaviour is more sensible.
It would be good to get other opinions.

Here is the translated information from the old bug mentioned.

Embedded gets the value last 'set' if no execute was done 
right before; Client gets the value from the last execute.

Basically, if the sequence of events is:
cs.prepareCall, cs.registerOutParameter, cs.set*, cs.get* (i.e. 
no execute), Embedded will return the value used in the set* 
(e.g. setInt) statement. Client returns either an inappropriate 
message (invalid operation: wasNull() called with no data 
retrieved) - but that's another issue) or the value obtained in 
the last execution. 

Thus, if the sequence is: prepare, register, set, execute, set, 
get, Embedded returns the value passed into the INOUT 
parameter with the set, Client returns the value obtained in from 
the last execute.

Similarly, if the sequence of events is:
prepare, get (no register, set, or execute), embedded returns: 0.
This does not make sense, and a graceful message should be 
issued.

test: conn/parameterMetaData.java:
---------------------
 s.executeUpdate("create procedure dummyint(in a integer, in b 
integer, out c integer, inout d integer) language java external 
name 
'com.ibm.db2j.functionTests.conn.parameterMetaDataJdbc30.dummyin
t' parameter style java");
// the method dummyint returns 11111
System.out.println("Behaviour of meta data and out params after 
re-compile");
      cs = con.prepareCall("CALL dummyint(?,?,?,?)");
      cs.registerOutParameter(3,Types.INTEGER);
      cs.registerOutParameter(4,Types.INTEGER);
      cs.setInt(1,1);
      cs.setInt(2,1);
      cs.setInt(4,4);
      dumpParameterMetaData(cs.getParameterMetaData());
      cs.execute();
      System.out.println("DUMMYINT alias returned " + 
cs.getInt(4));
------------
      This first time, the value returned is 11111. It's like 
that with networkserver and  Embedded
The dummyint2 method used next is like dummyint1, but always 
returns 22222.
------------
      s.executeUpdate("drop procedure dummyint");
      s.executeUpdate("create procedure dummyint(in a integer, 
in b integer, out c integer, inout d integer) language java 
external name 
'com.ibm.db2j.functionTests.conn.parameterMetaDataJdbc30.dummyin
t2' parameter style java");
      cs.execute();
      dumpParameterMetaData(cs.getParameterMetaData());
      cs.setInt(4, 6);
      System.out.println("DUMMYINT alias returned " + 
cs.getInt(4));

-------------
--->    This is where a cs.execute() should happen in proper 
code...
-------------
      System.out.println("DUMMYINT alias returned " + 
cs.getInt(4));
      cs.close();
--------------------------------
         The returned value is 22222 for networkserver, 
but Embedded returns 6.




Mime
View raw message