db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r371897 - in /db/derby/code/trunk/java/drda/org/apache/derby/impl/drda: DRDAConnThread.java DRDAStatement.java
Date Tue, 24 Jan 2006 11:56:28 GMT
Author: bernt
Date: Tue Jan 24 03:56:16 2006
New Revision: 371897

URL: http://svn.apache.org/viewcvs?rev=371897&view=rev
Log:
DERBY-815 Prevent unneeded object creation and excessive decoding in parseSQLDTA_work()
Submitted by Dyre Tjeldvoll

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=371897&r1=371896&r2=371897&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Tue Jan 24
03:56:16 2006
@@ -3853,18 +3853,11 @@
 	 */
 	private void parseSQLDTA_work(DRDAStatement stmt) throws DRDAProtocolException,SQLException
 	{
-		String strVal;
 		PreparedStatement ps = stmt.getPreparedStatement();
-		int codePoint;
-		EmbedParameterSetMetaData pmeta = null;
-		Vector paramDrdaTypes = new Vector();
-		Vector paramLens = new Vector();
-		ArrayList paramExtPositions = null;
-		int numVars = 0;
-		boolean rtnParam = false;
-
+        final boolean haveParams = (stmt.getNumParams() > 0);
+        
 		reader.markCollection();		
-		codePoint = reader.getCodePoint();
+        int codePoint = reader.getCodePoint();
 		while (codePoint != -1)
 		{
 				switch (codePoint)
@@ -3881,21 +3874,44 @@
 						reader.readByte();		// id
 						for (int j = 0; j < numVarsInGrp; j++)
 						{
-							paramDrdaTypes.addElement(new Byte(reader.readByte()));
+                            final byte drdaType = reader.readByte();
 							if (SanityManager.DEBUG) 
 								trace("drdaType is: "+ "0x" +
-       								  Integer.toHexString(((Byte ) paramDrdaTypes.lastElement()).byteValue()));
-							int drdaLength = reader.readNetworkShort();
+                                         Integer.toHexString(drdaType));
+
+                            final int drdaLength = reader.readNetworkShort();
 							if (SanityManager.DEBUG) 
 								trace("drdaLength is: "+drdaLength);
-							paramLens.addElement(new Integer(drdaLength));
-						}
-					}
-					numVars = paramDrdaTypes.size();
-					if (SanityManager.DEBUG)
-						trace("numVars = " + numVars);
+
+                            if (!haveParams) {
+                                stmt.addParam(drdaType, drdaLength);
+                                continue;
+                            }
+                            final DRDAStatement.CliParam cp = 
+                                stmt.getCliParam(j);
+                            if (cp.drdaType != drdaType || 
+                                cp.drdaLength != drdaLength) {
+                                if (SanityManager.DEBUG) {
+                                    trace(ps+" param " +j+
+                                          " type: "+ 
+                                          drdaTypeName(cp.drdaType)+ 
+                                          "->"+drdaTypeName(drdaType)+ 
+                                          " length: "+ 
+                                          cp.drdaLength+"->"+drdaLength);
+                                }
+                                // Trust that this is OK...
+                                cp.drdaType = drdaType;
+                                cp.drdaLength = drdaLength;
+                            }
+                        }
+                    } // while (reader 
+                        
 					if (ps == null)		// it is a CallableStatement under construction
 					{
+                        final int numVars = stmt.getNumParams();
+                        if (SanityManager.DEBUG)
+                            trace("numVars = " + numVars);
+
 						String marks = "(?";	// construct parameter marks
 						for (int i = 1; i < numVars; i++)
 							marks += ", ?";
@@ -3927,23 +3943,22 @@
 								// The first exception is the most likely suspect
 								throw se;
 							}
-							rtnParam = true;
 						}
 						ps = cs;
 						stmt.ps = ps;
 					}
 
-					pmeta = stmt.getParameterMetaData();
-
 					reader.readBytes(6);	// descriptor footer
 					break;
 				// optional
 				case CodePoint.FDODTA:
+                    EmbedParameterSetMetaData pmeta = stmt.getParameterMetaData();
 					reader.readByte();	// row indicator
