db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1370674 [9/12] - in /db/derby/code/trunk/java/drda/org/apache/derby: drda/ impl/drda/
Date Wed, 08 Aug 2012 06:54:47 GMT
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXAProtocol.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXAProtocol.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXAProtocol.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXAProtocol.java Wed Aug  8 06:54:46 2012
@@ -41,226 +41,226 @@ import org.apache.derby.shared.common.re
 
 class DRDAXAProtocol {
 
-	private DRDAConnThread connThread;
-	private DDMReader reader;
-	private DDMWriter writer;
+    private DRDAConnThread connThread;
+    private DDMReader reader;
+    private DDMWriter writer;
     /** Holds the Xid of the global transaction associated with
       * the corresponding DRDAConnThread (and connection itself). */
     private Xid xid;
 
 
-	DRDAXAProtocol(DRDAConnThread connThread)
-	{
-		this.connThread = connThread;
-		reader = connThread.getReader();
-		writer = connThread.getWriter();
+    DRDAXAProtocol(DRDAConnThread connThread)
+    {
+        this.connThread = connThread;
+        reader = connThread.getReader();
+        writer = connThread.getWriter();
         xid = null;
-	}
+    }
+
+
+
+    /**
+     * Parse SYNCCTL - Parse SYNCCTL command for XAMGR lvl 7
+     *
+     */
+    protected void parseSYNCCTL() throws DRDAProtocolException
+    {
+        
+        reader.markCollection();
+        
+        int codePoint = reader.getCodePoint(CodePoint.SYNCTYPE);
+        int syncType = parseSYNCTYPE();
+        
+        int xaflags = 0;
+        boolean readXAFlags = false;
+        Xid xid = null;
+        // The value -1 means no value of timeout received
+        long xaTimeout = -1;
+        boolean readXATimeout = false;
+
+        codePoint = reader.getCodePoint();
+        while (codePoint != -1)
+        {
+            switch(codePoint)
+            {
+                case CodePoint.XID:
+                    xid = parseXID();
+                    break;                    
+                case CodePoint.XAFLAGS:
+                    xaflags = parseXAFlags();                    
+                    readXAFlags =true;
+                    break;
+                case CodePoint.TIMEOUT:
+                    xaTimeout = parseXATimeout();
+                    readXATimeout = true;
+                    break;
+                case CodePoint.RLSCONV:
+                    connThread.codePointNotSupported(codePoint);      
+                default:
+                    connThread.invalidCodePoint(codePoint);
+            }
+
+            codePoint = reader.getCodePoint();
+        }
+
+
+        {
+            connThread.trace("syncType = " + syncTypeToString(syncType));
+            connThread.trace("xid = " + xid);
+            connThread.trace("xaflags =" + xaflagsToString(xaflags));
+        }
+
+        if (syncType != CodePoint.SYNCTYPE_INDOUBT)
+        {
+            if (xid == null)
+                connThread.missingCodePoint(CodePoint.XID);
+            
+            // All but Recover and forget require xaFlags
+            if (syncType != CodePoint.SYNCTYPE_REQ_FORGET && 
+                ! readXAFlags)
+                if (SanityManager.DEBUG)
+                    connThread.missingCodePoint(CodePoint.XAFLAGS);
+        }
+
+        switch (syncType)
+        {  
+            case CodePoint.SYNCTYPE_NEW_UOW:
+                // new unit of work for XA
+                // formatId -1 is just a local connection
+                startXATransaction(xid, xaflags, xaTimeout);
+                break;
+            case CodePoint.SYNCTYPE_END_UOW:
+                // End unit of work
+                endXA(xid,xaflags);
+                break;
+            case CodePoint.SYNCTYPE_PREPARE:
+                prepareXATransaction(xid);
+                // Prepare to commit 
+                break;
+            case CodePoint.SYNCTYPE_MIGRATE:
+                // migrate to resync server sync type
+                connThread.codePointNotSupported(codePoint);                
+                break;            
+            case CodePoint.SYNCTYPE_REQ_COMMIT:
+                // request to commit sync type
+                commitTransaction(xid,xaflags);
+                break;
+            case CodePoint.SYNCTYPE_COMMITTED:
+                // commit  sync type
+                commitTransaction(xid, xaflags);
+                break;
+            case CodePoint.SYNCTYPE_REQ_FORGET:
+                // request to forget sync type
+                forgetXATransaction(xid);
+                break;
+            case CodePoint.SYNCTYPE_ROLLBACK:
+                //rollback sync type
+                rollbackTransaction(xid, true);
+                break;
+            case CodePoint.SYNCTYPE_INDOUBT:
+                //recover sync type
+                if (readXAFlags)
+                    recoverXA(xaflags);
+                else
+                    recoverXA();
+                break;
+            default:
+                connThread.invalidCodePoint(codePoint);
+         }
+
+    }
+
+    /** 
+     * parse SYNCTYPE for XAMGR lvl 7
+     * return synctype value 
+     *   CodePoint.SYNCTYPE_NEW_UOW -> XAResource.start()
+     *   CodePoint.SYNCTYPE_END_UOW -> XAResource.end()
+     *   CodePoint.SYNCTYPE_PREPARE -> XAResource.prepare()
+     *   CodePoint.SYNCTYPE_MIGRATE -> not supported  //SYNCPT MGR LEVEL 5
+     *   CodePoint.SYNCTYPE_REQ_COMMIT -> not supported //SYNCPT MGR LEVEL 5
+     *   CodePoint.SYNCTYPE_COMMITTED -> XAResource.commit()  
+     *                                   or local commit for null XID
+     *   CodePoint.SYNCTYPE_REQ_LOG ->  not supported
+     *   CodePoint.SYNCTYPE_REQ_FORGET -> XAResource.forget()
+     *   CodePoint.SYNCTYPE_ROLLBACK -> XAResource.rollback()
+     *   CodePoint.SYNCTYPE_MIGRATED -> not supported
+     *   CodePoint.SYNCTYPE_INDOUBT   -> XAResource.recover();
+     * 
+     */     
+    protected int  parseSYNCTYPE() throws DRDAProtocolException
+    {
+        return reader.readUnsignedByte();
+        
+    }
+    
+
+    /** Parse XID
+     *  formatId -1 translates into a null XID and a local transaction
+     */
+    private  Xid parseXID () throws DRDAProtocolException
+    {
+        int formatId = reader.readNetworkInt();
+        byte[] gtrid = null;
+        byte[] bqual = null;
+        if (formatId != -1)
+        {
+            int gtridLen = reader.readNetworkInt();
+            int bqualLen = reader.readNetworkInt();
+            
+            gtrid = reader.readBytes(gtridLen);
+            bqual = reader.readBytes(bqualLen);
+        }
+        return new DRDAXid(formatId, gtrid, bqual);
+    }
 
+    /** 
+     *  parse XAFlags 
+     *
+     * @return XAFlags value
+     * @throws DRDAProtocolException
+     */
+    private int parseXAFlags() throws DRDAProtocolException
+    {
+        return reader.readNetworkInt();
+    }
 
+    /**
+     * Parses a XA transaction timout value.
+     *
+     * @return A timeout value.
+     * @throws DRDAProtocolException
+     */
+    private long parseXATimeout() throws DRDAProtocolException
+    {
+        return reader.readNetworkLong();
+    }
 
-	/**
-	 * Parse SYNCCTL - Parse SYNCCTL command for XAMGR lvl 7
-	 *
-	 */
-	protected void parseSYNCCTL() throws DRDAProtocolException
-	{
-		
-		reader.markCollection();
-		
-		int codePoint = reader.getCodePoint(CodePoint.SYNCTYPE);
-		int syncType = parseSYNCTYPE();
-		
-		int xaflags = 0;
-		boolean readXAFlags = false;
-		Xid xid = null;
-		// The value -1 means no value of timeout received
-		long xaTimeout = -1;
-		boolean readXATimeout = false;
-
-		codePoint = reader.getCodePoint();
-		while (codePoint != -1)
-		{
-			switch(codePoint)
-			{
-				case CodePoint.XID:
-					xid = parseXID();
-					break;					
-				case CodePoint.XAFLAGS:
-					xaflags = parseXAFlags();					
-					readXAFlags =true;
-					break;
-				case CodePoint.TIMEOUT:
-					xaTimeout = parseXATimeout();
-					readXATimeout = true;
-					break;
-				case CodePoint.RLSCONV:
-					connThread.codePointNotSupported(codePoint);	  
-				default:
-					connThread.invalidCodePoint(codePoint);
-			}
-
-			codePoint = reader.getCodePoint();
-		}
-
-
-		{
-			connThread.trace("syncType = " + syncTypeToString(syncType));
-			connThread.trace("xid = " + xid);
-			connThread.trace("xaflags =" + xaflagsToString(xaflags));
-		}
-
-		if (syncType != CodePoint.SYNCTYPE_INDOUBT)
-		{
-			if (xid == null)
-				connThread.missingCodePoint(CodePoint.XID);
-			
-			// All but Recover and forget require xaFlags
-			if (syncType != CodePoint.SYNCTYPE_REQ_FORGET && 
-				! readXAFlags)
-				if (SanityManager.DEBUG)
-					connThread.missingCodePoint(CodePoint.XAFLAGS);
-		}
-
-		switch (syncType)
-		{  
-			case CodePoint.SYNCTYPE_NEW_UOW:
-				// new unit of work for XA
-				// formatId -1 is just a local connection
-				startXATransaction(xid, xaflags, xaTimeout);
-				break;
-			case CodePoint.SYNCTYPE_END_UOW:
-				// End unit of work
-				endXA(xid,xaflags);
-				break;
-			case CodePoint.SYNCTYPE_PREPARE:
-				prepareXATransaction(xid);
-				// Prepare to commit 
-				break;
-			case CodePoint.SYNCTYPE_MIGRATE:
-				// migrate to resync server sync type
-				connThread.codePointNotSupported(codePoint);				
-				break;			
-			case CodePoint.SYNCTYPE_REQ_COMMIT:
-				// request to commit sync type
-				commitTransaction(xid,xaflags);
-				break;
-			case CodePoint.SYNCTYPE_COMMITTED:
-				// commit  sync type
-				commitTransaction(xid, xaflags);
-				break;
-			case CodePoint.SYNCTYPE_REQ_FORGET:
-				// request to forget sync type
-				forgetXATransaction(xid);
-				break;
-			case CodePoint.SYNCTYPE_ROLLBACK:
-				//rollback sync type
-				rollbackTransaction(xid, true);
-				break;
-			case CodePoint.SYNCTYPE_INDOUBT:
-				//recover sync type
-				if (readXAFlags)
-					recoverXA(xaflags);
-				else
-					recoverXA();
-				break;
-			default:
-				connThread.invalidCodePoint(codePoint);
- 		}
-
-	}
-
-	/** 
-	 * parse SYNCTYPE for XAMGR lvl 7
-	 * return synctype value 
-	 *   CodePoint.SYNCTYPE_NEW_UOW -> XAResource.start()
-	 *   CodePoint.SYNCTYPE_END_UOW -> XAResource.end()
-	 *   CodePoint.SYNCTYPE_PREPARE -> XAResource.prepare()
-	 *   CodePoint.SYNCTYPE_MIGRATE -> not supported  //SYNCPT MGR LEVEL 5
-	 *   CodePoint.SYNCTYPE_REQ_COMMIT -> not supported //SYNCPT MGR LEVEL 5
-	 *   CodePoint.SYNCTYPE_COMMITTED -> XAResource.commit()  
-	 *                                   or local commit for null XID
-	 *   CodePoint.SYNCTYPE_REQ_LOG ->  not supported
-	 *   CodePoint.SYNCTYPE_REQ_FORGET -> XAResource.forget()
-	 *   CodePoint.SYNCTYPE_ROLLBACK -> XAResource.rollback()
-	 *   CodePoint.SYNCTYPE_MIGRATED -> not supported
-	 *   CodePoint.SYNCTYPE_INDOUBT   -> XAResource.recover();
-	 * 
-	 */	 
-	protected int  parseSYNCTYPE() throws DRDAProtocolException
-	{
-		return reader.readUnsignedByte();
-		
-	}
-	
-
-	/** Parse XID
-	 *  formatId -1 translates into a null XID and a local transaction
-	 */
-	private  Xid parseXID () throws DRDAProtocolException
-	{
-		int formatId = reader.readNetworkInt();
-		byte[] gtrid = null;
-		byte[] bqual = null;
-		if (formatId != -1)
-		{
-			int gtridLen = reader.readNetworkInt();
-			int bqualLen = reader.readNetworkInt();
-			
-			gtrid = reader.readBytes(gtridLen);
-			bqual = reader.readBytes(bqualLen);
-		}
-		return new DRDAXid(formatId, gtrid, bqual);
-	}
-
-	/** 
-	 *  parse XAFlags 
-	 *
-	 * @return XAFlags value
-	 * @throws DRDAProtocolException
-	 */
-	private int parseXAFlags() throws DRDAProtocolException
-	{
-		return reader.readNetworkInt();
-	}
-
-	/**
-	 * Parses a XA transaction timout value.
-	 *
-	 * @return A timeout value.
-	 * @throws DRDAProtocolException
-	 */
-	private long parseXATimeout() throws DRDAProtocolException
-	{
-		return reader.readNetworkLong();
-	}
-
-
-	/**
-	 *  Start the xa transaction. Send SYNCRRD response
-	 * 
-	 *  @param xid - XID (formatId = -1 for local transaction)
-	 *  @param xaflags - xaflags
-	 *  @param xaTimeout - The timeout for the global transaction in millis
+
+    /**
+     *  Start the xa transaction. Send SYNCRRD response
+     * 
+     *  @param xid - XID (formatId = -1 for local transaction)
+     *  @param xaflags - xaflags
+     *  @param xaTimeout - The timeout for the global transaction in millis
      *                     (or -1 if not specified)
-	 *  @throws DRDAProtocolException
-	 */
-	private void startXATransaction(Xid xid, int xaflags, long xaTimeout)
-												throws DRDAProtocolException
-	{
-		XAResource xaResource = getXAResource();
-		int xaRetVal = XAResource.XA_OK;
-
-		try {
-			if (xid.getFormatId() == -1 && xaTimeout != -1) {
-				// The value of timeout might be specified only for global transactions
-				throw new XAException(XAException.XAER_PROTO);
-			} else if (xaTimeout != -1 && xaflags != XAResource.TMNOFLAGS) {
-				// According the DRDA spec if the value of timeout was specified
-				// a TMNOFLAGS have to be used
-				throw new XAException(XAException.XAER_PROTO);
-			} else {
-				if (xaTimeout == 0) {
+     *  @throws DRDAProtocolException
+     */
+    private void startXATransaction(Xid xid, int xaflags, long xaTimeout)
+                                                throws DRDAProtocolException
+    {
+        XAResource xaResource = getXAResource();
+        int xaRetVal = XAResource.XA_OK;
+
+        try {
+            if (xid.getFormatId() == -1 && xaTimeout != -1) {
+                // The value of timeout might be specified only for global transactions
+                throw new XAException(XAException.XAER_PROTO);
+            } else if (xaTimeout != -1 && xaflags != XAResource.TMNOFLAGS) {
+                // According the DRDA spec if the value of timeout was specified
+                // a TMNOFLAGS have to be used
+                throw new XAException(XAException.XAER_PROTO);
+            } else {
+                if (xaTimeout == 0) {
                     // According the DRDA specification
                     // value 0 means the unlimited timeout
                     // Integer.MAX_VALUE is used in derby
@@ -268,447 +268,447 @@ class DRDAXAProtocol {
                     // In JDBC spec the value 0 means the resource
                     // manager's default value.
                     xaResource.setTransactionTimeout(Integer.MAX_VALUE);
-				} else if (xaTimeout == -1) {
+                } else if (xaTimeout == -1) {
                     // The timeout value was not specified, so use the default
                     // timeout - see javadoc for XAResource.setTransactionTimeout
-					xaResource.setTransactionTimeout(0);
+                    xaResource.setTransactionTimeout(0);
                 } else {
                     // The value of timeout was specified
                     xaResource.setTransactionTimeout((int) (xaTimeout/1000));
                 }
-				if (xid.getFormatId() != -1) {
-					xaResource.start(xid,xaflags);
-				}
-            	this.xid = xid;
-			}
-		} catch (XAException xe)
-		{
-			xaRetVal = processXAException(xe);
-		}
-		writeSYNCCRD(CodePoint.SYNCTYPE_NEW_UOW, 
-					 xaRetVal, null);
-		
-	}
-	
-
-	/**
-	 *  Commit  the xa transaction. Send SYNCCRD response
-	 * 
-	 *  @param xid - XID (formatId = -1 for local transaction)
-	 *  @param xaflags - xaflags
-	 *  @throws DRDAProtocolException
-	 */
-	private void commitTransaction(Xid xid, int xaflags) throws DRDAProtocolException
-	{
-		boolean local  = ( xid.getFormatId() == -1);
-		if (local)
-			commitLocalTransaction();
-		else
-			commitXATransaction(xid, xaflags);
-	}
-
-	/**
-	 *  Commit local transaction. Send SYNCCRD response.
-	 * 
-	 *  @throws DRDAProtocolException
-	 */	   
-	private void commitLocalTransaction() throws DRDAProtocolException
-	{
-		int xaRetVal = XAResource.XA_OK;
-		try {
-			connThread.getDatabase().commit();
-		}
-		catch  (Exception e)
-		{
-			xaRetVal = XAException.XAER_RMFAIL;
-			if (SanityManager.DEBUG)
-			{
-				connThread.getServer().consoleExceptionPrint(e);
-			}
-
-		}
-		writeSYNCCRD(CodePoint.SYNCTYPE_COMMITTED, 
-					 xaRetVal, null);
-
-	}
-
-	
-	/**
-	 *  Commit  the xa transaction. Send SYNCCRD response.
-	 * 
-	 *  @param xid - XID 
-	 *  @param xaflags - xaflags
-	 *  @throws DRDAProtocolException
-	 */
-	private void commitXATransaction(Xid xid, int xaflags) throws DRDAProtocolException
-	{
-		XAResource xaResource = getXAResource();
-		int xaRetVal = XAResource.XA_OK;
-		// check this
-		boolean isOnePhase = (xaflags & XAResource.TMONEPHASE) != 0;
-		try {
-			xaResource.commit(xid, isOnePhase);
-			if (SanityManager.DEBUG)
-				connThread.trace("committed XA transaction: xaRetVal=" + xaRetVal);
-
-		} catch (XAException xe)
-		{
-			xaRetVal = processXAException(xe);
-		}
-		writeSYNCCRD(CodePoint.SYNCTYPE_COMMITTED, 
-					 xaRetVal, null);
-		
-	}
-
-	/**
-	 * Rollback transaction. Optionally send SYNCCRD response.
-	 * @param xid  Xid for rollback for global transaction.
-	 *             If xid formatid is -1 it represents a local transaction
+                if (xid.getFormatId() != -1) {
+                    xaResource.start(xid,xaflags);
+                }
+                this.xid = xid;
+            }
+        } catch (XAException xe)
+        {
+            xaRetVal = processXAException(xe);
+        }
+        writeSYNCCRD(CodePoint.SYNCTYPE_NEW_UOW, 
+                     xaRetVal, null);
+        
+    }
+    
+
+    /**
+     *  Commit  the xa transaction. Send SYNCCRD response
+     * 
+     *  @param xid - XID (formatId = -1 for local transaction)
+     *  @param xaflags - xaflags
+     *  @throws DRDAProtocolException
+     */
+    private void commitTransaction(Xid xid, int xaflags) throws DRDAProtocolException
+    {
+        boolean local  = ( xid.getFormatId() == -1);
+        if (local)
+            commitLocalTransaction();
+        else
+            commitXATransaction(xid, xaflags);
+    }
+
+    /**
+     *  Commit local transaction. Send SYNCCRD response.
+     * 
+     *  @throws DRDAProtocolException
+     */       
+    private void commitLocalTransaction() throws DRDAProtocolException
+    {
+        int xaRetVal = XAResource.XA_OK;
+        try {
+            connThread.getDatabase().commit();
+        }
+        catch  (Exception e)
+        {
+            xaRetVal = XAException.XAER_RMFAIL;
+            if (SanityManager.DEBUG)
+            {
+                connThread.getServer().consoleExceptionPrint(e);
+            }
+
+        }
+        writeSYNCCRD(CodePoint.SYNCTYPE_COMMITTED, 
+                     xaRetVal, null);
+
+    }
+
+    
+    /**
+     *  Commit  the xa transaction. Send SYNCCRD response.
+     * 
+     *  @param xid - XID 
+     *  @param xaflags - xaflags
+     *  @throws DRDAProtocolException
+     */
+    private void commitXATransaction(Xid xid, int xaflags) throws DRDAProtocolException
+    {
+        XAResource xaResource = getXAResource();
+        int xaRetVal = XAResource.XA_OK;
+        // check this
+        boolean isOnePhase = (xaflags & XAResource.TMONEPHASE) != 0;
+        try {
+            xaResource.commit(xid, isOnePhase);
+            if (SanityManager.DEBUG)
+                connThread.trace("committed XA transaction: xaRetVal=" + xaRetVal);
+
+        } catch (XAException xe)
+        {
+            xaRetVal = processXAException(xe);
+        }
+        writeSYNCCRD(CodePoint.SYNCTYPE_COMMITTED, 
+                     xaRetVal, null);
+        
+    }
+
+    /**
+     * Rollback transaction. Optionally send SYNCCRD response.
+     * @param xid  Xid for rollback for global transaction.
+     *             If xid formatid is -1 it represents a local transaction
      * @param sendSYNCCRD Indicates whether the function should
      *                    send a SYNCCRD response
-	 */
-	private void rollbackTransaction(Xid xid, boolean sendSYNCCRD) throws DRDAProtocolException
-	{
-		boolean local  = ( xid.getFormatId() == -1);
-		if (local)
-			rollbackLocalTransaction(sendSYNCCRD);
-		else
-			rollbackXATransaction(xid, sendSYNCCRD);
-	}
-	
-	/**
-	 * Rollback a local transaction. Optionally send SYNCCRD response.
-	 *
+     */
+    private void rollbackTransaction(Xid xid, boolean sendSYNCCRD) throws DRDAProtocolException
+    {
+        boolean local  = ( xid.getFormatId() == -1);
+        if (local)
+            rollbackLocalTransaction(sendSYNCCRD);
+        else
+            rollbackXATransaction(xid, sendSYNCCRD);
+    }
+    
+    /**
+     * Rollback a local transaction. Optionally send SYNCCRD response.
+     *
      * @param sendSYNCCRD Indicates whether the function should
      *                    send a SYNCCRD response
-	 * @throws DRDAProtocolException
-	 */
-	private void rollbackLocalTransaction(boolean sendSYNCCRD) throws DRDAProtocolException
-	{
-		int xaRetVal = XAResource.XA_OK;
-		try {
-			connThread.getDatabase().rollback();
-		}
-		catch  (Exception e)
-		{
-			xaRetVal = XAException.XAER_RMFAIL;
-			if (SanityManager.DEBUG)
-			{
-				connThread.getServer().consoleExceptionPrint(e);
-			}
-			
-		}
+     * @throws DRDAProtocolException
+     */
+    private void rollbackLocalTransaction(boolean sendSYNCCRD) throws DRDAProtocolException
+    {
+        int xaRetVal = XAResource.XA_OK;
+        try {
+            connThread.getDatabase().rollback();
+        }
+        catch  (Exception e)
+        {
+            xaRetVal = XAException.XAER_RMFAIL;
+            if (SanityManager.DEBUG)
+            {
+                connThread.getServer().consoleExceptionPrint(e);
+            }
+            
+        }
         if (sendSYNCCRD) {
             writeSYNCCRD(CodePoint.SYNCTYPE_COMMITTED,
                          xaRetVal, null);
         }
-	}
+    }
 
-	/**
-	 *  Rollback the xa transaction. Optionally send SYNCCRD response.
-	 * 
-	 *  @param xid - XID 
+    /**
+     *  Rollback the xa transaction. Optionally send SYNCCRD response.
+     * 
+     *  @param xid - XID 
      *  @param sendSYNCCRD Indicates whether the function should
      *                     send a SYNCCRD response
-	 *  @throws DRDAProtocolException
-	 */
-	private void rollbackXATransaction(Xid xid, boolean sendSYNCCRD) throws DRDAProtocolException
-	{
-		XAResource xaResource = getXAResource();
-		int xaRetVal = XAResource.XA_OK;
-
-		try {
-			xaResource.rollback(xid);
-			if (SanityManager.DEBUG)
-			{
-				connThread.trace("rollback  XA transaction: xaRetVal=" + xaRetVal); 
-			}
-		} catch (XAException xe)
-		{
-			xaRetVal = processXAException(xe);
-		}
+     *  @throws DRDAProtocolException
+     */
+    private void rollbackXATransaction(Xid xid, boolean sendSYNCCRD) throws DRDAProtocolException
+    {
+        XAResource xaResource = getXAResource();
+        int xaRetVal = XAResource.XA_OK;
+
+        try {
+            xaResource.rollback(xid);
+            if (SanityManager.DEBUG)
+            {
+                connThread.trace("rollback  XA transaction: xaRetVal=" + xaRetVal); 
+            }
+        } catch (XAException xe)
+        {
+            xaRetVal = processXAException(xe);
+        }
         if (sendSYNCCRD) {
             writeSYNCCRD(CodePoint.SYNCTYPE_ROLLBACK,
                          xaRetVal, null);
         }
-	}
+    }
 
-	/**
-	 *  End  the xa transaction. Send SYNCRRD response
-	 * 
-	 *  @param xid - XID 
-	 *  @param xaflags - xaflags
-	 *  @throws DRDAProtocolException
-	 */
-	private void endXA(Xid xid, int xaflags) throws DRDAProtocolException
-	{
-		XAResource xaResource = getXAResource();		
-		int xaRetVal = XAResource.XA_OK;
+    /**
+     *  End  the xa transaction. Send SYNCRRD response
+     * 
+     *  @param xid - XID 
+     *  @param xaflags - xaflags
+     *  @throws DRDAProtocolException
+     */
+    private void endXA(Xid xid, int xaflags) throws DRDAProtocolException
+    {
+        XAResource xaResource = getXAResource();        
+        int xaRetVal = XAResource.XA_OK;
 
-		try {
-			xaResource.end(xid,xaflags);
+        try {
+            xaResource.end(xid,xaflags);
             this.xid = null;
-			if (SanityManager.DEBUG)
-			{
-				connThread.trace("ended XA transaction. xid =  " + xid +
-							   " xaflags =" + xaflags + 
-								 "xaRetVal=" + xaRetVal); 
-			}
-		} catch (XAException xe)
-		{
-			xaRetVal = processXAException(xe);
-		}
-		writeSYNCCRD(CodePoint.SYNCTYPE_END_UOW,
-					 xaRetVal, null);		
-	}
-
-
-	/**
-	 *  Prepare the xa transaction. Send SYNCCRD response.
-	 * 
-	 *  @param xid - XID 
-	 *  @throws DRDAProtocolException
-	 */
-	private void prepareXATransaction(Xid xid) throws DRDAProtocolException
-	{
-		XAResource xaResource = getXAResource();
-		int xaRetVal;
-
-		try {
-			xaRetVal = xaResource.prepare(xid);
-			if (SanityManager.DEBUG)
-			{
-				connThread.trace("prepared xa transaction: xaRetVal=" +
-								xaRetVal); 
-			}
-		} catch (XAException xe)
-		{			
-			xaRetVal = processXAException(xe);
-		}
-		writeSYNCCRD(CodePoint.SYNCTYPE_PREPARE,
-					 xaRetVal, null);		
-	}
-
-	/**
-	 *  Forget the xa transaction. Send SYNCCRD response.
-	 * 
-	 *  @param xid - XID 
-	 *  @throws DRDAProtocolException
-	 */
-	private void forgetXATransaction(Xid xid) throws DRDAProtocolException
-	{
-		XAResource xaResource = getXAResource();
-		int xaRetVal = XAResource.XA_OK;
-
-		try {
-			xaResource.forget(xid);
-			if (SanityManager.DEBUG)
-			{
-				connThread.trace("forgot xa transaction: xaRetVal=" + xaRetVal);
-			}
-		} catch (XAException xe)
-		{
-			xaRetVal = processXAException(xe);
-		}
-		writeSYNCCRD(CodePoint.SYNCTYPE_REQ_FORGET,
-					 xaRetVal, null);		
-	}
-
-	// JCC doesn't send xaflags but always wants TMSTARTRSCAN.  
-	//So default to that if we got no xaflags
-	private void recoverXA() throws DRDAProtocolException
-	{
-		recoverXA(XAResource.TMSTARTRSCAN);
-	}
-
-	/**
-	 * Call recover. Send SYNCCRD response with indoubt list
-	 * 
-	 *  @throws DRDAProtocolException
-	 */
-	private void recoverXA(int xaflags) throws DRDAProtocolException
-	{
-		XAResource xaResource = getXAResource();
-		int xaRetVal = XAResource.XA_OK;
-		Xid[] indoubtXids = null;
-		try {
-			indoubtXids = xaResource.recover(xaflags);
-		} catch (XAException xe)
-		{
-			xaRetVal = processXAException(xe);
-		}
-		writeSYNCCRD(CodePoint.SYNCTYPE_INDOUBT,
-					 xaRetVal, indoubtXids);		
-	}
-
-	/** Write SYNCCRD (SYNCCTL response)
-	 * @param synctype - XA Command to send response for see  parseSYNCTYPE
-	 * @param xaRetVal - return value from XA command
-	 * @param xids - list of xids to return for recover. 
-	 *               null for other commands
-	 * @throws DRDAProtocolException
-	 */
-	private void writeSYNCCRD (int synctype, int xaRetVal, Xid[] xids) throws DRDAProtocolException
-	{
-		writer.createDssReply();
-		writer.startDdm(CodePoint.SYNCCRD);
-		writer.startDdm(CodePoint.XARETVAL);
-		writer.writeInt(xaRetVal);
-		writer.endDdm();
-		if (xids != null)
-			writePRPHRCLST(xids);
-		writer.endDdmAndDss();
-	}
-
-	/** write PRPHRCLST (indoubt list)
-	 * 
-	 * @param xids - list of indoubt xa transactions obtained from recover
-	 * @throws DRDAProtocolException
-	 */
-	private void writePRPHRCLST(Xid[] xids) throws DRDAProtocolException
-	{
-		int xidcnt = (xids == null ? 0 : xids.length);
-		writer.startDdm(CodePoint.PRPHRCLST);
-		writer.writeScalar2Bytes(CodePoint.XIDCNT, xidcnt);
-		for (int i = 0; i < xidcnt; i++)
-			writeXID(xids[i]);
-		writer.endDdm();
-	}
-
-	/** write XID
-	 * 
-	 * @param xid - XID to write
-	 * @throws DRDAProtocolException
-	 */
-	
-	private void writeXID(Xid xid) throws DRDAProtocolException
-	{
-		writer.startDdm(CodePoint.XID);
-		int formatId = xid.getFormatId();
-		byte[] gtrid = xid.getGlobalTransactionId();
-		byte[] bqual = xid.getBranchQualifier();
-		
-		writer.writeInt(formatId);
-		writer.writeInt(gtrid.length);
-		writer.writeInt(bqual.length);
-		writer.writeBytes(gtrid);
-		writer.writeBytes(bqual);
-		writer.endDdm();
-	}
-	
-
-	/** get XAResource for the connection
-	 *
-	 * @return XAResource
-	 */
-	private XAResource getXAResource()
-	{
-		return ((XADatabase) connThread.getDatabase()).getXAResource();
-		
-	}
-	
-	/** printable syncType for debug output
-	 * @param syncType
-	 * @return - sync type meaning
-	 */
-	private String syncTypeToString(int syncType)
-	{
-		switch (syncType)
-		{  
-			case CodePoint.SYNCTYPE_NEW_UOW:
-				return "SYNCTYPE_NEW_UOW";
-				
-			case CodePoint.SYNCTYPE_END_UOW:
-				return "SYNCTYPE_END_UOW";
-				
-			case CodePoint.SYNCTYPE_PREPARE:
-				return "SYNCTYPE_PREPARE";
-				
-			case CodePoint.SYNCTYPE_MIGRATE:
-				return "SYNCTYPE_MIGRATE";
-							
-			case CodePoint.SYNCTYPE_REQ_COMMIT:
-				return "SYNCTYPE_REQ_COMMIT";
-				
-			case CodePoint.SYNCTYPE_COMMITTED:
-				return "SYNCTYPE_COMMITTED";
-				
-			case CodePoint.SYNCTYPE_REQ_FORGET:
-				return "SYNCTYPE_FORGET";
-				
-			case CodePoint.SYNCTYPE_ROLLBACK:
-				return "SYNCTYPE_ROLLBACK";
-				
-			case CodePoint.SYNCTYPE_REQ_LOG:
-				return "SYNCTYPE_REQ_LOG";
-				
-			case   CodePoint.SYNCTYPE_MIGRATED:
-				return "SYNCTYPE_MIGRATED";
-				
-			case CodePoint.SYNCTYPE_INDOUBT:
-				return "SYNCTYPE_INDOUBT";
-				
-			default:
-				return "UNKNOWN SYNCTYPE";
- 		}
-	}
-
-	/** 
-	 * printable xaflags
-	 * @param xaflags
-	 * @return printable xaflags for debug output
-	 */
-	private String xaflagsToString(int xaflags)
-	{
-		switch (xaflags)
-		{
-			case XAResource.TMENDRSCAN :
-				return "XAResource.TMENDRSCAN";
-				
-			case XAResource.TMFAIL:
-				return "XAResource.TMFAIL";
-				
-			case XAResource.TMNOFLAGS:
-				return "XAResource.TMNOFLAGS";
-				
-			case XAResource.TMJOIN:
-				return "XAResource.TMJOIN";
-				
-			case XAResource.TMONEPHASE:
-				return "XAResource.TMONEPHASE";
-				
-			case XAResource.TMRESUME:
-				return "XAResource.TMRESUME";
-				
-			case XAResource.TMSTARTRSCAN:
-				return "XAResource.TMSTARTRSCAN";
-				
-			case XAResource.TMSUCCESS:
-				return "XAResource.TMSUCCESS";
-				
-			case XAResource.TMSUSPEND:
-				return "XAResource.TMSUSPEND";
-				
-			default:
-				return "UNRECOGNIZED flags:" + xaflags;
-				
-		}
-	}
-
-	/** 
-	 * return xa exception errorCode.
-	 * print to console for debug output.
-	 * @param xe - XA Exception
-	 */
-	private int processXAException(XAException xe)
-	{
-		int xaRetVal = xe.errorCode;
-		if (SanityManager.DEBUG)
-		{
-			connThread.getServer().consoleExceptionPrint(xe);
-		}
-		return xaRetVal;
-	}
+            if (SanityManager.DEBUG)
+            {
+                connThread.trace("ended XA transaction. xid =  " + xid +
+                               " xaflags =" + xaflags + 
+                                 "xaRetVal=" + xaRetVal); 
+            }
+        } catch (XAException xe)
+        {
+            xaRetVal = processXAException(xe);
+        }
+        writeSYNCCRD(CodePoint.SYNCTYPE_END_UOW,
+                     xaRetVal, null);        
+    }
+
+
+    /**
+     *  Prepare the xa transaction. Send SYNCCRD response.
+     * 
+     *  @param xid - XID 
+     *  @throws DRDAProtocolException
+     */
+    private void prepareXATransaction(Xid xid) throws DRDAProtocolException
+    {
+        XAResource xaResource = getXAResource();
+        int xaRetVal;
+
+        try {
+            xaRetVal = xaResource.prepare(xid);
+            if (SanityManager.DEBUG)
+            {
+                connThread.trace("prepared xa transaction: xaRetVal=" +
+                                xaRetVal); 
+            }
+        } catch (XAException xe)
+        {            
+            xaRetVal = processXAException(xe);
+        }
+        writeSYNCCRD(CodePoint.SYNCTYPE_PREPARE,
+                     xaRetVal, null);        
+    }
+
+    /**
+     *  Forget the xa transaction. Send SYNCCRD response.
+     * 
+     *  @param xid - XID 
+     *  @throws DRDAProtocolException
+     */
+    private void forgetXATransaction(Xid xid) throws DRDAProtocolException
+    {
+        XAResource xaResource = getXAResource();
+        int xaRetVal = XAResource.XA_OK;
+
+        try {
+            xaResource.forget(xid);
+            if (SanityManager.DEBUG)
+            {
+                connThread.trace("forgot xa transaction: xaRetVal=" + xaRetVal);
+            }
+        } catch (XAException xe)
+        {
+            xaRetVal = processXAException(xe);
+        }
+        writeSYNCCRD(CodePoint.SYNCTYPE_REQ_FORGET,
+                     xaRetVal, null);        
+    }
+
+    // JCC doesn't send xaflags but always wants TMSTARTRSCAN.  
+    //So default to that if we got no xaflags
+    private void recoverXA() throws DRDAProtocolException
+    {
+        recoverXA(XAResource.TMSTARTRSCAN);
+    }
+
+    /**
+     * Call recover. Send SYNCCRD response with indoubt list
+     * 
+     *  @throws DRDAProtocolException
+     */
+    private void recoverXA(int xaflags) throws DRDAProtocolException
+    {
+        XAResource xaResource = getXAResource();
+        int xaRetVal = XAResource.XA_OK;
+        Xid[] indoubtXids = null;
+        try {
+            indoubtXids = xaResource.recover(xaflags);
+        } catch (XAException xe)
+        {
+            xaRetVal = processXAException(xe);
+        }
+        writeSYNCCRD(CodePoint.SYNCTYPE_INDOUBT,
+                     xaRetVal, indoubtXids);        
+    }
+
+    /** Write SYNCCRD (SYNCCTL response)
+     * @param synctype - XA Command to send response for see  parseSYNCTYPE
+     * @param xaRetVal - return value from XA command
+     * @param xids - list of xids to return for recover. 
+     *               null for other commands
+     * @throws DRDAProtocolException
+     */
+    private void writeSYNCCRD (int synctype, int xaRetVal, Xid[] xids) throws DRDAProtocolException
+    {
+        writer.createDssReply();
+        writer.startDdm(CodePoint.SYNCCRD);
+        writer.startDdm(CodePoint.XARETVAL);
+        writer.writeInt(xaRetVal);
+        writer.endDdm();
+        if (xids != null)
+            writePRPHRCLST(xids);
+        writer.endDdmAndDss();
+    }
+
+    /** write PRPHRCLST (indoubt list)
+     * 
+     * @param xids - list of indoubt xa transactions obtained from recover
+     * @throws DRDAProtocolException
+     */
+    private void writePRPHRCLST(Xid[] xids) throws DRDAProtocolException
+    {
+        int xidcnt = (xids == null ? 0 : xids.length);
+        writer.startDdm(CodePoint.PRPHRCLST);
+        writer.writeScalar2Bytes(CodePoint.XIDCNT, xidcnt);
+        for (int i = 0; i < xidcnt; i++)
+            writeXID(xids[i]);
+        writer.endDdm();
+    }
+
+    /** write XID
+     * 
+     * @param xid - XID to write
+     * @throws DRDAProtocolException
+     */
+    
+    private void writeXID(Xid xid) throws DRDAProtocolException
+    {
+        writer.startDdm(CodePoint.XID);
+        int formatId = xid.getFormatId();
+        byte[] gtrid = xid.getGlobalTransactionId();
+        byte[] bqual = xid.getBranchQualifier();
+        
+        writer.writeInt(formatId);
+        writer.writeInt(gtrid.length);
+        writer.writeInt(bqual.length);
+        writer.writeBytes(gtrid);
+        writer.writeBytes(bqual);
+        writer.endDdm();
+    }
+    
+
+    /** get XAResource for the connection
+     *
+     * @return XAResource
+     */
+    private XAResource getXAResource()
+    {
+        return ((XADatabase) connThread.getDatabase()).getXAResource();
+        
+    }
+    
+    /** printable syncType for debug output
+     * @param syncType
+     * @return - sync type meaning
+     */
+    private String syncTypeToString(int syncType)
+    {
+        switch (syncType)
+        {  
+            case CodePoint.SYNCTYPE_NEW_UOW:
+                return "SYNCTYPE_NEW_UOW";
+                
+            case CodePoint.SYNCTYPE_END_UOW:
+                return "SYNCTYPE_END_UOW";
+                
+            case CodePoint.SYNCTYPE_PREPARE:
+                return "SYNCTYPE_PREPARE";
+                
+            case CodePoint.SYNCTYPE_MIGRATE:
+                return "SYNCTYPE_MIGRATE";
+                            
+            case CodePoint.SYNCTYPE_REQ_COMMIT:
+                return "SYNCTYPE_REQ_COMMIT";
+                
+            case CodePoint.SYNCTYPE_COMMITTED:
+                return "SYNCTYPE_COMMITTED";
+                
+            case CodePoint.SYNCTYPE_REQ_FORGET:
+                return "SYNCTYPE_FORGET";
+                
+            case CodePoint.SYNCTYPE_ROLLBACK:
+                return "SYNCTYPE_ROLLBACK";
+                
+            case CodePoint.SYNCTYPE_REQ_LOG:
+                return "SYNCTYPE_REQ_LOG";
+                
+            case   CodePoint.SYNCTYPE_MIGRATED:
+                return "SYNCTYPE_MIGRATED";
+                
+            case CodePoint.SYNCTYPE_INDOUBT:
+                return "SYNCTYPE_INDOUBT";
+                
+            default:
+                return "UNKNOWN SYNCTYPE";
+         }
+    }
+
+    /** 
+     * printable xaflags
+     * @param xaflags
+     * @return printable xaflags for debug output
+     */
+    private String xaflagsToString(int xaflags)
+    {
+        switch (xaflags)
+        {
+            case XAResource.TMENDRSCAN :
+                return "XAResource.TMENDRSCAN";
+                
+            case XAResource.TMFAIL:
+                return "XAResource.TMFAIL";
+                
+            case XAResource.TMNOFLAGS:
+                return "XAResource.TMNOFLAGS";
+                
+            case XAResource.TMJOIN:
+                return "XAResource.TMJOIN";
+                
+            case XAResource.TMONEPHASE:
+                return "XAResource.TMONEPHASE";
+                
+            case XAResource.TMRESUME:
+                return "XAResource.TMRESUME";
+                
+            case XAResource.TMSTARTRSCAN:
+                return "XAResource.TMSTARTRSCAN";
+                
+            case XAResource.TMSUCCESS:
+                return "XAResource.TMSUCCESS";
+                
+            case XAResource.TMSUSPEND:
+                return "XAResource.TMSUSPEND";
+                
+            default:
+                return "UNRECOGNIZED flags:" + xaflags;
+                
+        }
+    }
+
+    /** 
+     * return xa exception errorCode.
+     * print to console for debug output.
+     * @param xe - XA Exception
+     */
+    private int processXAException(XAException xe)
+    {
+        int xaRetVal = xe.errorCode;
+        if (SanityManager.DEBUG)
+        {
+            connThread.getServer().consoleExceptionPrint(xe);
+        }
+        return xaRetVal;
+    }
 
     /**
      * @return The ResourceAdapter instance for

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXid.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXid.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXid.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAXid.java Wed Aug  8 06:54:46 2012
@@ -29,19 +29,19 @@ import javax.transaction.xa.Xid;
 class DRDAXid implements Xid
 {
 
-	private final int format_id;
-	private final byte[] global_id;
-	private final byte[] branch_id;
+    private final int format_id;
+    private final byte[] global_id;
+    private final byte[] branch_id;
 
 
-	DRDAXid(int formatid, byte[] globalid, byte[] branchid)
-	{
-
-		format_id = formatid;
-		global_id = globalid;
-		branch_id = branchid;
-		
-	}
+    DRDAXid(int formatid, byte[] globalid, byte[] branchid)
+    {
+
+        format_id = formatid;
+        global_id = globalid;
+        branch_id = branchid;
+        
+    }
 
     /**
      * Obtain the format id part of the Xid.
@@ -59,7 +59,7 @@ class DRDAXid implements Xid
      * bytes.
      * <p>
      *
-	 * @return A byte array containing the global transaction identifier.
+     * @return A byte array containing the global transaction identifier.
      **/
     public byte[] getGlobalTransactionId()
     {
@@ -70,48 +70,48 @@ class DRDAXid implements Xid
      * Obtain the transaction branch qualifier part of the Xid in a byte array.
      * <p>
      *
-	 * @return A byte array containing the branch qualifier of the transaction.
+     * @return A byte array containing the branch qualifier of the transaction.
      **/
     public byte[] getBranchQualifier()
     {
         return(branch_id);
     }
 
-	public String toString()
-	{
-		
-	   String s =  "{DRDAXid: " +
-		   "formatId("     + format_id   + "), " +
-		   "globalTransactionId(" +  convertToHexString(global_id) + ")" +
-		   "branchQualifier(" +  convertToHexString(branch_id) + ")";
-	   return s;
-	}
-
-
-	/**
-	 * convert byte array to a Hex string
-	 * 
-	 * @param buf buffer to  convert
-	 * @return hex string representation of byte array
-	 */
-	private static String convertToHexString(byte [] buf)
-	{
-		if (buf == null)
-			return null;
-		StringBuffer str = new StringBuffer();
-		str.append("0x");
-		String val;
-		int byteVal;
-		for (int i = 0; i < buf.length; i++)
-		{
-			byteVal = buf[i] & 0xff;
-			val = Integer.toHexString(byteVal);
-			if (val.length() < 2)
-				str.append("0");
-			str.append(val);
-		}
-		return str.toString();
-	}
+    public String toString()
+    {
+        
+       String s =  "{DRDAXid: " +
+           "formatId("     + format_id   + "), " +
+           "globalTransactionId(" +  convertToHexString(global_id) + ")" +
+           "branchQualifier(" +  convertToHexString(branch_id) + ")";
+       return s;
+    }
+
+
+    /**
+     * convert byte array to a Hex string
+     * 
+     * @param buf buffer to  convert
+     * @return hex string representation of byte array
+     */
+    private static String convertToHexString(byte [] buf)
+    {
+        if (buf == null)
+            return null;
+        StringBuffer str = new StringBuffer();
+        str.append("0x");
+        String val;
+        int byteVal;
+        for (int i = 0; i < buf.length; i++)
+        {
+            byteVal = buf[i] & 0xff;
+            val = Integer.toHexString(byteVal);
+            if (val.length() < 2)
+                str.append("0");
+            str.append(val);
+        }
+        return str.toString();
+    }
 }
 
 

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Database.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Database.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Database.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Database.java Wed Aug  8 06:54:46 2012
@@ -31,8 +31,8 @@ import org.apache.derby.iapi.reference.A
 import org.apache.derby.iapi.tools.i18n.LocalizedResource;
 
 /**
-	Database stores information about the current database
-	It is used so that a session may have more than one database
+    Database stores information about the current database
+    It is used so that a session may have more than one database
 */
 class Database
 {
@@ -41,222 +41,222 @@ class Database
      * it is probably wise to keep dbName and shortDbName private and have 
      * accessors for them.
      */
-	private String dbName;			// database name 
-	private String shortDbName;       // database name without attributes
-	String attrString="";               // attribute string
-	protected int securityMechanism;	// Security mechanism
-	protected String userId;			// User Id
-	protected String password;			// password
-	protected String decryptedUserId;	// Decrypted User id
-	protected String decryptedPassword;	// Decrypted password
+    private String dbName;            // database name 
+    private String shortDbName;       // database name without attributes
+    String attrString="";               // attribute string
+    protected int securityMechanism;    // Security mechanism
+    protected String userId;            // User Id
+    protected String password;            // password
+    protected String decryptedUserId;    // Decrypted User id
+    protected String decryptedPassword;    // Decrypted password
     protected byte[] passwordSubstitute;// password substitute - SECMEC_USRSSBPWD
-	protected boolean rdbAllowUpdates = true; // Database allows updates -default is true		
-	protected int	accessCount;		// Number of times we have tried to
-										// set up access to this database (only 1 
-										// allowed)
-    protected byte[] secTokenIn;		// Security token from app requester
-    protected byte[] secTokenOut;		// Security token sent to app requester
-	protected byte[] crrtkn;			// Correlation token
-	protected String typDefNam;			// Type definition name
-	protected int byteOrder;			//deduced from typDefNam, save String comparisons
-	protected int ccsidSBC;				// Single byte CCSID
-	protected int ccsidDBC;				// Double byte CCSID
-	protected int ccsidMBC;				// Mixed byte CCSID
-	protected String ccsidSBCEncoding;	// Encoding for single byte code page
-	protected String ccsidDBCEncoding;	// Encoding for double byte code page
-	protected String ccsidMBCEncoding;	// Encoding for mixed byte code page
-	protected boolean RDBUPDRM_sent = false;	//We have sent that an update
-											// occurred in this transaction
-	protected boolean sendTRGDFTRT = false; // Send package target default value
+    protected boolean rdbAllowUpdates = true; // Database allows updates -default is true        
+    protected int    accessCount;        // Number of times we have tried to
+                                        // set up access to this database (only 1 
+                                        // allowed)
+    protected byte[] secTokenIn;        // Security token from app requester
+    protected byte[] secTokenOut;        // Security token sent to app requester
+    protected byte[] crrtkn;            // Correlation token
+    protected String typDefNam;            // Type definition name
+    protected int byteOrder;            //deduced from typDefNam, save String comparisons
+    protected int ccsidSBC;                // Single byte CCSID
+    protected int ccsidDBC;                // Double byte CCSID
+    protected int ccsidMBC;                // Mixed byte CCSID
+    protected String ccsidSBCEncoding;    // Encoding for single byte code page
+    protected String ccsidDBCEncoding;    // Encoding for double byte code page
+    protected String ccsidMBCEncoding;    // Encoding for mixed byte code page
+    protected boolean RDBUPDRM_sent = false;    //We have sent that an update
+                                            // occurred in this transaction
+    protected boolean sendTRGDFTRT = false; // Send package target default value
     /**
      * Connection to the database in the embedded engine.
      */
-	private EngineConnection conn;
-	DRDAStatement defaultStatement;    // default statement used 
-													   // for execute imm
-	private DRDAStatement currentStatement; // current statement we are working on
+    private EngineConnection conn;
+    DRDAStatement defaultStatement;    // default statement used 
+                                                       // for execute imm
+    private DRDAStatement currentStatement; // current statement we are working on
     /** Hash table for storing statements. */
     private Hashtable<Object, DRDAStatement> stmtTable;
 
-	// constructor
-	/**
-	 * Database constructor
-	 * 
-	 * @param dbName	database name
-	 */
-	Database (String dbName)
-	{
-		setDatabaseName(dbName);
-		this.stmtTable = new Hashtable<Object, DRDAStatement>();
-		initializeDefaultStatement();
-	}
-
-	/**
-	 * Take database name including attributes and set
-	 * attrString and shortDbName accordingly.
-	 * 
-	 * @param dbName database name, including attributes.
-	 */
-	public void setDatabaseName(String dbName) {
-		if (dbName != null)
-		{
-			int attrOffset = dbName.indexOf(';');
-			if (attrOffset != -1)
-			{
-				this.attrString = dbName.substring(attrOffset,dbName.length());
-				this.shortDbName = dbName.substring(0,attrOffset);
-			}
-			else
-				this.shortDbName = dbName;
-		}
-
-		this.dbName = dbName;
-
-	}
-	
-	public String getDatabaseName() {
-	    return this.dbName;
-	}
-	
-	public String getShortDbName() {
-	    return this.shortDbName;
-	}
-	
-	private void initializeDefaultStatement()
-	{
-		this.defaultStatement = new DRDAStatement(this);
-	}
-
-	/**
-	 * Set connection and create the SQL statement for the default statement
-	 *
-	 * @param conn Connection
-	 * @exception SQLException
-	 */
-	final void setConnection(EngineConnection conn)
-		throws SQLException
-	{
+    // constructor
+    /**
+     * Database constructor
+     * 
+     * @param dbName    database name
+     */
+    Database (String dbName)
+    {
+        setDatabaseName(dbName);
+        this.stmtTable = new Hashtable<Object, DRDAStatement>();
+        initializeDefaultStatement();
+    }
+
+    /**
+     * Take database name including attributes and set
+     * attrString and shortDbName accordingly.
+     * 
+     * @param dbName database name, including attributes.
+     */
+    public void setDatabaseName(String dbName) {
+        if (dbName != null)
+        {
+            int attrOffset = dbName.indexOf(';');
+            if (attrOffset != -1)
+            {
+                this.attrString = dbName.substring(attrOffset,dbName.length());
+                this.shortDbName = dbName.substring(0,attrOffset);
+            }
+            else
+                this.shortDbName = dbName;
+        }
+
+        this.dbName = dbName;
+
+    }
+    
+    public String getDatabaseName() {
+        return this.dbName;
+    }
+    
+    public String getShortDbName() {
+        return this.shortDbName;
+    }
+    
+    private void initializeDefaultStatement()
+    {
+        this.defaultStatement = new DRDAStatement(this);
+    }
+
+    /**
+     * Set connection and create the SQL statement for the default statement
+     *
+     * @param conn Connection
+     * @exception SQLException
+     */
+    final void setConnection(EngineConnection conn)
+        throws SQLException
+    {
         if (this.conn != conn) {
             // Need to drop the pb session data when switching connections
             pbsd_ = null;
         }
-		this.conn = conn;
-		if(conn != null)
-			defaultStatement.setStatement(conn);
-	}
-	/**
-	 * Get the connection
-	 *
-	 * @return connection
-	 */
-	final EngineConnection getConnection()
-	{
-		return conn;
-	}
-	/**
-	 * Get current DRDA statement 
-	 *
-	 * @return DRDAStatement
-	 * @exception SQLException
-	 */
-	protected DRDAStatement getCurrentStatement() 
-	{
-		return currentStatement;
-	}
-	/**
-	 * Get default statement for use in EXCIMM
-	 *
-	 * @return DRDAStatement
-	 */
-	protected DRDAStatement getDefaultStatement() 
-	{
-		currentStatement = defaultStatement;
-		return defaultStatement;
-	}
-
-	/**
-	 * Get default statement for use in EXCIMM with specified pkgnamcsn
-	 * The pkgnamcsn has the encoded isolation level
-	 *
-	 * @param pkgnamcsn package/ section # for statement
-	 * @return DRDAStatement
-	 */
-	protected DRDAStatement getDefaultStatement(Pkgnamcsn pkgnamcsn) 
-	{
-		currentStatement = defaultStatement;
-		currentStatement.setPkgnamcsn(pkgnamcsn);
-		return currentStatement;
-	}
-
-	/**
-	 * Get a new DRDA statement and store it in the stmtTable if stortStmt is 
-	 * true. If possible recycle an existing statement. When the server gets a
-	 * new statement with a previously used pkgnamcsn, it means that 
-	 * client-side statement associated with this pkgnamcsn has been closed. In 
-	 * this case, server can re-use the DRDAStatement by doing the following:  
-	 * 1) Retrieve the old DRDAStatement associated with this pkgnamcsn and
-	 * close it.
-	 * 2) Reset the DRDAStatement state for re-use.
-	 * 
-	 * @param pkgnamcsn  Package name and section
-	 * @return DRDAStatement  
-	 */
-	protected DRDAStatement newDRDAStatement(Pkgnamcsn pkgnamcsn)
-	throws SQLException
-	{
-		DRDAStatement stmt = getDRDAStatement(pkgnamcsn);
-		if (stmt != null) {
-			stmt.close();
-			stmt.reset();
-		}
-		else
-		{
-			stmt = new DRDAStatement(this);
-			stmt.setPkgnamcsn(pkgnamcsn);
-			storeStatement(stmt);
-		}
-		return stmt;
-	}
-
-	/**
-	 * Get DRDA statement based on pkgnamcsn
-	 *
-	 * @param pkgnamcsn - key to access statement
-	 * @return DRDAStatement
-	 */
-	protected DRDAStatement getDRDAStatement(Pkgnamcsn pkgnamcsn) {
-		DRDAStatement newStmt =
-			(DRDAStatement) stmtTable.get(pkgnamcsn.getStatementKey());
-		if (newStmt != null) {
-			currentStatement = newStmt;
-			currentStatement.setCurrentDrdaResultSet(pkgnamcsn);
-		}
-		return newStmt;
-	}
-
-	/**
-	 * Make a new connection using the database name and set 
-	 * the connection in the database
-	 * @param p Properties for connection attributes to pass to connect
-	 */
-	void makeConnection(Properties p) throws SQLException
-	{
-		p.put(Attribute.USERNAME_ATTR, userId);
+        this.conn = conn;
+        if(conn != null)
+            defaultStatement.setStatement(conn);
+    }
+    /**
+     * Get the connection
+     *
+     * @return connection
+     */
+    final EngineConnection getConnection()
+    {
+        return conn;
+    }
+    /**
+     * Get current DRDA statement 
+     *
+     * @return DRDAStatement
+     * @exception SQLException
+     */
+    protected DRDAStatement getCurrentStatement() 
+    {
+        return currentStatement;
+    }
+    /**
+     * Get default statement for use in EXCIMM
+     *
+     * @return DRDAStatement
+     */
+    protected DRDAStatement getDefaultStatement() 
+    {
+        currentStatement = defaultStatement;
+        return defaultStatement;
+    }
+
+    /**
+     * Get default statement for use in EXCIMM with specified pkgnamcsn
+     * The pkgnamcsn has the encoded isolation level
+     *
+     * @param pkgnamcsn package/ section # for statement
+     * @return DRDAStatement
+     */
+    protected DRDAStatement getDefaultStatement(Pkgnamcsn pkgnamcsn) 
+    {
+        currentStatement = defaultStatement;
+        currentStatement.setPkgnamcsn(pkgnamcsn);
+        return currentStatement;
+    }
+
+    /**
+     * Get a new DRDA statement and store it in the stmtTable if stortStmt is 
+     * true. If possible recycle an existing statement. When the server gets a
+     * new statement with a previously used pkgnamcsn, it means that 
+     * client-side statement associated with this pkgnamcsn has been closed. In 
+     * this case, server can re-use the DRDAStatement by doing the following:  
+     * 1) Retrieve the old DRDAStatement associated with this pkgnamcsn and
+     * close it.
+     * 2) Reset the DRDAStatement state for re-use.
+     * 
+     * @param pkgnamcsn  Package name and section
+     * @return DRDAStatement  
+     */
+    protected DRDAStatement newDRDAStatement(Pkgnamcsn pkgnamcsn)
+    throws SQLException
+    {
+        DRDAStatement stmt = getDRDAStatement(pkgnamcsn);
+        if (stmt != null) {
+            stmt.close();
+            stmt.reset();
+        }
+        else
+        {
+            stmt = new DRDAStatement(this);
+            stmt.setPkgnamcsn(pkgnamcsn);
+            storeStatement(stmt);
+        }
+        return stmt;
+    }
+
+    /**
+     * Get DRDA statement based on pkgnamcsn
+     *
+     * @param pkgnamcsn - key to access statement
+     * @return DRDAStatement
+     */
+    protected DRDAStatement getDRDAStatement(Pkgnamcsn pkgnamcsn) {
+        DRDAStatement newStmt =
+            (DRDAStatement) stmtTable.get(pkgnamcsn.getStatementKey());
+        if (newStmt != null) {
+            currentStatement = newStmt;
+            currentStatement.setCurrentDrdaResultSet(pkgnamcsn);
+        }
+        return newStmt;
+    }
+
+    /**
+     * Make a new connection using the database name and set 
+     * the connection in the database
+     * @param p Properties for connection attributes to pass to connect
+     */
+    void makeConnection(Properties p) throws SQLException
+    {
+        p.put(Attribute.USERNAME_ATTR, userId);
                 
         // take care of case of SECMEC_USRIDONL
         if (password != null) 
-		    p.put(Attribute.PASSWORD_ATTR, password);
+            p.put(Attribute.PASSWORD_ATTR, password);
                 
         // Contract between network server and embedded engine
         // is that any connection returned implements EngineConnection.
         EngineConnection conn = (EngineConnection)
             NetworkServerControlImpl.getDriver().connect(Attribute.PROTOCOL
-							 + shortDbName + attrString, p);
-		if (conn != null) {
-			conn.setAutoCommit(false);
-		}
-		setConnection(conn);
-	}
+                             + shortDbName + attrString, p);
+        if (conn != null) {
+            conn.setAutoCommit(false);
+        }
+        setConnection(conn);
+    }
 
     /**
      * This makes a dummy connection to the database in order to 
@@ -283,146 +283,146 @@ class Database
         } catch (SQLException se) {} // Simply do nothing
     }
     
-	// Create string to pass to DataSource.setConnectionAttributes
-	String appendAttrString(Properties p)
-	{
-		if (p == null)
-			return null;
-		
-		Enumeration pKeys = p.propertyNames();
-		while (pKeys.hasMoreElements()) 
-		{
-			String key = (String) pKeys.nextElement();
-			attrString +=";" + key  + "=" + p.getProperty(key);
-		}
-
-		return attrString;
-	}
-
-	/**
-	 * Store DRDA prepared statement
-	 * @param  stmt	DRDA prepared statement
-	 */
-	protected void storeStatement(DRDAStatement stmt) throws SQLException
-	{
-		stmtTable.put(stmt.getPkgnamcsn().getStatementKey(), stmt);
-	}
-
-	protected void removeStatement(DRDAStatement stmt) throws SQLException
-	{
-		stmtTable.remove(stmt.getPkgnamcsn().getStatementKey());
-		stmt.close();
-	}
-	
-	/**
-	 * Make statement the current statement
-	 * @param stmt
-	 *
-	 */
-
-	protected void setCurrentStatement(DRDAStatement stmt)
-	{
-		currentStatement = stmt;
-	}
+    // Create string to pass to DataSource.setConnectionAttributes
+    String appendAttrString(Properties p)
+    {
+        if (p == null)
+            return null;
+        
+        Enumeration pKeys = p.propertyNames();
+        while (pKeys.hasMoreElements()) 
+        {
+            String key = (String) pKeys.nextElement();
+            attrString +=";" + key  + "=" + p.getProperty(key);
+        }
+
+        return attrString;
+    }
+
+    /**
+     * Store DRDA prepared statement
+     * @param  stmt    DRDA prepared statement
+     */
+    protected void storeStatement(DRDAStatement stmt) throws SQLException
+    {
+        stmtTable.put(stmt.getPkgnamcsn().getStatementKey(), stmt);
+    }
+
+    protected void removeStatement(DRDAStatement stmt) throws SQLException
+    {
+        stmtTable.remove(stmt.getPkgnamcsn().getStatementKey());
+        stmt.close();
+    }
+    
+    /**
+     * Make statement the current statement
+     * @param stmt
+     *
+     */
+
+    protected void setCurrentStatement(DRDAStatement stmt)
+    {
+        currentStatement = stmt;
+    }
 
    
-	protected void commit() throws SQLException
-	{
-		
-		if (conn != null)
-			conn.commit();
-	}
-
-	protected void rollback() throws SQLException
-	{
-		
-		if (conn != null)
-			conn.rollback();
-	}
-	/**
-	  * Database close does following cleanup tasks
-	  * 1)Rollback any pending transaction on the Connection object (except 
-	  * for a global-XA Connection obejct) before closing the Connection. 
-	  * Without the rollback, the Connection close will result into an 
-	  * exception if there is a pending transaction on that Connection.
-	  * 2)Clean up the statement table 
-	  * @throws SQLException on conn.close() error to be handled in DRDAConnThread.
-	  */
-	protected void close() throws SQLException
-	{
-
-		try {
-			if (stmtTable != null)
-			{
-				for (Enumeration e = stmtTable.elements() ; e.hasMoreElements() ;) 
-				{
-					((DRDAStatement) e.nextElement()).close();
-				}
-			
-			}
-			if (defaultStatement != null)			
-				defaultStatement.close();
-			if ((conn != null) && !conn.isClosed())
-			{
-				//rollback all the pending transactions except global XA trans
-				if (! conn.isInGlobalTransaction())
-				{
-					conn.rollback();
-				}
-				conn.close();					
-			}
-		}
-		finally {
-			conn = null;
-			currentStatement = null;
-			defaultStatement = null;
-			stmtTable=null;
-		}
-	}
-
-	final void setDrdaID(String drdaID)
-	{
-		if (conn != null)
-			conn.setDrdaID(drdaID);
-	}
-
-	/**
-	 *  Set the internal isolation level to use for preparing statements.
-	 *  Subsequent prepares will use this isoalation level
-	 * @param level internal isolation level 
-	 *
-	 * @throws SQLException
-	 * @see EngineConnection#setPrepareIsolation
-	 * 
-	 */
-	final void setPrepareIsolation(int level) throws SQLException
-	{
-		conn.setPrepareIsolation(level);
-	}
-
-	final int getPrepareIsolation() throws SQLException
-	{
-		return conn.getPrepareIsolation();
-	}
-
-	protected String buildRuntimeInfo(String indent, LocalizedResource localLangUtil)
-	{	
-	  
-		String s = indent + 
-		localLangUtil.getTextMessage("DRDA_RuntimeInfoDatabase.I") +
-			dbName + "\n" +  
-		localLangUtil.getTextMessage("DRDA_RuntimeInfoUser.I")  +
-			userId +  "\n" +
-		localLangUtil.getTextMessage("DRDA_RuntimeInfoNumStatements.I") +
-			stmtTable.size() + "\n";
-		s += localLangUtil.getTextMessage("DRDA_RuntimeInfoPreparedStatementHeader.I");
-		for (Enumeration e = stmtTable.elements() ; e.hasMoreElements() ;) 
-				{
-					s += ((DRDAStatement) e.nextElement()).toDebugString(indent
-																		 +"\t") +"\n";
-				}
-		return s;
-	}
+    protected void commit() throws SQLException
+    {
+        
+        if (conn != null)
+            conn.commit();
+    }
+
+    protected void rollback() throws SQLException
+    {
+        
+        if (conn != null)
+            conn.rollback();
+    }
+    /**
+      * Database close does following cleanup tasks
+      * 1)Rollback any pending transaction on the Connection object (except 
+      * for a global-XA Connection obejct) before closing the Connection. 
+      * Without the rollback, the Connection close will result into an 
+      * exception if there is a pending transaction on that Connection.
+      * 2)Clean up the statement table 
+      * @throws SQLException on conn.close() error to be handled in DRDAConnThread.
+      */
+    protected void close() throws SQLException
+    {
+
+        try {
+            if (stmtTable != null)
+            {
+                for (Enumeration e = stmtTable.elements() ; e.hasMoreElements() ;) 
+                {
+                    ((DRDAStatement) e.nextElement()).close();
+                }
+            
+            }
+            if (defaultStatement != null)            
+                defaultStatement.close();
+            if ((conn != null) && !conn.isClosed())
+            {
+                //rollback all the pending transactions except global XA trans
+                if (! conn.isInGlobalTransaction())
+                {
+                    conn.rollback();
+                }
+                conn.close();                    
+            }
+        }
+        finally {
+            conn = null;
+            currentStatement = null;
+            defaultStatement = null;
+            stmtTable=null;
+        }
+    }
+
+    final void setDrdaID(String drdaID)
+    {
+        if (conn != null)
+            conn.setDrdaID(drdaID);
+    }
+
+    /**
+     *  Set the internal isolation level to use for preparing statements.
+     *  Subsequent prepares will use this isoalation level
+     * @param level internal isolation level 
+     *
+     * @throws SQLException
+     * @see EngineConnection#setPrepareIsolation
+     * 
+     */
+    final void setPrepareIsolation(int level) throws SQLException
+    {
+        conn.setPrepareIsolation(level);
+    }
+
+    final int getPrepareIsolation() throws SQLException
+    {
+        return conn.getPrepareIsolation();
+    }
+
+    protected String buildRuntimeInfo(String indent, LocalizedResource localLangUtil)
+    {    
+      
+        String s = indent + 
+        localLangUtil.getTextMessage("DRDA_RuntimeInfoDatabase.I") +
+            dbName + "\n" +  
+        localLangUtil.getTextMessage("DRDA_RuntimeInfoUser.I")  +
+            userId +  "\n" +
+        localLangUtil.getTextMessage("DRDA_RuntimeInfoNumStatements.I") +
+            stmtTable.size() + "\n";
+        s += localLangUtil.getTextMessage("DRDA_RuntimeInfoPreparedStatementHeader.I");
+        for (Enumeration e = stmtTable.elements() ; e.hasMoreElements() ;) 
+                {
+                    s += ((DRDAStatement) e.nextElement()).toDebugString(indent
+                                                                         +"\t") +"\n";
+                }
+        return s;
+    }
     
     private boolean locatorSupport = false;
     private boolean locatorSupportChecked = false;

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DecryptionManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DecryptionManager.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DecryptionManager.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DecryptionManager.java Wed Aug  8 06:54:46 2012
@@ -129,16 +129,16 @@ class DecryptionManager
     }
     catch (java.security.NoSuchAlgorithmException e) {
       throw new SQLException ("java.security.NoSuchAlgorithmException is caught" +
-			      " when initializing EncryptionManager '" + e.getMessage() + "'");
+                  " when initializing EncryptionManager '" + e.getMessage() + "'");
     }
     catch (java.security.InvalidAlgorithmParameterException e) {
       throw new SQLException ("java.security.InvalidAlgorithmParameterException is caught" +
-			      " when initializing EncryptionManager '" + e.getMessage() + "'");
+                  " when initializing EncryptionManager '" + e.getMessage() + "'");
     }
 
     catch (java.security.InvalidKeyException e) {
       throw new SQLException ("java.security.InvalidKeyException is caught" +
-			      " when initializing EncryptionManager '" + e.getMessage() + "'");
+                  " when initializing EncryptionManager '" + e.getMessage() + "'");
     }
   }
 
@@ -171,7 +171,7 @@ class DecryptionManager
     if (aPubKey.length == 33 && aPubKey[0]==0) {
       byte[] newKey = new byte[32];
       for (int i=0; i < newKey.length; i++)
-		newKey[i] = aPubKey[i+1];
+        newKey[i] = aPubKey[i+1];
       return newKey;
     }
 
@@ -183,10 +183,10 @@ class DecryptionManager
       byte[] newKey = new byte[32];
       int i;
       for (i=0; i < 32-aPubKey.length; i++) {
-		newKey[i] = 0;
+        newKey[i] = 0;
       }
       for (int j=i; j<newKey.length; j++)
-		newKey[j] = aPubKey[j-i];
+        newKey[j] = aPubKey[j-i];
       return newKey;
     }
     return aPubKey;
