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: [DRDA] Question about DRDAStatement.initialize() method
Date Thu, 23 Feb 2006 22:52:43 GMT
Deepa Remesh wrote:

>For my DERBY-1002 patch,
>
Thanks Deepa for working to make this code clearer.  It had fooled many
developers and burnt you personally a couple of  times I know.

> I have added a method DRDAStatement.reuse()
>which resets all fields in this class.
>
>        /**
>	 * Clean up statements and result set for reuse.
>         * 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
>         *
>         * @throws SQLException
>	 */
>         protected void reuse() throws SQLException {
>                ...
>         }
>
>  
>
>I was just going through all methods in DRDAStatement and found that
>there is a method called initialize() which does this:
>        /**
>	 * Initialize for reuse
>	 */
>	protected void initialize()
>	{
>		setTypDefValues();
>	}
>where setTypDefValues() does this:
>         /**
>	 * set TypDef values
>	 *
>	 */
>	protected void setTypDefValues()
>	{
>		// initialize statement values to current database values
>		this.typDefNam = database.typDefNam;
>		this.byteOrder = database.byteOrder;
>		this.ccsidSBC = database.ccsidSBC;
>		this.ccsidDBC = database.ccsidDBC;
>		this.ccsidMBC = database.ccsidMBC;
>		this.ccsidSBCEncoding = database.ccsidSBCEncoding;
>		this.ccsidDBCEncoding = database.ccsidDBCEncoding;
>		this.ccsidMBCEncoding = database.ccsidMBCEncoding;
>	}
>
>
>I have couple of questions:
>1. I find it confusing to have a initialize and reuse method with
>similar comments. Can initialize be removed since we can call
>setTypDefValues directly at places where it is currently called?
>
>  
>
I must say I find every use of initialize() absolutely perplexing except
for the one in  parseEXCSQLIMM,
but regardless they all seem to be resetting the defaultDRDAStatement
for reuse, so I think initialize can go away and you can  use your new
reuse() method. I think you can have a reuse, with or without a database
parameter.

>2. initialize() is called at called at 5 places in the server code.
>Two of these places (DRDAConnThread methods parseEXCSQLIMM and
>parseEXCSQLSETobjects) have the following comment:
>
>// initialize statement for reuse
>drdaStmt.initialize();
>
>I am not sure about the actual intention of calling initialize() at
>these places - whether it is to just reset the typedef values or does
>it expect all fields to be reset for reuse. Can someone familiar with
>code look at these places to see it is enough to use initialize() at
>these places? If this does not look right, I can open another issue
>for this.
>
>  
>
yes.  1

>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.

I wonder if reset() is beetter than reuse, but I am the worlds worst namer.
Will there be a reuse() in DRDAResultSet as well?
Will close no longer reset these values and the reuse only called when
the statement is reused?
Even with the rename, I worry a little about the maintainability of
this.  Part of that is just that DRDAStatement is way to busy and I
think the ParameterMetadata should be broken out some day..


Thanks again Deepa



Mime
View raw message