+                    final int numVars = stmt.getNumParams();
 					for (int i = 0; i < numVars; i++)
 					{
-					
-						if ((((Byte)paramDrdaTypes.elementAt(i)).byteValue() & 0x1) == 0x1)	// nullable
+                        final DRDAStatement.CliParam cp = stmt.getCliParam(i);
+                        if ((cp.drdaType & 0x1) == 0x1) // nullable
 						{
 							int nullData = reader.readUnsignedByte();
 							if ((nullData & 0xFF) == FdocaConstants.NULL_DATA)
@@ -3960,15 +3975,8 @@
 						}
 
 						// not null, read and set it
-						paramExtPositions = readAndSetParams(i, stmt,
-															 ((Byte)paramDrdaTypes.elementAt(i)).byteValue(),
-															 pmeta,
-															 paramExtPositions,
-															 ((Integer)(paramLens.elementAt(i))).intValue());
+                        readAndSetParams(i, stmt, cp, pmeta);
 					}
-					stmt.cliParamExtPositions = paramExtPositions;
-					stmt.cliParamDrdaTypes = paramDrdaTypes;
-					stmt.cliParamLens = paramLens;	
 					break;
 				case CodePoint.EXTDTA:
 					readAndSetAllExtParams(stmt);
@@ -3979,8 +3987,6 @@
 			}
 				codePoint = reader.getCodePoint();
 		}
-
-
 	}
 
 	private int getByteOrder()
@@ -3992,25 +3998,21 @@
 	/**
 	 * Read different types of input parameters and set them in PreparedStatement
 	 * @param i			index of the parameter
-	 * @param stmt       drda statement
-	 * @param drdaType	drda type of the parameter
+     * @param stmt      drda statement
+     * @param cp        CliParam object for parameter i
 	 * @param pmeta		parameter meta data
-	 * @param paramExtPositions  ArrayList of parameters with extdta
-	 * @param paramLenNumBytes Number of bytes for encoding LOB Length
 	 *
-	 * @return updated paramExtPositions
 	 * @throws DRDAProtocolException
      * @throws SQLException
 	 */
-	private ArrayList readAndSetParams(int i, DRDAStatement stmt, int
-									   drdaType, EmbedParameterSetMetaData pmeta,
-									   ArrayList paramExtPositions,
-									   int paramLenNumBytes)
+    private void readAndSetParams(int i, DRDAStatement stmt, 
+                                  DRDAStatement.CliParam cp,
+                                  EmbedParameterSetMetaData pmeta)
 				throws DRDAProtocolException, SQLException
 	{
 		PreparedStatement ps = stmt.getPreparedStatement();
 		// mask out null indicator
-		drdaType = ((drdaType | 0x01) & 0x000000ff);
+        int drdaType = ((cp.drdaType | 0x01) & 0x000000ff);
 
 		if (ps instanceof CallableStatement)
 		{
@@ -4069,8 +4071,8 @@
 			}
 			case DRDAConstants.DRDA_TYPE_NDECIMAL:
 			{
-				int precision = (paramLenNumBytes >> 8) & 0xff;
-				int scale = paramLenNumBytes & 0xff;
+                int precision = (cp.drdaLength >> 8) & 0xff;
+                int scale = cp.drdaLength & 0xff;
 				BigDecimal paramVal = reader.readBigDecimal(precision, scale);
 				if (SanityManager.DEBUG)
 					trace("ndecimal parameter value is: "+paramVal);
@@ -4168,12 +4170,10 @@
 			case DRDAConstants.DRDA_TYPE_NLOBCSBCS:
 			case DRDAConstants.DRDA_TYPE_NLOBCDBCS:
 			 {
-				 long length = readLobLength(paramLenNumBytes);
+                 long length = readLobLength(cp.drdaLength);
 				 if (length != 0) //can be -1 for CLI if "data at exec" mode, see clifp/exec test
 				 {
-					if (paramExtPositions == null)
-						 paramExtPositions = new ArrayList();
-				 	paramExtPositions.add(new Integer(i));
+                     cp.isExt = true;
 				 }
 				 else   /* empty */
 				 {
@@ -4192,7 +4192,6 @@
 				ps.setObject(i+1, paramVal);
 			}
 		}
-		return paramExtPositions;
 	}
 
 	private long readLobLength(int extLenIndicator) 
@@ -4221,21 +4220,20 @@
 	private void readAndSetAllExtParams(DRDAStatement stmt) 
 		throws SQLException, DRDAProtocolException
 	{
-		int numExt = stmt.cliParamExtPositions.size();
-		for (int i = 0; i < stmt.cliParamExtPositions.size(); i++)
-					{
-						int paramPos = ((Integer) (stmt.cliParamExtPositions).get(i)).intValue();
-						readAndSetExtParam(paramPos,
-										   stmt,
-										   ((Byte)stmt.cliParamDrdaTypes.elementAt(paramPos)).intValue(),((Integer)(stmt.cliParamLens.elementAt(paramPos))).intValue());
-						// Each extdta in it's own dss
-						if (i < numExt -1)
-						{
-							correlationID = reader.readDssHeader();
-							int codePoint = reader.readLengthAndCodePoint();
-						}
-					}
-
+        int extCount = 0;
+        final int end = stmt.getNumParams();
+        for (int i = 0; i < end; i++) {
+            final DRDAStatement.CliParam cp = stmt.getCliParam(i);
+            if (cp.isExt == false) continue;
+            
+            // Each extdta in it's own dss, except the first
+            if (extCount > 0) {
+                correlationID = reader.readDssHeader();
+                reader.readLengthAndCodePoint();
+            }
+            ++extCount;
+            readAndSetExtParam(i, stmt, cp.drdaType, cp.drdaLength);
+        }
 	}
 	
 
@@ -7545,4 +7543,298 @@
 
 	}
 