@@ -213,8 +213,8 @@ class DecryptionManager
     if (securityMechanism == 7) {
       if (initVector.length < 8) { //shorter than 8 bytes, zero padded to 8 bytes
         System.arraycopy(initVector, 0, token, 0, initVector.length);
-		for (int i=initVector.length; i<8; i++)
-	 	 token[i] = 0;
+        for (int i=initVector.length; i<8; i++)
+          token[i] = 0;
       }
       else {  //longer than 8 bytes, truncated to 8 bytes
         System.arraycopy(initVector, 0, token, 0, 8);
@@ -224,7 +224,7 @@ class DecryptionManager
     //the token.
     else if (securityMechanism == 9) {
       for (int i = 0; i < 8; i++) {
-		token[i] = initVector[i + 12];
+        token[i] = initVector[i + 12];
       }
     }
     return token;
@@ -244,9 +244,9 @@ class DecryptionManager
    * @return the decrypted data (plain text) in a byte array.
    */
   public byte[] decryptData (byte[] cipherText,
-			     int    securityMechanism,
-			     byte[] initVector,
-			     byte[] sourcePublicKey) throws SQLException
+                 int    securityMechanism,
+                 byte[] initVector,
+                 byte[] sourcePublicKey) throws SQLException
   {
     byte[] plainText = null;
     byte[] token = calculateDecryptionToken (securityMechanism, initVector);
@@ -274,15 +274,15 @@ class DecryptionManager
       //we trim off the frist byte. If the length of secret key is less than 32, we will
       //pad 0 to the beginning of the byte array tho make the secret key 32 bytes.
       if (sharedSecret.length == 33 && sharedSecret[0] == 0) {
-		for (int i=0; i<newKey.length; i++)
-		  newKey[i] = sharedSecret[i+1];
+        for (int i=0; i<newKey.length; i++)
+          newKey[i] = sharedSecret[i+1];
       }
       if (sharedSecret.length < 32) {
-		int i;
-		for (i=0; i<(32 - sharedSecret.length); i++)
-	 		newKey[i] = 0;
-		for (int j=i; j<sharedSecret.length; j++)
-	 		 newKey[j] = sharedSecret[j-i];
+        int i;
+        for (i=0; i<(32 - sharedSecret.length); i++)
+             newKey[i] = 0;
+        for (int j=i; j<sharedSecret.length; j++)
+              newKey[j] = sharedSecret[j-i];
       }
 
       //The Data Encryption Standard (DES) is going to be used to encrypt userid
@@ -296,37 +296,37 @@ class DecryptionManager
 
       //if secret key is not 32, we will use the adjust length secret key
       if (sharedSecret.length==32) {
-		for (int i=0; i< 8;i++)
-		  key[i] = sharedSecret[i+12];
+        for (int i=0; i< 8;i++)
+          key[i] = sharedSecret[i+12];
       }
       else if (sharedSecret.length==33 || sharedSecret.length < 32) {
-		for (int i=0; i< 8;i++)
-		  key[i] = newKey[i+12];
+        for (int i=0; i< 8;i++)
+          key[i] = newKey[i+12];
       }
       else
-		throw new SQLException ("sharedSecret key length error " + sharedSecret.length);
+        throw new SQLException ("sharedSecret key length error " + sharedSecret.length);
 
-	  // make parity bit right, even number of 1's
-	  byte temp;
-	  int changeParity;
-	  for (int i=0; i<8; i++)
-	  {
-		temp = key[i];
-		changeParity = 1;
-		for (int j=0; j<8; j++)
-		{
-			if (temp < 0)
-				changeParity = 1 - changeParity;
-			temp = (byte) (temp << 1);
-		}
-		if (changeParity == 1)
-		{
-			if ((key[i] & 1) != 0)
-				key[i] &= 0xfe;
-			else
-				key[i] |= 1;
-		}
-	  }
+      // make parity bit right, even number of 1's
+      byte temp;
+      int changeParity;
+      for (int i=0; i<8; i++)
+      {
+        temp = key[i];
+        changeParity = 1;
+        for (int j=0; j<8; j++)
+        {
+            if (temp < 0)
+                changeParity = 1 - changeParity;
+            temp = (byte) (temp << 1);
+        }
+        if (changeParity == 1)
+        {
+            if ((key[i] & 1) != 0)
+                key[i] &= 0xfe;
+            else
+                key[i] |= 1;
+        }
+      }
 
       //use this encryption key to initiate a SecretKeySpec object
       SecretKeySpec desKey = new SecretKeySpec (key, "DES");
@@ -351,35 +351,35 @@ class DecryptionManager
     }
     catch (java.security.NoSuchProviderException e) {
       throw new SQLException ("java.security.NoSuchProviderException is caught "
-			      + "when encrypting data '" + e.getMessage() + "'");
+                  + "when encrypting data '" + e.getMessage() + "'");
     }
     catch (java.security.NoSuchAlgorithmException e) {
       throw new SQLException ("java.security.NoSuchAlgorithmException is caught "
-			      + "when encrypting data '" + e.getMessage() + "'");
+                  + "when encrypting data '" + e.getMessage() + "'");
     }
     catch (java.security.spec.InvalidKeySpecException e) {
       throw new SQLException ("java.security.InvalidKeySpecException is caught "
-			      + "when encrypting data");
+                  + "when encrypting data");
     }
     catch (java.security.InvalidKeyException e) {
       throw new SQLException ("java.security.InvalidKeyException is caught "
-			      + "when encrypting data '" + e.getMessage() + "'");
+                  + "when encrypting data '" + e.getMessage() + "'");
     }
     catch (javax.crypto.NoSuchPaddingException e) {
       throw new SQLException ("javax.crypto.NoSuchPaddingException is caught "
-			      + "when encrypting data '" + e.getMessage() + "'");
+                  + "when encrypting data '" + e.getMessage() + "'");
     }
     catch (javax.crypto.BadPaddingException e) {
       throw new SQLException ("javax.crypto.BadPaddingException is caught "
-			      + "when encrypting data '" + e.getMessage() + "'");
+                  + "when encrypting data '" + e.getMessage() + "'");
     }
     catch (java.security.InvalidAlgorithmParameterException e) {
       throw new SQLException ("java.security.InvalidAlgorithmParameterException is caught "
-			      + "when encrypting data '" + e.getMessage() + "'");
+                  + "when encrypting data '" + e.getMessage() + "'");
     }
     catch (javax.crypto.IllegalBlockSizeException e) {
       throw new SQLException ("javax.crypto.IllegalBlockSizeException is caught "
-			      + "when encrypting data '" + e.getMessage() + "'");
+                  + "when encrypting data '" + e.getMessage() + "'");
     }
     return plainText;
   }
