db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r189752 - in /incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda: CodePoint.java DRDAConnThread.java DRDAResultSet.java DRDAStatement.java
Date Thu, 09 Jun 2005 12:57:26 GMT
Author: kmarsden
Date: Thu Jun  9 05:57:25 2005
New Revision: 189752

URL: http://svn.apache.org/viewcvs?rev=189752&view=rev
Log:
DERBY-343 Clean up DRDA classes handling of OPNQRY options

Move qryclsimp logic to DRDAResultset.
Organize imports
			Contributed by Philip Wilder


Modified:
    incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java
    incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java
    incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java?rev=189752&r1=189751&r2=189752&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java (original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java Thu Jun
 9 05:57:25 2005
@@ -741,9 +741,6 @@
 	static final int MAXBLKEXT_NONE = 0;
 	static final int MAXBLKEXT_DEFAULT = MAXBLKEXT_NONE;
 
-	//-------------------Default for QRYCLSIMP
-	static final int QRYCLSIMP_DEFAULT = QRYCLSIMP_SERVER_CHOICE;
-
 	//-------------- QRYSCRORN - query scroll orientation values
 	static final int QRYSCRREL = 1;		// relative fetch
 	static final int QRYSCRABS = 2;		// absolute fetch

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=189752&r1=189751&r2=189752&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Thu
Jun  9 05:57:25 2005
@@ -27,48 +27,37 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.FileInputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.lang.reflect.*;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.DataTruncation;
-import java.sql.DriverManager;
+import java.math.BigDecimal;
+import java.sql.CallableStatement;
 import java.sql.Connection;
-import java.sql.Statement;
 import java.sql.PreparedStatement;
-import java.sql.CallableStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
 import java.sql.Types;
-import java.sql.Blob;
-import java.sql.Clob;
-
-import java.util.Properties;
-import java.util.Enumeration;
-import java.util.Vector;
 import java.util.ArrayList;
 import java.util.Date;
-import java.math.BigDecimal;
+import java.util.Properties;
+import java.util.Vector;
 
-import org.apache.derby.iapi.tools.i18n.LocalizedResource;
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.iapi.error.ExceptionSeverity;
-import org.apache.derby.impl.jdbc.Util;
-import org.apache.derby.impl.jdbc.EmbedSQLException;
-import org.apache.derby.impl.jdbc.EmbedSQLWarning;
-import org.apache.derby.impl.jdbc.EmbedStatement;
-import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
-import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
-
+import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.iapi.reference.JDBC30Translation;
+import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.info.JVMInfo;
-
+import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
-import org.apache.derby.iapi.services.monitor.Monitor;
+import org.apache.derby.iapi.tools.i18n.LocalizedResource;
+import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
+import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
+import org.apache.derby.impl.jdbc.EmbedSQLException;
+import org.apache.derby.impl.jdbc.EmbedStatement;
+import org.apache.derby.impl.jdbc.Util;
 
 public class DRDAConnThread extends Thread {
 
@@ -158,7 +147,6 @@
 	// public key generated by Deffie-Hellman algorithm, to be passed to the encrypter,
 	// as well as used to initialize the cipher
 	private byte[] myPublicKey;
-
 	// constructor
 	/**
 	 * Create a new Thread for processing session requests
@@ -1661,7 +1649,7 @@
 		int qryblkctl = CodePoint.QRYBLKCTL_DEFAULT;
 		int maxblkext = CodePoint.MAXBLKEXT_DEFAULT;
 		int qryrowset = CodePoint.QRYROWSET_DEFAULT;
-		int qryclsimp = CodePoint.QRYCLSIMP_DEFAULT;
+		int qryclsimp = DRDAResultSet.QRYCLSIMP_DEFAULT;
 		int outovropt = CodePoint.OUTOVRFRS;
 		reader.markCollection();
 		int codePoint = reader.getCodePoint();
@@ -1758,7 +1746,7 @@
 		stmt.setOPNQRYOptions(blksize,qryblkctl,maxblkext,outovropt,
 							  qryrowset, qryclsimp);
 		//}
-
+		
 		// read the command objects
 		// for ps with parameter
 		if (reader.isChainedWithSameID())
@@ -5867,10 +5855,9 @@
 			writer.endDdmAndDss();
 
 		if( (!stmt.hasdata()) &&
-			stmt.getQryclsimp() != CodePoint.QRYCLSIMP_NO &&
-			stmt.getQryprctyp() != CodePoint.LMTBLKPRC)
+			stmt.isRSCloseImplicit()) {
 			stmt.rsClose();
-		
+		}
 	}
 
 	private boolean writeFDODTA (DRDAStatement stmt) 
@@ -5896,7 +5883,6 @@
 				hasdata = positionCursor(stmt, rs);
 			else
 				hasdata = rs.next();
-
 		}
 		else	// it's for a CallableStatement
 		{
@@ -6150,13 +6136,7 @@
 			}
 			else  // non-scrollable cursor
 			{
-				// for QRYCLSIMP_YES or SERVER_CHOICE close the rs
-				int qryclsimp = stmt.getQryclsimp();
-				if (qryclsimp != CodePoint.QRYCLSIMP_NO &&
-					//For LMTBLKPRC, we reach the end early, but cursor should
-					//not be closed prematurely.
-					stmt.getQryprctyp()
-										!= CodePoint.LMTBLKPRC)
+				if (stmt.isRSCloseImplicit())
 				{
 					stmt.rsClose();
 					stmt.rsSuspend();

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java?rev=189752&r1=189751&r2=189752&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java (original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java Thu
Jun  9 05:57:25 2005
@@ -20,27 +20,13 @@
 
 package org.apache.derby.impl.drda;
 
-import java.lang.reflect.*;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.sql.Statement;
 import java.sql.ResultSetMetaData;
-import java.sql.Types;
 import java.sql.SQLException;
-
+import java.sql.Types;
 import java.util.ArrayList;
-import java.util.StringTokenizer;
-import java.util.Vector;
 
-import org.apache.derby.iapi.reference.JDBC30Translation;
-import org.apache.derby.impl.jdbc.Util;
 import org.apache.derby.impl.jdbc.EmbedResultSet;
-import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.impl.jdbc.EmbedSQLException;
-import org.apache.derby.iapi.reference.SQLState;
 
 /**
 	DRDAResultSet holds result set information
@@ -51,7 +37,8 @@
 	// resultSet states are NOT_OPENED and SUSPENDED
 	protected static final int NOT_OPENED = 1;
 	protected static final int SUSPENDED = 2;
-
+	public static final int QRYCLSIMP_DEFAULT = CodePoint.QRYCLSIMP_NO;  
+	
 	boolean explicitlyClosed = false;
 
 	int state;
@@ -72,7 +59,7 @@
 	protected int blksize;				// Query block size
 	protected int maxblkext;			// Maximum number of extra blocks
 	protected int outovropt;			// Output Override option
-	protected int qryclsimp;            // Implicit Query Close Setting
+	private int qryclsimp; // Implicit Query Close Setting
 	protected boolean qryrelscr;		// Query relative scrolling
 	protected long qryrownbr;			// Query row number
 	protected boolean qryrfrtbl;		// Query refresh answer set table
@@ -495,6 +482,40 @@
 		}
 
 	}
-}
 	
-
+	/**
+	 * Method to decide weather the ResultSet should be closed implicitly.
+	 * When the protocol type is Limited Block Query Protocol we should not
+	 * close implicitly even if qryclsimp is set to YES.
+	 * 
+	 * @return close implicit boolean
+	 * @throws SQLException
+	 */
+	boolean isRSCloseImplicit() throws SQLException {
+		return qryclsimp == CodePoint.QRYCLSIMP_YES && 
+			getQryprctyp() != CodePoint.LMTBLKPRC;
+	}
+	
+	/**
+	 * Sets the OPNQRYOptions. For more information on the meaning of these
+	 * values consult the DRDA Technical Standard document. 
+	 * 
+	 * @param blksize Query block Size
+	 * @param qryblkctl Use to set the query protocol type
+	 * @param maxblkext Maximum number of extra blocks
+	 * @param outovropt Output override option
+	 * @param qryrowset Query row set
+	 * @param qryclsimpl Implicit query close setting
+	 */
+	protected void setOPNQRYOptions(int blksize, int qryblkctl,
+			int maxblkext, int outovropt,int qryrowset,int qryclsimpl)
+	{
+		this.blksize = blksize;
+		setQryprctyp(qryblkctl);
+		this.maxblkext = maxblkext;
+		this.outovropt = outovropt;
+		this.qryrowset = qryrowset;
+		this.qryclsimp = (qryclsimpl == CodePoint.QRYCLSIMP_SERVER_CHOICE)
+			? DRDAResultSet.QRYCLSIMP_DEFAULT : qryclsimpl;
+	}
+}
\ No newline at end of file

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java?rev=189752&r1=189751&r2=189752&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java (original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java Thu
Jun  9 05:57:25 2005
@@ -20,38 +20,28 @@
 
 package org.apache.derby.impl.drda;
 
-import java.lang.reflect.*;
-
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigInteger;
+import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
-import java.sql.CallableStatement;
 import java.sql.ResultSet;
-import java.sql.Statement;
 import java.sql.SQLException;
-
+import java.sql.Statement;
 import java.util.ArrayList;
+import java.util.Hashtable;
 import java.util.StringTokenizer;
 import java.util.Vector;
-import java.util.Enumeration;
 
+import org.apache.derby.iapi.jdbc.BrokeredConnection;
+import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
 import org.apache.derby.iapi.reference.JDBC30Translation;
-import org.apache.derby.iapi.services.info.JVMInfo;
-import org.apache.derby.impl.jdbc.Util;
-import org.apache.derby.impl.jdbc.EmbedConnection;
-import  org.apache.derby.iapi.jdbc.BrokeredConnection;
-import  org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
-import org.apache.derby.impl.jdbc.EmbedResultSet;
-import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.impl.jdbc.EmbedSQLException;
 import org.apache.derby.iapi.sql.execute.ExecutionContext;
-import org.apache.derby.iapi.reference.SQLState;
-
 import org.apache.derby.iapi.util.StringUtil;
-
-import java.math.BigInteger;
-import java.io.UnsupportedEncodingException;
-import java.util.Hashtable;
+import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
+import org.apache.derby.impl.jdbc.Util;
 
 /**
 	DRDAStatement stores information about the statement being executed
@@ -112,7 +102,6 @@
 	protected int blksize;				// Query block size
 	protected int maxblkext;			// Maximum number of extra blocks
 	protected int outovropt;			// Output Override option
-	protected int qryclsimp;            // Implicit Query Close Setting
 	protected boolean qryrfrtbl;		// Query refresh answer set table
 	private int qryprctyp = CodePoint.QRYBLKCTL_DEFAULT;   // Protocol type
 	
@@ -297,17 +286,15 @@
 	
 
 	/**
-	 * Set query options sent on OPNQRY
+	 * Delegation method to call DRDAResultSet to set query 
+	 * options sent on OPNQRY.
+	 * @see DRDAResultSet#setOPNQRYOptions(int, int, int, int, int, int)
 	 */
 	protected void setOPNQRYOptions(int blksize, int qryblkctl,
 								  int maxblkext, int outovropt,int qryrowset,int qryclsimpl)
 	{
-		currentDrdaRs.blksize = blksize;
-		currentDrdaRs.setQryprctyp(qryblkctl);
-		currentDrdaRs.maxblkext = maxblkext;
-		currentDrdaRs.outovropt = outovropt;
-		currentDrdaRs.qryrowset = qryrowset;
-		currentDrdaRs.qryclsimp = qryclsimp;
+		currentDrdaRs.setOPNQRYOptions( blksize, qryblkctl, maxblkext, 
+				outovropt, qryrowset, qryclsimpl);
 	}
 
 	/*
@@ -392,16 +379,6 @@
 		return currentDrdaRs.qryscrorn;
 	}
 
-	protected void getQryclsimp(int value)
-	{
-		currentDrdaRs.qryclsimp = value;
-	}
-
-	protected int  getQryclsimp()
-	{
-		return currentDrdaRs.qryclsimp;
-	}
-
 	protected void setScrollType(int scrollType)
 	{
 		currentDrdaRs.scrollType = scrollType;
@@ -950,7 +927,6 @@
 	 */
 	protected void close()  throws SQLException
 	{
-		
 		if (ps != null)
 			ps.close();
 		if (stmt != null)
@@ -1630,6 +1606,17 @@
 			// occur from this code. Just in case we will throw it
 			throw Util.javaException(e);
 		
+	}
+	
+	/**
+	 * Delegation method to call DRDAResultSet.isRSCloseImplicit()
+	 * 
+	 * @see DRDAResultSet#isRSCloseImplicit()
+	 * @return implicit close boolean
+	 * @throws SQLException
+	 */
+	boolean isRSCloseImplicit() throws SQLException {
+		return currentDrdaRs.isRSCloseImplicit();
 	}
 }
 



Mime
View raw message