+    /**
+     * Get a the name of the int constant representing a drdaType value. 
+     * This is useful for debugging.  
+     * 
+     * @param drdaType  the drdaType value
+     * @return a string containing the constant name and the value in hex
+     */
+    public static String drdaTypeName(int drdaType) {
+        switch (drdaType) {
+        case DRDAConstants.DRDA_TYPE_INTEGER:
+            return "DRDA_TYPE_INTEGER (0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NINTEGER:
+            return "DRDA_TYPE_NINTEGER(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_SMALL:
+            return "DRDA_TYPE_SMALL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NSMALL:
+            return "DRDA_TYPE_NSMALL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_1BYTE_INT:
+            return "DRDA_TYPE_1BYTE_INT(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_N1BYTE_INT:
+            return "DRDA_TYPE_N1BYTE_INT(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_FLOAT16:
+            return "DRDA_TYPE_FLOAT16(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NFLOAT16:
+            return "DRDA_TYPE_NFLOAT16(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_FLOAT8:
+            return "DRDA_TYPE_FLOAT8(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NFLOAT8:
+            return "DRDA_TYPE_NFLOAT8(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_FLOAT4:
+            return "DRDA_TYPE_FLOAT4(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NFLOAT4:
+            return "DRDA_TYPE_NFLOAT4(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_DECIMAL:
+            return "DRDA_TYPE_DECIMAL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NDECIMAL:
+            return "DRDA_TYPE_NDECIMAL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_ZDECIMAL:
+            return "DRDA_TYPE_ZDECIMAL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NZDECIMAL:
+            return "DRDA_TYPE_NZDECIMAL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NUMERIC_CHAR:
+            return "DRDA_TYPE_NUMERIC_CHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NNUMERIC_CHAR:
+            return "DRDA_TYPE_NNUMERIC_CHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_RSET_LOC:
+            return "DRDA_TYPE_RSET_LOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NRSET_LOC:
+            return "DRDA_TYPE_NRSET_LOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_INTEGER8:
+            return "DRDA_TYPE_INTEGER8(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NINTEGER8:
+            return "DRDA_TYPE_NINTEGER8(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LOBLOC:
+            return "DRDA_TYPE_LOBLOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLOBLOC:
+            return "DRDA_TYPE_NLOBLOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_CLOBLOC:
+            return "DRDA_TYPE_CLOBLOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NCLOBLOC:
+            return "DRDA_TYPE_NCLOBLOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_DBCSCLOBLOC:
+            return "DRDA_TYPE_DBCSCLOBLOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NDBCSCLOBLOC:
+            return "DRDA_TYPE_NDBCSCLOBLOC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_ROWID:
+            return "DRDA_TYPE_ROWID(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NROWID:
+            return "DRDA_TYPE_NROWID(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_DATE:
+            return "DRDA_TYPE_DATE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NDATE:
+            return "DRDA_TYPE_NDATE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_TIME:
+            return "DRDA_TYPE_TIME(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NTIME:
+            return "DRDA_TYPE_NTIME(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_TIMESTAMP:
+            return "DRDA_TYPE_TIMESTAMP(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NTIMESTAMP:
+            return "DRDA_TYPE_NTIMESTAMP(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_FIXBYTE:
+            return "DRDA_TYPE_FIXBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NFIXBYTE:
+            return "DRDA_TYPE_NFIXBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_VARBYTE:
+            return "DRDA_TYPE_VARBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NVARBYTE:
+            return "DRDA_TYPE_NVARBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LONGVARBYTE:
+            return "DRDA_TYPE_LONGVARBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLONGVARBYTE:
+            return "DRDA_TYPE_NLONGVARBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NTERMBYTE:
+            return "DRDA_TYPE_NTERMBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NNTERMBYTE:
+            return "DRDA_TYPE_NNTERMBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_CSTR:
+            return "DRDA_TYPE_CSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NCSTR:
+            return "DRDA_TYPE_NCSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_CHAR:
+            return "DRDA_TYPE_CHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NCHAR:
+            return "DRDA_TYPE_NCHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_VARCHAR:
+            return "DRDA_TYPE_VARCHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NVARCHAR:
+            return "DRDA_TYPE_NVARCHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LONG:
+            return "DRDA_TYPE_LONG(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLONG:
+            return "DRDA_TYPE_NLONG(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_GRAPHIC:
+            return "DRDA_TYPE_GRAPHIC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NGRAPHIC:
+            return "DRDA_TYPE_NGRAPHIC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_VARGRAPH:
+            return "DRDA_TYPE_VARGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NVARGRAPH:
+            return "DRDA_TYPE_NVARGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LONGRAPH:
+            return "DRDA_TYPE_LONGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLONGRAPH:
+            return "DRDA_TYPE_NLONGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_MIX:
+            return "DRDA_TYPE_MIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NMIX:
+            return "DRDA_TYPE_NMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_VARMIX:
+            return "DRDA_TYPE_VARMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NVARMIX:
+            return "DRDA_TYPE_NVARMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LONGMIX:
+            return "DRDA_TYPE_LONGMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLONGMIX:
+            return "DRDA_TYPE_NLONGMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_CSTRMIX:
+            return "DRDA_TYPE_CSTRMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NCSTRMIX:
+            return "DRDA_TYPE_NCSTRMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_PSCLBYTE:
+            return "DRDA_TYPE_PSCLBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NPSCLBYTE:
+            return "DRDA_TYPE_NPSCLBYTE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LSTR:
+            return "DRDA_TYPE_LSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLSTR:
+            return "DRDA_TYPE_NLSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LSTRMIX:
+            return "DRDA_TYPE_LSTRMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLSTRMIX:
+            return "DRDA_TYPE_NLSTRMIX(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_SDATALINK:
+            return "DRDA_TYPE_SDATALINK(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NSDATALINK:
+            return "DRDA_TYPE_NSDATALINK(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_MDATALINK:
+            return "DRDA_TYPE_MDATALINK(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NMDATALINK:
+            return "DRDA_TYPE_NMDATALINK(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LOBBYTES:
+            return "DRDA_TYPE_LOBBYTES(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLOBBYTES:
+            return "DRDA_TYPE_NLOBBYTES(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LOBCSBCS:
+            return "DRDA_TYPE_LOBCSBCS(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLOBCSBCS:
+            return "DRDA_TYPE_NLOBCSBCS(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LOBCDBCS:
+            return "DRDA_TYPE_LOBCDBCS(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLOBCDBCS:
+            return "DRDA_TYPE_NLOBCDBCS(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_LOBCMIXED:
+            return "DRDA_TYPE_LOBCMIXED(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NLOBCMIXED:
+            return "DRDA_TYPE_NLOBCMIXED(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_BOOLEAN:
+            return "DRDA_TYPE_BOOLEAN(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DRDA_TYPE_NBOOLEAN:
+            return "DRDA_TYPE_NBOOLEAN(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_DATE:
+            return "DB2_SQLTYPE_DATE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NDATE:
+            return "DB2_SQLTYPE_NDATE(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_TIME:
+            return "DB2_SQLTYPE_TIME(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NTIME:
+            return "DB2_SQLTYPE_NTIME(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_TIMESTAMP:
+            return "DB2_SQLTYPE_TIMESTAMP(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NTIMESTAMP:
+            return "DB2_SQLTYPE_NTIMESTAMP(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_DATALINK:
+            return "DB2_SQLTYPE_DATALINK(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NDATALINK:
+            return "DB2_SQLTYPE_NDATALINK(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_BLOB:
+            return "DB2_SQLTYPE_BLOB(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NBLOB:
+            return "DB2_SQLTYPE_NBLOB(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_CLOB:
+            return "DB2_SQLTYPE_CLOB(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NCLOB:
+            return "DB2_SQLTYPE_NCLOB(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_DBCLOB:
+            return "DB2_SQLTYPE_DBCLOB(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NDBCLOB:
+            return "DB2_SQLTYPE_NDBCLOB(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_VARCHAR:
+            return "DB2_SQLTYPE_VARCHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NVARCHAR:
+            return "DB2_SQLTYPE_NVARCHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_CHAR:
+            return "DB2_SQLTYPE_CHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NCHAR:
+            return "DB2_SQLTYPE_NCHAR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_LONG:
+            return "DB2_SQLTYPE_LONG(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NLONG:
+            return "DB2_SQLTYPE_NLONG(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_CSTR:
+            return "DB2_SQLTYPE_CSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NCSTR:
+            return "DB2_SQLTYPE_NCSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_VARGRAPH:
+            return "DB2_SQLTYPE_VARGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NVARGRAPH:
+            return "DB2_SQLTYPE_NVARGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_GRAPHIC:
+            return "DB2_SQLTYPE_GRAPHIC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NGRAPHIC:
+            return "DB2_SQLTYPE_NGRAPHIC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_LONGRAPH:
+            return "DB2_SQLTYPE_LONGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NLONGRAPH:
+            return "DB2_SQLTYPE_NLONGRAPH(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_LSTR:
+            return "DB2_SQLTYPE_LSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NLSTR:
+            return "DB2_SQLTYPE_NLSTR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_FLOAT:
+            return "DB2_SQLTYPE_FLOAT(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NFLOAT:
+            return "DB2_SQLTYPE_NFLOAT(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_DECIMAL:
+            return "DB2_SQLTYPE_DECIMAL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NDECIMAL:
+            return "DB2_SQLTYPE_NDECIMAL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_ZONED:
+            return "DB2_SQLTYPE_ZONED(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NZONED:
+            return "DB2_SQLTYPE_NZONED(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_BIGINT:
+            return "DB2_SQLTYPE_BIGINT(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NBIGINT:
+            return "DB2_SQLTYPE_NBIGINT(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_INTEGER:
+            return "DB2_SQLTYPE_INTEGER(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NINTEGER:
+            return "DB2_SQLTYPE_NINTEGER(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_SMALL:
+            return "DB2_SQLTYPE_SMALL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NSMALL:
+            return "DB2_SQLTYPE_NSMALL(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NUMERIC:
+            return "DB2_SQLTYPE_NUMERIC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NNUMERIC:
+            return "DB2_SQLTYPE_NNUMERIC(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_ROWID:
+            return "DB2_SQLTYPE_ROWID(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NROWID:
+            return "DB2_SQLTYPE_NROWID(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_BLOB_LOCATOR:
+            return "DB2_SQLTYPE_BLOB_LOCATOR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NBLOB_LOCATOR:
+            return "DB2_SQLTYPE_NBLOB_LOCATOR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_CLOB_LOCATOR:
+            return "DB2_SQLTYPE_CLOB_LOCATOR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NCLOB_LOCATOR:
+            return "DB2_SQLTYPE_NCLOB_LOCATOR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_DBCLOB_LOCATOR:
+            return "DB2_SQLTYPE_DBCLOB_LOCATOR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NDBCLOB_LOCATOR:
+            return "DB2_SQLTYPE_NDBCLOB_LOCATOR(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_BOOLEAN:
+            return "DB2_SQLTYPE_BOOLEAN(0x" + Integer.toHexString(drdaType) + ")";
+        case DRDAConstants.DB2_SQLTYPE_NBOOLEAN:
+            return "DB2_SQLTYPE_NBOOLEAN(0x" + Integer.toHexString(drdaType) + ")";
+
+        default:
+            return "DRDA_TYPE_UNKNOWN(0x" + Integer.toHexString(drdaType) + ")";
+        }
+    }
 }

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java?rev=371897&r1=371896&r2=371897&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java Tue Jan 24
03:56:16 2006
@@ -90,9 +90,19 @@
 	private int numResultSets = 0;  
 
 	// State for parameter data