@@ -430,12 +430,12 @@ class DecryptionManager
         For each byte (b) two characaters are generated, the first character
         represents the high nibble (4 bits) in hexidecimal (<code>b & 0xf0</code>),
         the second character represents the low nibble (<code>b & 0x0f</code>).
-		<BR>
+        <BR>
         The byte at <code>data[offset]</code> is represented by the first two characters in the returned String.
 
-        @param	data	byte array
-        @param	offset	starting byte (zero based) to convert.
-        @param	length	number of bytes to convert.
+        @param    data    byte array
+        @param    offset    starting byte (zero based) to convert.
+        @param    length    number of bytes to convert.
 
         @return the String (with hexidecimal format) form of the byte array
     */
@@ -467,19 +467,19 @@ class DecryptionManager
         The character at <code>str.charAt(0)</code> is represented by the first two bytes 
         in the returned String.
 
-        @param	str string 
-        @param	offset	starting character (zero based) to convert.
-        @param	length	number of characters to convert.
+        @param    str string 
+        @param    offset    starting character (zero based) to convert.
+        @param    length    number of characters to convert.
 
         @return the byte[]  (with hexidecimal format) form of the string (str) 
     */
     protected static byte[] toHexByte(String str, int offset, int length)
     {
-  	    byte[] data = new byte[(length - offset) * 2];
+          byte[] data = new byte[(length - offset) * 2];
         int end = offset+length;
 
         for (int i = offset; i < end; i++)
- 	    {
+         {
             char ch = str.charAt(i);
             int high_nibble = (ch & 0xf0) >>> 4;
             int low_nibble = (ch & 0x0f);

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssConstants.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssConstants.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssConstants.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssConstants.java Wed Aug  8 06:54:46 2012
@@ -23,8 +23,8 @@
 package org.apache.derby.impl.drda;
 
 /**
-	This class defines DSS constants that are shared in the classes implementing
-	the DRDA protocol.
+    This class defines DSS constants that are shared in the classes implementing
+    the DRDA protocol.
 */
 class DssConstants
 {

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java Wed Aug  8 06:54:46 2012
@@ -181,7 +181,7 @@ public class DssTrace
             // We don't try making the directory first because it would require
             // extra permissions if the directory already exists. DERBY-4128
             for (int attempt=0; attempt <2; attempt++) {
-                try {             	
+                try {                 
                     // The writer will be buffered for effeciency.
                     comBufferWriter =
                         (AccessController.doPrivileged(
@@ -246,7 +246,7 @@ public class DssTrace
                         throw e;
                     }
                 }
-        	}
+            }
           // Turn on the trace flag.
           comBufferTraceOn = true;
           // initialize the codepoint name table if it is null.

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java Wed Aug  8 06:54:46 2012
@@ -67,84 +67,84 @@ class EXTDTAInputStream extends InputStr
     private Blob _blob;
     
       
-	
-	private EXTDTAInputStream(ResultSet rs,
-				  int columnNumber,
-				  int ndrdaType) 
+    
+    private EXTDTAInputStream(ResultSet rs,
+                  int columnNumber,
+                  int ndrdaType) 
     {
-	
+    
         this.rs = (EngineResultSet) rs;
         this.columnNumber = columnNumber;
         this.ndrdaType = ndrdaType;
     }
 
-	private EXTDTAInputStream(Clob clob, int ndrdaType ) 
+    private EXTDTAInputStream(Clob clob, int ndrdaType ) 
     {
         _clob = clob;
         this.ndrdaType = ndrdaType;
     }
 
-	private EXTDTAInputStream(Blob blob, int ndrdaType ) 
+    private EXTDTAInputStream(Blob blob, int ndrdaType ) 
     {
         _blob = blob;
         this.ndrdaType = ndrdaType;
     }
 
     
-	/**
-	 * Create a new EXTDTAInputStream.  Before read the stream must be 
+    /**
+     * Create a new EXTDTAInputStream.  Before read the stream must be 
      * initialized by the user with {@link #initInputStream()} 
-	 * 
-	 * @see DDMWriter#writeScalarStream
+     * 
+     * @see DDMWriter#writeScalarStream
      * @see #initInputStream()
-	 * 
-	 * @param rs
-	 *            result set from which to retrieve the lob
-	 * @param column
-	 *            column number
-	 * @param drdaType
-	 *            FD:OCA type of object one of
-	 * 			   DRDAConstants.DRDA_TYPE_NLOBBYTES
-	 * 			   DRDAConstants.DRDA_TYPE_LOBBYTES
-	 * 			   DRDAConstants.DRDA_TYPE_NLOBCMIXED
-	 *  		   DRDAConstants.DRDA_TYPE_LOBCMIXED
-	 * 
-	 * @return null if the value is null or a new EXTDTAInputStream corresponding to 
-	 *  		rs.getBinaryStream(column) value and associated length
-	 * 
-	 * @throws SQLException
-	 */
-	public static EXTDTAInputStream getEXTDTAStream(ResultSet rs, int column, int drdaType) 
-		{
- 	    
-		int ndrdaType = drdaType | 1; //nullable drdaType
-			
-		return new EXTDTAInputStream(rs,
-					     column,
-					     ndrdaType);
-		
-	}
-
-	/**
-	 * Create a new EXTDTAInputStream from a CallableStatement.
-	 * 
-	 * 
-	 * @param cs
-	 *            CallableStatement from which to retrieve the lob
-	 * @param column
-	 *            column number
-	 * @param drdaType
-	 *            FD:OCA type of object one of
-	 * 			   DRDAConstants.DRDA_TYPE_NLOBBYTES
-	 * 			   DRDAConstants.DRDA_TYPE_LOBBYTES
-	 * 			   DRDAConstants.DRDA_TYPE_NLOBCMIXED
-	 *  		   DRDAConstants.DRDA_TYPE_LOBCMIXED
-	 */
-	public static EXTDTAInputStream getEXTDTAStream(CallableStatement cs, int column, int drdaType)
+     * 
+     * @param rs
+     *            result set from which to retrieve the lob
+     * @param column
+     *            column number
+     * @param drdaType
+     *            FD:OCA type of object one of
+     *                DRDAConstants.DRDA_TYPE_NLOBBYTES
+     *                DRDAConstants.DRDA_TYPE_LOBBYTES
+     *                DRDAConstants.DRDA_TYPE_NLOBCMIXED
+     *             DRDAConstants.DRDA_TYPE_LOBCMIXED
+     * 
+     * @return null if the value is null or a new EXTDTAInputStream corresponding to 
+     *          rs.getBinaryStream(column) value and associated length
+     * 
+     * @throws SQLException
+     */
+    public static EXTDTAInputStream getEXTDTAStream(ResultSet rs, int column, int drdaType) 
+        {
+         
+        int ndrdaType = drdaType | 1; //nullable drdaType
+            
+        return new EXTDTAInputStream(rs,
+                         column,
+                         ndrdaType);
+        
+    }
+
+    /**
+     * Create a new EXTDTAInputStream from a CallableStatement.
+     * 
+     * 
+     * @param cs
+     *            CallableStatement from which to retrieve the lob
+     * @param column
+     *            column number
+     * @param drdaType
+     *            FD:OCA type of object one of
+     *                DRDAConstants.DRDA_TYPE_NLOBBYTES
+     *                DRDAConstants.DRDA_TYPE_LOBBYTES
+     *                DRDAConstants.DRDA_TYPE_NLOBCMIXED
+     *             DRDAConstants.DRDA_TYPE_LOBCMIXED
+     */
+    public static EXTDTAInputStream getEXTDTAStream(CallableStatement cs, int column, int drdaType)
         throws SQLException
     {
- 	    
-		int ndrdaType = drdaType | 1; //nullable drdaType
+         
+        int ndrdaType = drdaType | 1; //nullable drdaType
 
         switch ( ndrdaType )
         {
@@ -158,118 +158,118 @@ class EXTDTAInputStream extends InputStr
             return new EXTDTAInputStream( clob, ndrdaType );
         default:
             badDRDAType( ndrdaType );
-			return null;
+            return null;
         }
-	}
+    }
 
-	
-	
-	/**
-	 * Requires {@link #initInputStream()} be called before we can read from the stream
-	 * 
-	 * @see java.io.InputStream#read()
-	 */
-	public int read() throws IOException {
+    
+    
+    /**
+     * Requires {@link #initInputStream()} be called before we can read from the stream
+     * 
+     * @see java.io.InputStream#read()
+     */
+    public int read() throws IOException {
                        
-		return binaryInputStream.read();
-	}
+        return binaryInputStream.read();
+    }
+
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#available()
+     */
+    public int available() throws IOException {
+        return binaryInputStream.available();
+    }
+
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#close()
+     */
+    public void close() throws IOException {
+        
+        if (binaryInputStream != null)
+            binaryInputStream.close();    
+        binaryInputStream = null;
+        
+    }
+
+    /**
+     * 
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object arg0) {
+        return binaryInputStream.equals(arg0);
+    }
+
+    /**
+     * 
+     * 
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode() {
+        return binaryInputStream.hashCode();
+    }
 
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#available()
-	 */
-	public int available() throws IOException {
-		return binaryInputStream.available();
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#close()
-	 */
-	public void close() throws IOException {
-	    
-		if (binaryInputStream != null)
-			binaryInputStream.close();	
-		binaryInputStream = null;
-	    
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.lang.Object#equals(java.lang.Object)
-	 */
-	public boolean equals(Object arg0) {
-		return binaryInputStream.equals(arg0);
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.lang.Object#hashCode()
-	 */
-	public int hashCode() {
-		return binaryInputStream.hashCode();
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#mark(int)
-	 */
-	public void mark(int arg0) {
-		binaryInputStream.mark(arg0);
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#markSupported()
-	 */
-	public boolean markSupported() {
-		return binaryInputStream.markSupported();
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#read(byte[])
-	 */
-	public int read(byte[] arg0) throws IOException {
-		return binaryInputStream.read(arg0);
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#read(byte[], int, int)
-	 */
-	public int read(byte[] arg0, int arg1, int arg2) throws IOException {
-		return binaryInputStream.read(arg0, arg1, arg2);
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#reset()
-	 */
-	public void reset() throws IOException {
-		binaryInputStream.reset();
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.io.InputStream#skip(long)
-	 */
-	public long skip(long arg0) throws IOException {
-		if (arg0 < 0L) {
-			return 0L;
-		}
-		return binaryInputStream.skip(arg0);
-	}
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#mark(int)
+     */
+    public void mark(int arg0) {
+        binaryInputStream.mark(arg0);
+    }
+
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#markSupported()
+     */
+    public boolean markSupported() {
+        return binaryInputStream.markSupported();
+    }
+
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#read(byte[])
+     */
+    public int read(byte[] arg0) throws IOException {
+        return binaryInputStream.read(arg0);
+    }
+
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#read(byte[], int, int)
+     */
+    public int read(byte[] arg0, int arg1, int arg2) throws IOException {
+        return binaryInputStream.read(arg0, arg1, arg2);
+    }
+
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#reset()
+     */
+    public void reset() throws IOException {
+        binaryInputStream.reset();
+    }
+
+    /**
+     * 
+     * 
+     * @see java.io.InputStream#skip(long)
+     */
+    public long skip(long arg0) throws IOException {
+        if (arg0 < 0L) {
+            return 0L;
+        }
+        return binaryInputStream.skip(arg0);
+    }
 
 
     protected boolean isEmptyStream() throws SQLException
@@ -293,45 +293,45 @@ class EXTDTAInputStream extends InputStr
      *
      */
     public  void initInputStream()
-	throws SQLException
+    throws SQLException
     {
 
-	InputStream is = null;
-	Reader r = null;
-	// BLOBS
-	if (ndrdaType == DRDAConstants.DRDA_TYPE_NLOBBYTES) 
-	{ 	    	
-	    is = getBinaryStream();
-	    if (is == null) { return; }
-	}
-	    // CLOBS
-	else if (ndrdaType ==  DRDAConstants.DRDA_TYPE_NLOBCMIXED)
-	{	
-	    try {
-	        
-	        r = getCharacterStream();
-		    	
-	        if(r == null){	            
+    InputStream is = null;
+    Reader r = null;
+    // BLOBS
+    if (ndrdaType == DRDAConstants.DRDA_TYPE_NLOBBYTES) 
+    {             
+        is = getBinaryStream();
+        if (is == null) { return; }
+    }
+        // CLOBS
+    else if (ndrdaType ==  DRDAConstants.DRDA_TYPE_NLOBCMIXED)
+    {    
+        try {
+            
+            r = getCharacterStream();
+                
+            if(r == null){                
                     return;
-	        }
+            }
 
-			is = new ReEncodedInputStream(r);
-			
-		    }catch (java.io.UnsupportedEncodingException e) {
-			throw Util.javaException(e);
-			
-		    }catch (IOException e){
-			throw Util.javaException(e);
-			
-		    }
-		    
-		}
+            is = new ReEncodedInputStream(r);
+            
+            }catch (java.io.UnsupportedEncodingException e) {
+            throw Util.javaException(e);
+            
+            }catch (IOException e){
+            throw Util.javaException(e);
+            
+            }
+            
+        }
         else { badDRDAType( ndrdaType ); }
-	if (! is.markSupported()) {
-	    is = new BufferedInputStream(is);
-	    }
-	    
- 	this.binaryInputStream=is;
+    if (! is.markSupported()) {
+        is = new BufferedInputStream(is);
+        }
+        
+     this.binaryInputStream=is;
     }
     private InputStream getBinaryStream() throws SQLException
     {
@@ -354,8 +354,8 @@ class EXTDTAInputStream extends InputStr
     
         
     protected void finalize() throws Throwable{
-	close();
-	}
+    close();
+    }
 
     /**
      * Is the value null?  Null status is obtained from the underlying 



Mime
View raw message