db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: [DRDA] Question about DRDAStatement.initialize() method
Date Fri, 24 Feb 2006 08:20:44 GMT
Deepa Remesh <dremesh@gmail.com> writes:

> Thanks Knut and Kathey. I will open a jira issue for changing use of
> initialize or do it in a separate patch. For your answers to
> question3, I have a small concern. Please see below.
>
>
>> >>3. Is my comment for the new reuse method() okay? specifically, the
>> >>comment about fields which should not be reset?
>> >>"This method should reset all members of this class except the
>> >>following which will be set at initial creation or set explicitly in
>> >>the code: database, pkgnamcsn, pkgcnstkn, pkgid, pkgsn"
>> >>
>> >>
>> >>
>> > If these can be reset too that would be good and then get set whereever
>> > the get set just for completeness.
>>
>> If you reset these variables, you'll need to call
>> DRDAStatement.setPkgnamcsn() and DRDAStatement.setDatabase() later. In
>> DRDAConnThread, setPkgnamcsn() and setDatabase() are not called after
>> DRDAStatement.initialize(), so you'll have to add those calls there.
>
> pkgnamcsn is the key used for statements added to stmtTable. It seems
> to the basis for reusing statements. Resetting it seems a bit odd to
> me. Code in Database.newDRDAStatement will look like this:
>
>         DRDAStatement stmt = getDRDAStatement(pkgnamcsn);
>         if (stmt != null) {
>             stmt.reset();
>             stmt.setPkgnamcsn(pkgnamcsn);
>             stmt.setDatabase(this);
>         }

I agree, it's odd. The way DRDAStatements are reused, pkgnamcsn and
database rarely (if ever) have to be touched. I think it's OK not to
reset them.

You might also consider getting rid of pkgcnstkn, pkgid and pkgsn
since they are stored in pkgnamcsn anyway. If you remove them, we only
have two variables that aren't reset like the others.

I also think it's a good idea to add a comment before the declarations
of the instance variables saying something like

  // NOTE!
  //
  // Since DRDAStatements are reused, ALL variables (except 'database'
  // and 'pkgnamcsn') should be set to their default values in
  // reset().

-- 
Knut Anders

Mime
View raw message