-	protected  Vector cliParamDrdaTypes = new Vector();
-	protected Vector cliParamLens = new Vector();
-	protected ArrayList cliParamExtPositions = null;
+    protected static final class CliParam {
+        public CliParam(byte drdaType, int drdaLength) { 
+            this.drdaType = drdaType; 
+            this.drdaLength = drdaLength; 
+        }
+        public byte drdaType;
+        public int  drdaLength;
+        public boolean isExt = false;
+    }
+    private ArrayList cliParams_ = new ArrayList();
+    protected final CliParam getCliParam(int i) { 
+        return (CliParam) cliParams_.get(i); 
+    }
 
 	// Query options  sent on EXCSQLSTT
 	// These the default for ResultSets created for this statement.
@@ -982,10 +992,7 @@
 		outputExpected = false;
 		isCall = false;
 		explicitlyPrepared = false;
-		cliParamDrdaTypes = null;
-		cliParamLens = null;
-		cliParamExtPositions = null;
-
+        cliParams_.clear();
 	}	
 
 	/**
@@ -1061,8 +1068,26 @@
 		
 	}
 
-	
 	/**
+     * Add a parameter. 
+     *
+     * @param drdaType - parameter type
+     * @param drdaLength - parameter length
+     */
+    protected void addParam(byte drdaType, int drdaLength)
+    {
+        cliParams_.add(new CliParam(drdaType, drdaLength));
+    }
+
+    /**
+     * Reset the cliParams ArrayList.
+     *
+     */
+    protected void resetParams() { 
+        cliParams_.clear();
+    }
+        
+    /**
 	 * get parameter DRDAType
 	 *
 	 * @param index - starting with 1
@@ -1070,33 +1095,33 @@
 	 */
 	protected int getParamDRDAType(int index)
 	{
-		
-		return ((Byte)cliParamDrdaTypes.get(index -1)).intValue();
+        return getCliParam(index-1).drdaType;
 	}
 
 
 	/**
-	 * set param  DRDAType
+     * set param DRDAType. Assumes that index is a valid index.
 	 *
 	 * @param index - starting with 1
 	 * @param type
 	 */
-	protected  void setParamDRDAType(int index, byte type)
-	{
-		cliParamDrdaTypes.addElement(new Byte(type));
-		
-	}
+     protected  void setParamDRDAType(int index, byte type)
+     {
+        getCliParam(index-1).drdaType = type;
+     }
+
 	/**
 	 * returns drda length of parameter as sent by client.
-	 * @param index
+     * @param index - starting with 1
 	 * @return data length
 
 	 */
 
 	protected int getParamLen(int index)
 	{
-		return ((Integer) cliParamLens.elementAt(index -1)).intValue();
+        return getCliParam(index-1).drdaLength;
 	}
+
 	/**
 	 *  get parameter precision or DB2 max (31)
 	 *
@@ -1144,7 +1169,7 @@
 	 */
 	protected void  setParamLen(int index, int value)
 	{
-		cliParamLens.add(index -1, new Integer(value));
+        getCliParam(index-1).drdaLength = value;
 	}
 
 	/**
@@ -1152,14 +1177,11 @@
 	 * 
 	 * @return number of parameters
 	 */
-	protected int getNumParams()
-	{
-		if (cliParamDrdaTypes != null)
-			return cliParamDrdaTypes.size();
-		else
-			return 0;
-	}
-	   
+     protected int getNumParams()
+    {
+        return cliParams_.size();
+    }
+    
 	/** 
 	 * get the number of result set columns for the current resultSet
 	 * 
@@ -1635,13 +1657,3 @@
 		return currentDrdaRs.isRSCloseImplicit();
 	}
 }
-
-
-
-
-
-
-
-
-
-



Mime
View raw message