db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: rev 37083 - in incubator/derby/code/trunk: . java java/build java/build/org java/build/org/apache java/build/org/apache/derbyBuild java/build/org/apache/derbyBuild/javadoc java/drda java/drda/org java/drda/org/apache java/drda/org/apache/derby java/drda/org/apache/derby/drda java/drda/org/apache/derby/impl java/drda/org/apache/derby/impl/drda java/drda/org/apache/derby/loc java/drda/org/apache/derby/loc/drda java/engine java/engine/org java/engine/org/apache java/engine/org/apache/derby java/engine/org/apache/derby/authentication java/engine/org/apache/derby/catalog java/engine/org/apache/derby/catalog/types java/engine/org/apache/derby/database java/engine/org/apache/derby/diag java/engine/org/apache/derby/iapi java/engine/org/apache/derby/iapi/db java/engine/org/apache/derby/iapi/error java/engine/org/apache/derby/iapi/jdbc java/engine/org/apache/derby/iapi/reference java/engine/org/apache/derby/iapi/services java/engine/org/apache/derby/iapi/services/cache java/engine/org/apache/derby/iapi/services/classfile java/engine/org/apache/derby/iapi/services/compiler java/engine/org/apache/derby/iapi/services/context java/engine/org/apache/derby/iapi/services/crypto java/engine/org/apache/derby/iapi/services/daemon java/engine/org/apache/derby/iapi/services/diag java/engine/org/apache/derby/iapi/services/i18n java/engine/org/apache/derby/iapi/services/info java/engine/org/apache/derby/iapi/services/io java/engine/org/apache/derby/iapi/services/loader java/engine/org/apache/derby/iapi/services/locks java/engine/org/apache/derby/iapi/services/monitor java/engine/org/apache/derby/iapi/services/property java/engine/org/apache/derby/iapi/services/sanity java/engine/org/apache/derby/iapi/services/stream java/engine/org/apache/derby/iapi/services/uuid java/engine/org/apache/derby/iapi/sql java/engine/org/apache/derby/iapi/sql/compile java/engine/org/apache/derby/iapi/sql/conn java/engine/org/apache/derby/iapi/sql/depend java/engine/org/apache/derby/iapi/sql/dictionary java/engine/org/apache/derby/iapi/sql/execute java/engine/org/apache/derby/iapi/store java/engine/org/apache/derby/iapi/store/access java/engine/org/apache/derby/iapi/store/access/conglomerate java/engine/org/apache/derby/iapi/store/access/xa java/engine/org/apache/derby/iapi/store/raw java/engine/org/apache/derby/iapi/store/raw/data java/engine/org/apache/derby/iapi/store/raw/log java/engine/org/apache/derby/iapi/store/raw/xact java/engine/org/apache/derby/iapi/types java/engine/org/apache/derby/iapi/util java/engine/org/apache/derby/impl java/engine/org/apache/derby/impl/db java/engine/org/apache/derby/impl/io java/engine/org/apache/derby/impl/jdbc java/engine/org/apache/derby/impl/jdbc/authentication java/engine/org/apache/derby/impl/load java/engine/org/apache/derby/impl/services java/engine/org/apache/derby/impl/services/bytecode java/engine/org/apache/derby/impl/services/cache java/engine/org/apache/derby/impl/services/daemon java/engine/org/apache/derby/impl/services/jce java/engine/org/apache/derby/impl/services/locks java/engine/org/apache/derby/impl/services/monitor java/engine/org/apache/derby/impl/services/reflect java/engine/org/apache/derby/impl/services/stream java/engine/org/apache/derby/impl/services/uuid java/engine/org/apache/derby/impl/sql java/engine/org/apache/derby/impl/sql/catalog java/engine/org/apache/derby/impl/sql/compile java/engine/org/apache/derby/impl/sql/conn java/engine/org/apache/derby/impl/sql/depend java/engine/org/apache/derby/impl/sql/execute java/engine/org/apache/derby/impl/sql/execute/rts java/engine/org/apache/derby/impl/store java/engine/org/apache/derby/impl/store/access java/engine/org/apache/derby/impl/store/access/btree java/engine/org/apache/derby/impl/store/access/btree/index java/engine/org/apache/derby/impl/store/access/conglomerate java/engine/org/apache/derby/impl/store/access/heap java/engine/org/apache/derby/impl/store/access/sort java/engine/org/apache/derby/impl/store/raw java/engine/org/apache/derby/impl/store/raw/data java/engine/org/apache/derby/impl/store/raw/log java/engine/org/apache/derby/impl/store/raw/xact java/engine/org/apache/derby/io java/engine/org/apache/derby/jdbc java/engine/org/apache/derby/loc java/engine/org/apache/derby/osgi java/engine/org/apache/derby/vti java/tools java/tools/org java/tools/org/apache java/tools/org/apache/derby java/tools/org/apache/derby/iapi java/tools/org/apache/derby/iapi/tools java/tools/org/apache/derby/iapi/tools/i18n java/tools/org/apache/derby/impl java/tools/org/apache/derby/impl/tools java/tools/org/apache/derby/impl/tools/cslook java/tools/org/apache/derby/impl/tools/ij java/tools/org/apache/derby/impl/tools/sysinfo java/tools/org/apache/derby/loc java/tools/org/apache/derby/tools tools tools/ant tools/ant/properties tools/jar tools/java tools/javadoc
Date Thu, 26 Aug 2004 14:14:02 GMT
Author: coar
Date: Thu Aug 26 07:13:46 2004
New Revision: 37083

Added:
   incubator/derby/code/trunk/BUILDING.txt   (contents, props changed)
   incubator/derby/code/trunk/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/
   incubator/derby/code/trunk/java/build/
   incubator/derby/code/trunk/java/build/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/
   incubator/derby/code/trunk/java/build/org/apache/
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/ClassSizeCrawler.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/DiskLayoutTaglet.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/EndFormatTaglet.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/FormatIdTaglet.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/PurposeTaglet.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/UpgradeTaglet.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/propertyconfig.java   (contents, props changed)
   incubator/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/
   incubator/derby/code/trunk/java/drda/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/
   incubator/derby/code/trunk/java/drda/org/apache/
   incubator/derby/code/trunk/java/drda/org/apache/derby/
   incubator/derby/code/trunk/java/drda/org/apache/derby/drda/
   incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetServlet.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/drda/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CcsidManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CharacterEncodings.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePointNameTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DB2jServerImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolExceptionInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Database.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DecryptionManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssConstants.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EbcdicCcsidManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SignedBinary.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/TestFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/TestProto.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/memCheck.java   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/loc/
   incubator/derby/code/trunk/java/drda/org/apache/derby/loc/drda/
   incubator/derby/code/trunk/java/drda/org/apache/derby/loc/drda/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties   (contents, props changed)
   incubator/derby/code/trunk/java/drda/org/apache/derby/loc/drda/servlet_en.properties   (contents, props changed)
   incubator/derby/code/trunk/java/engine/
   incubator/derby/code/trunk/java/engine/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/
   incubator/derby/code/trunk/java/engine/org/apache/
   incubator/derby/code/trunk/java/engine/org/apache/derby/
   incubator/derby/code/trunk/java/engine/org/apache/derby/authentication/
   incubator/derby/code/trunk/java/engine/org/apache/derby/authentication/UserAuthenticator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/authentication/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/AliasInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/DefaultInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/Dependable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/DependableFinder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/GetProcedureColumns.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/IndexDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/ReferencedColumns.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/Statistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/TriggerNewTransitionRows.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/TriggerOldTransitionRows.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/UUID.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/DecimalTypeIdImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/DefaultInfoImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/IndexDescriptorImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/MethodAliasInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/ReferencedColumnsDescriptorImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/StatisticsImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypesImplInstanceGetter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/UserDefinedTypeIdImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/database/
   incubator/derby/code/trunk/java/engine/org/apache/derby/database/Database.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/database/UserUtility.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/database/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorLogReader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorMessages.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/StatementDuration.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/diag/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/ConnectionInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/ConsistencyChecker.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/DatabaseContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Factory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/OptimizerTrace.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/PropertyInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/TriggerExecutionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/db/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/error/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ExceptionSeverity.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/error/PassThroughException.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/error/PublicAPI.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/AuthenticationService.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnectionControl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ConnectionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/JDBCBoot.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ResourceAdapter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/ClassName.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/ContextId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Copyright.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/DB2Limit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/EngineType.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/JDBC20Translation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/JDBC30Translation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/MessageId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Module.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/cache/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/cache/CacheFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/cache/CacheManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/cache/Cacheable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/cache/CacheableFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/cache/ClassSize.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/cache/SizedCacheable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/AttributeEntry.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/Attributes.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Double_info.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Float_info.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Index_info.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Integer_info.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Long_info.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/CONSTANT_Utf8_info.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassEnumeration.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassFormatOutput.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassInput.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassInvestigator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ClassMember.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/ConstantPoolEntry.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/MemberTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/VMDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/classfile/VMOpcode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/compiler/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/compiler/ClassBuilder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/compiler/JavaFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/compiler/LocalField.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/compiler/MethodBuilder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/Context.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ErrorStringBuilder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ShutdownException.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/crypto/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/crypto/CipherFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/crypto/CipherProvider.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/crypto/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/daemon/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/daemon/DaemonFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/daemon/DaemonService.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/daemon/Serviceable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/diag/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/diag/DiagnosticUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/diag/Diagnosticable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/diag/DiagnosticableGeneric.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/diag/Performance.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/BundleFinder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/LocaleFinder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/JVMInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/ProductGenusNames.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/ProductVersionHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/PropertyNames.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/AccessibleByteArrayOutputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ApplicationObjectInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayOutputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ArrayUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/CompressedNumber.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/CounterOutputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/DebugByteTeeOutputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/DynamicByteArrayOutputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ErrorInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/ErrorObjectInput.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FileUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdOutputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/Formatable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableArrayHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableBitSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableHashtable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableInstanceGetter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableIntHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableLongHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableProperties.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/InputStreamUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/Limit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/LimitInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/LimitObjectInput.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/LimitReader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/NewByteArrayInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/NullOutputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/SQLExceptionWrapper.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/Storable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/StoredFormatIds.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/StreamStorable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/TypedFormat.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassFactoryContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/GeneratedByteCode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/GeneratedClass.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/GeneratedMethod.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/InstanceGetter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/JarReader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/C_LockFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/Latch.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/Limit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/LockFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/Lockable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/ShExLockable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/ShExQual.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/locks/VirtualLockTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/ModuleControl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/ModuleFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/ModuleSupportable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/PersistentService.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/property/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/property/PersistentSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/property/PropertyFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/property/PropertySetCallback.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/property/PropertyUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/property/PropertyValidation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/AssertFailure.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/sanity/SanityState.tmpl   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/HeaderPrintWriter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/InfoStreams.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/stream/PrintWriterGetHeader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/uuid/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/services/uuid/UUIDFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Activation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/LanguageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/LanguageProperties.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ParameterValueSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/PreparedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultDescription.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Row.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Statement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/StatementType.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/StatementUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/StorablePreparedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/AccessPath.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CodeGeneration.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CostEstimate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/ExpressionClassBuilderInterface.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/JoinStrategy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/NodeFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Optimizable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizableList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicateList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Optimizer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizerFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Parser.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/RequiredRowOrdering.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/RowOrdering.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompilerFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Visitable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Visitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/Authorizer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/ConnectionUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/StatementContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/DependableList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/Dependency.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/DependencyManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/Dependent.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/Provider.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/ProviderInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/depend/ProviderList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/AliasDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/CatalogRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/CheckConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptorList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptorList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConsInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptorList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DDUtils.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDescriptorGenerator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionaryContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DefaultDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DependencyDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/FileInfoDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ForeignKeyConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/GenericDescriptorList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/IndexLister.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/IndexRowGenerator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/KeyConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ListOfRowLists.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ReferencedKeyConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/RowList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SchemaDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/StatisticsDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SubCheckConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SubConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SubKeyConstraintDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SystemColumn.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TabInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TableDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TupleDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/UniqueSQLObjectDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/UniqueTupleDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ViewDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/CursorActivation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/CursorResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecCursorTableReference.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecIndexRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecPreparedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecutionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecutionFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecutionStmtValidator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/NoPutResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetStatisticsFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/RowChanger.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/RunTimeStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ScanQualifier.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/TargetResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/TemporaryRowHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/TupleFilter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/AccessFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/AccessFactoryGlobals.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BinaryOrderable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/ColumnOrdering.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/ConglomPropertyQueryable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/ConglomerateController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/DatabaseInstant.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/DynamicCompiledOpenConglomInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/FileResource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/GenericScanController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/GlobalXact.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/GroupFetchScanController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/KeyHasher.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/Qualifier.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowCountable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowLocationRetRowSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/ScanController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/ScanInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/SortController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/SortCostController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/SortInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/SortObserver.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/SpaceInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/StaticCompiledOpenConglomInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/StoreCostController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/StoreCostResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/TransactionController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/TransactionInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/XATransactionController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/Conglomerate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/ConglomerateFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/LogicalUndo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/MethodFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/ScanControllerRowSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/ScanManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/Sort.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/SortFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/conglomerate/TransactionManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/XAResourceManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/XAXactId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/AuxObject.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Compensation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/ContainerHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/ContainerKey.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/ContainerLock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Corruptable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/D_ContainerKey.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/D_ContainerLock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/D_RowLock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/FetchDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/GlobalTransactionId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/LockingPolicy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Loggable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/LogicalUndoable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Page.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/PageKey.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/PageTimeStamp.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RePreparable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RecordHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/RowLock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/ScanHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/ScannedTransactionHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/StreamContainerHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Transaction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Undoable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/data/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/data/DataFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/data/RawContainerHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogInstant.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/Logger.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/TransactionFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/TransactionId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BitDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BooleanDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CloneableObject.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/ConcatableDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeUtilities.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DateTimeDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DateTimeParser.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/JSQLType.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Like.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Orderable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/RefDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Resetable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/RowLocation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLInteger.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongVarbit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongint.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongvarchar.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLNClob.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLNationalChar.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLNationalLongvarchar.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLNationalVarchar.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLRef.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLSmallint.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTime.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTinyint.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLVarbit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLVarchar.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/StringDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/VariableSizeDataValue.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ByteArray.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/CheapDateFormatter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/DoubleProperties.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/JBitSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/Matchable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/Operator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/PropertyUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ReuseFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/StringUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/util/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/db/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/db/StoreClassFactoryContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/db/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/BaseStorageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPStorageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/DirFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/DirFile4.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/DirRandomAccessFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/DirRandomAccessFile4.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/DirStorageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/DirStorageFactory4.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/InputStreamFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarDBFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/JarStorageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/URLFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/URLStorageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/io/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/BinaryToRawStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement20.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection20.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnectionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement20.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet20.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLWarning.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSavepoint30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ReaderToAscii.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TransactionResourceImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/AuthenticationServiceBase.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/JNDIAuthenticationSchemeBase.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/JNDIAuthenticationService.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/LDAPAuthenticationSchemeImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/NoneAuthenticationServiceImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/SpecificAuthenticationServiceImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ControlInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/Export.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportAbstract.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportResultSetForObject.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportWriteData.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportWriteDataAbstract.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/Import.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportAbstract.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportReadData.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportResultSetMetaData.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/LoadError.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/load/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCClass.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCExpr.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCJava.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCLocalField.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCMethod.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCMethodCaller.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCMethodDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCUnsupported.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/CodeChunk.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Conditional.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/OpcodeDebug.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Type.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/VMTypeIdCacheable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/d_BCValidate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/CacheStat.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/CachedItem.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/Clock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/BasicDaemon.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/ServiceRecord.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/jce/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/jce/JCECipherFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/jce/JCECipherProvider.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ActiveLock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Constants.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Control.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/D_ActiveLock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/D_Lock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/D_LockControl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Deadlock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Lock.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockControl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockSpace.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockTableVTI.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/SinglePool.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/TableNameInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Timeout.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/FileMonitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/PersistentServiceImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/ProtocolKey.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/ReadOnly.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/ServiceBootContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/TopService.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/UpdateServiceProperties.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/DatabaseClasses.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/GCInstanceFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/JarFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/JarFileJava2.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/JarLoader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/LoadedGeneratedClass.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/ReflectClassesJava2.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/ReflectGeneratedClass.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/ReflectLoaderJava2.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/ReflectMethod.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/BasicGetLogHeader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/BasicHeaderPrintWriter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/stream/SingleStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/uuid/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/uuid/BasicUUID.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/uuid/BasicUUIDFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/services/uuid/BasicUUIDGetter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/CursorInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/CursorTableReference.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericClassInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericLanguageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericResultDescription.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStorablePreparedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/LanguageDbPropertySetter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/CoreDDFinderClassInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DDColumnDependableFinder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DDdependableFinder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryContextImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DropDependencyFilter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/IndexInfoImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/IndexScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/NameTDCacheable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/OIDTDCacheable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SPSNameCacheable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSALIASESRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCHECKSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCOLUMNSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCONGLOMERATESRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSCONSTRAINTSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSDEPENDSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSDUMMY1RowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSFILESRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSFOREIGNKEYSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSKEYSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSSCHEMASRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSSTATEMENTSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSSTATISTICSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSTABLESRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSTRIGGERSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSVIEWSRowFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/TDCacheable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/TabInfoImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/TableKey.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/metadata_net.properties   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AccessPathImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ActivationClassBuilder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateDefinition.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterSPSNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AndNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseJoinStrategy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryArithmeticOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CollectNodesVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnOrdering.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConstraintDefinitionNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CostEstimateImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CountAggregateDefinition.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateIndexNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateSchemaNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentDatetimeOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentIsolationNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentRowLocationNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CurrentUserNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DDLStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultVTIModDeferPolicy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropAliasNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropIndexNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropSPSNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropSchemaNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropTableNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropTriggerNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropViewNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExecSPSNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GetCurrentConnectionNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashNodeList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Level2CostEstimateImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Level2OptimizerFactoryImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Level2OptimizerImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LockTableNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaterializeResultSetNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaterializeSubqueryNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaxMinAggregateDefinition.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MiscellaneousStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NOPStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NestedLoopJoinStrategy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NotNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderedColumn.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderedColumnList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParseException.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParserImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QuantifiedBinaryOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QuantifiedUnaryOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReadCursorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReferencedTablesVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RelationalOperator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RemapCRsVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RenameNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceAggregatesWithCRVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowOrderingImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLBooleanConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SavepointNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ScrollInsensitiveResultSetNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetSchemaNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetTransactionIsolationNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StringSlicer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Token.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TransactionStatementNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TriggerReferencingStruct.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UCode_CharStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/CachedStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericStatementContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/TempTableInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependency.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicProviderInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/DepClassInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AddJarConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregateSortObserver.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregatorInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregatorInfoList.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterSPSConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AnyResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AutoincrementCounter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseExpressionActivation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicSortObserver.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BulkTableScanResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CardinalityCounter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstantActionActivation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CountAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateAliasConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateConstraintConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateIndexConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateSPSConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateSchemaConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateTableConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateTriggerConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CreateViewConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CurrentDatetime.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CurrentOfResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CursorActivation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DDLConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DDLSingleTableConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DMLVTIResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DMLWriteResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteCascadeResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteVTIResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DependentResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctGroupedAggregateResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctScanResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropAliasConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropConstraintConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropIndexConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropJarConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropSPSConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropSchemaConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropStatisticsConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTableConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropTriggerConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DropViewConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/FKInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ForeignKeyRIChecker.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericConstantActionFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericExecutionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericExecutionFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericQualifier.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericRIChecker.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericSPSConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericScanQualifier.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericTriggerExecutor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashJoinResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashLeftOuterJoinResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexChanger.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexColumnOrder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexRowToBaseRowResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexSetChanger.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexValueRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertVTIResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InternalTriggerExecutionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/JarDDL.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/JarUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/JoinResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/KeyToBaseRowConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/LastIndexKeyResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/LockTableConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MaterializedResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MaxMinAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MergeJoinResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NestedLoopJoinResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NestedLoopLeftOuterJoinResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoPutResultSetImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/OnceResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/OrderableAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RIBulkChecker.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RISetChecker.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RealResultSetStatisticsFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReferencedKeyRIChecker.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RenameConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReplaceJarConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowChangerImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowTriggerExecutor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SavepointConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetConstraintsConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetSchemaConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetTransactionIsolationConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetTransactionResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/StatementTriggerExecutor.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SumAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SystemAggregator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEvent.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEventActivator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEvents.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/UnionResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/UniqueIndexSortObserver.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/UpdatableVTIConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/UpdateConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/UpdateResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/UpdateStatisticsConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/UpdateVTIResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ValueRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/WriteCursorConstantAction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealAnyResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealBasicNoPutResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealCurrentOfStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteCascadeResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDeleteVTIResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScalarAggregateStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealDistinctScanStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealGroupedAggregateStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashJoinStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashLeftOuterJoinStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashScanStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealHashTableStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealIndexRowToBaseRowStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealInsertVTIResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealJoinResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealLastIndexKeyScanStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealMaterializedResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopJoinStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNestedLoopLeftOuterJoinStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNoPutResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNoRowsResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealNormalizeResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealOnceResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealProjectRestrictStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealRowResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScalarAggregateStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealScrollInsensitiveResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealSortStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealTableScanStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealUnionResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealUpdateResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RealVTIStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/ResultSetStatistics.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/rts/RunTimeStatisticsImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/BackingStoreHashTableFromScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/CacheableConglomerate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/PC_XenaVersion.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/PropertyConglomerate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMAccessManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMTransaction.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RAMTransactionContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/RllRAMAccessManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/StorableFormatId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/UTF.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/UTFQualifier.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTree.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeCostController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeForwardScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeLockingPolicy.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeMaxScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreePostCommit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeRowPosition.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeScanInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BranchControlRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BranchRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/ControlRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/D_BTreeController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/LeafControlRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/SearchParameters.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/WaitError.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2I.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2ICostController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IForwardScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IMaxScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2INoLocking.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking1.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking2.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking3.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLockingRR.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IStaticCompiledInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2ITableLocking3.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IUndo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/D_B2IController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/BinaryOrderableWrapper.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/ConglomerateUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerateController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericCostController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerateScratchSpace.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/QualifierUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/RowPosition.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/TemplateRow.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/D_HeapController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/Heap.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapClassInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapConglomerateFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapCostController.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapPostCommit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapRowLocation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapScanInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/OpenHeap.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/ExternalSortFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeInserter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeScanRowSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSortInfo.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/Node.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/NodeAllocator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/Scan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/SortBuffer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/SortBufferRowSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/SortBufferScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/SortScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPageOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocationActions.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocationCache.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainerHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BufferedByteHolderInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ByteHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ByteHolderInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ChainAllocPageOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ContainerActionOnCommit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ContainerBasicOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ContainerHandleActionOnCommit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ContainerOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ContainerUndoOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CopyRowsOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_BaseContainerHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_DiagnosticUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_RecordId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_StoredPage.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/DecryptInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/DeleteOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/DirectActions.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/DirectAllocActions.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/InitPageOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/InputStreamContainer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/InsertOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/InvalidatePageOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/LoggableActions.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/LoggableAllocActions.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/LogicalPageOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/LogicalUndoOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/LongColumnException.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/MemByteHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/NoSpaceOnPage.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/OverflowInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PageActions.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PageBasicOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PageVersion.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PhysicalPageOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PurgeOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RFResource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RawField.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpace.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RecordId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RememberBytesInputStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RemoveFileOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/SetReservedSpaceOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/SpaceInformation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredFieldHeader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredRecordHeader.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainerHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/SyncOnCommit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/TempRAFContainer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/TruncateOnCommit.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/UpdateFieldOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/UpdateOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/CheckpointOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/D_FlushedScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/D_LogToFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/D_TruncationPoint.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/FileLogger.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/FlushedScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/FlushedScanHandle.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogAccessFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogAccessFileBuffer.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogCounter.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogRecord.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/SaveLWMOperation.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/Scan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/StreamLogScan.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/TruncationPoint.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/BeginXact.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/ContainerLocking2.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/ContainerLocking3.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/D_Xact.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/EndXact.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/EscalateContainerKey.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/GlobalXactId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/InternalXact.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/NoLocking.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking1.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2nohold.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking3.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLocking3Escalate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/RowLockingRR.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/SavePoint.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTableEntry.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactContext.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactId.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactXAResourceManager.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/io/
   incubator/derby/code/trunk/java/engine/org/apache/derby/io/StorageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/io/StorageFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/io/StorageRandomAccessFile.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/io/WritableStorageFactory.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/io/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver169.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver30.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDriver.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/ReferenceableDataSource.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/ResourceAdapterImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/loc/
   incubator/derby/code/trunk/java/engine/org/apache/derby/loc/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/loc/messages.properties   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/modules.properties   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/osgi/
   incubator/derby/code/trunk/java/engine/org/apache/derby/osgi/EmbeddedActivator.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/osgi/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/DeferModification.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/IFastPath.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/IQualifyable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/Pushable.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/UpdatableVTITemplate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/VTICosting.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/VTIEnvironment.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/VTIMetaDataTemplate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/VTITemplate.java   (contents, props changed)
   incubator/derby/code/trunk/java/engine/org/apache/derby/vti/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/tools/
   incubator/derby/code/trunk/java/tools/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/
   incubator/derby/code/trunk/java/tools/org/apache/
   incubator/derby/code/trunk/java/tools/org/apache/derby/
   incubator/derby/code/trunk/java/tools/org/apache/derby/iapi/
   incubator/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/
   incubator/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/
   incubator/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedOutput.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_Check.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_Index.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_Jar.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_Key.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_Schema.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_StoredProcedure.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_Table.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_Trigger.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/DB_View.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/cslook/Logs.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/AsyncStatement.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/AttributeHolder.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ConnectionEnv.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main14.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ParseException.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Session.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/StatementFinder.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/UCode_CharStream.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijConnectionResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijException.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijExceptionResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijFatalException.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijMultiResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultImpl.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijRowResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijStatementResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijTokenException.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijVectorResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijWarningResult.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtGrammar.jj   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestSuite.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTester.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTime.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain14.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaAbstractHelper.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/ZipInfoProperties.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/loc/
   incubator/derby/code/trunk/java/tools/org/apache/derby/loc/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/loc/sysinfoMessages.properties   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/tools/
   incubator/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/tools/URLCheck.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/tools/build.xml   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/tools/ij.java   (contents, props changed)
   incubator/derby/code/trunk/java/tools/org/apache/derby/tools/sysinfo.java   (contents, props changed)
   incubator/derby/code/trunk/tools/
   incubator/derby/code/trunk/tools/ant/
   incubator/derby/code/trunk/tools/ant/properties/
   incubator/derby/code/trunk/tools/ant/properties/compilepath.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/defaultcompiler.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/dirs.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/extrapath.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/jikes.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/modern.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/release.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/sanefalse.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/ant/properties/sanetrue.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/jar/
   incubator/derby/code/trunk/tools/jar/DBMSnodes.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/jar/copyright.txt   (contents, props changed)
   incubator/derby/code/trunk/tools/jar/extraDBMSclasses.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/jar/extraDBMStypes.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/jar/net.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/jar/tools.properties   (contents, props changed)
   incubator/derby/code/trunk/tools/java/
   incubator/derby/code/trunk/tools/java/empty.jar   (contents, props changed)
   incubator/derby/code/trunk/tools/javadoc/
   incubator/derby/code/trunk/tools/javadoc/publishedapi.ant   (contents, props changed)
Log:
Initial code import

Added: incubator/derby/code/trunk/BUILDING.txt
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/BUILDING.txt	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,586 @@
+
+                     Building Derby
+================================================================
+
+Contents
+
+1     About this document
+1.1   Who should read this document
+1.2   Notes
+
+2     Downloads
+2.1   Download source code
+2.2   Download required software
+2.2.1 Download and install Apache Ant 1.6.x
+2.2.2 Download and install Java Development Kit release 1.4.x
+2.2.3 Download and install Java Development Kit release 1.3.x
+2.2.4 Download extensions for Java Development Kit release 1.3.x
+2.2.5 Download Java Compiler Compiler (JavaCC) version 3.1
+2.2.6 Download jakarta-servlet API 4 (Servlet 2.4)
+2.2.7 Download OSGi Service Platform release 3 (osgi.jar) (Optional)
+2.2.8 Download Jikes 1.14 (Optional)
+
+3     Build instructions
+3.1   Set required environmental variables
+3.2   Create property file
+3.3   Run Derby build
+3.4   Verify Derby build
+
+4     Derby build miscellaneous information
+4.1   Derby build targets
+4.2   Derby source code upgrade
+4.3   Derby build flow
+
+
+---------------------------------------------------------------
+1     About this document
+
+This document contains the instructions to build a binary
+distribution version of the derby database from a source 
+distribution. 
+
+
+
+1.1   Who should read this document
+
+This document is intended for any one interested in 
+downloading and building a binary distribution of
+derby source distribution. 
+
+
+
+1.2   Notes
+
+The following conventions are followed in the document:
+
+(1) The directories are referred in unix convention.
+    For Windows, / should be replaced with \.
+
+(2) All examples or commands are given in unix conventions.
+    For Windows, modify the examples or commands as per
+    windows conventions.
+ 
+(3) This document contains urls to download required
+    software for derby builds. Urls may change anytime.
+    If there is any problem with any url, notify it
+    via derby mailing list.
+
+
+
+---------------------------------------------------------------
+2     Downloads
+
+Prior to building derby source code, download derby source
+code and required software as following:
+
+
+
+2.1   Download source code
+
+Create a new directory and download derby source code in 
+this directory. This directory will be referred to as the 
+${derby.source} directory in the rest of this document. 
+
+After downloading source code to directory ${derby.source},
+there should be the following files and directories:
+
+${derby.source}/build.xml 
+${debry.source}/java 
+${derby.source}/tools 
+
+
+
+2.2   Download required software
+
+This section lists all the required software for Derby
+build environment.
+
+Notes:
+----- 
+(1) Derby build environment requires you to install two levels of 
+    Java Development Kit (JDK) - 1.3.x and 1.4.x as Derby is designed 
+    to work in JDK1.3.x (JDBC 2.0) and JDK 1.4.x (JDBC 3.0) 
+    environments. The Derby build is set up such that that most of 
+    the code is compiled against JDK 1.3.x libraries so that no 
+    dependencies on JDK 1.4.x classes exist, except for the code 
+    that only runs in JDK1.4.x. In addition Derby's JDBC 2.0 
+    implementation must compile against JDBC 2.0 class definitions 
+    and the JDBC 3.0 implementation against JDBC 3.0 class 
+    definitions.
+
+(2) The Derby build environment is tested with JDK 131 (Sun), 
+    JDK 141(Sun), and Ant 161. The Derby build environment should
+    work with other versions and other sources of JDK 13 (1.3.x) 
+    and JDK 14 (1.4.x), and other versions of Ant 1.6 (1.6.x).
+
+
+
+2.2.1 Download and install Apache Ant 1.6.x
+
+(1) Download a binary distribution of Ant 1.6.x from:
+         http://ant.apache.org/bindownload.cgi
+
+(2) Install Ant 1.6.x in any directory. This 
+    directory will be referred to as ${ant.dir} 
+    directory in the rest of this document. 
+
+
+
+2.2.2 Download and install Java Development Kit (JDK) release 1.4.x
+
+Skip steps 1-2 of this section if you already have JDK 1.4.x 
+installed on your system.  
+
+(1) Download JDK 1.4.x. 
+    The reference implementation is available at:
+       http://java.sun.com/j2se
+
+(2) Install JDK 1.4.x according to the instructions included 
+    with the release in any directory. 
+
+(3) The directory where you have installed JDK 1.4.x will be 
+    referred to as ${jdk14.dir} in the rest of this document.
+
+
+
+2.2.3 Download and install Java Development Kit (JDK) release 1.3.x
+
+Skip steps 1-2 of this section if you already have JDK 1.3.x 
+installed on your system.  
+
+(1) Download JDK 1.3.x. 
+    The reference implementation is available at:
+       http://java.sun.com/j2se
+
+(2) Install JDK 1.3.x according to the instructions included 
+    with the release in any directory. 
+
+(3) The directory where you have installed JDK 1.3.x will be 
+    referred to as ${jdk13.dir} in the rest of this document.
+
+
+
+2.2.4 Download extensions for Java Development Kit release 1.3.x
+
+(1) JDBC 2.0
+
+    Download JDBC 2.0 (jdbc2_0-stdext.jar) from:
+      http://java.sun.com/products/jdbc/download.html
+    by selecting "JDBC 2.0 Optional Package Binary".
+
+    Save jdbc2_0-stdext.jar file in directory
+      ${derby.source}/tools/java 
+
+
+(2) Java Transaction API (JTA) 1.0.1B
+
+    Download JTA 1.0.1B (jta-1_0_1B-classes.zip) from:
+      http://java.sun.com/products/jta/ 
+    by selecting "Class files".
+
+    Save jta-1_0_1B-classes.zip file in directory
+      ${derby.source}/tools/java 
+
+
+(3) Java Cryptography Extension (JCE) version 1.2.2
+
+    Download JCE 1.2.2 (jce-1_2_2.zip) from:
+      http://java.sun.com/products/jce/index-122.html
+
+    Note: You will need to register to download JCE 1.2.2.
+
+    The downloaded file (jce-1_2_2.zip)  for JCE contains 
+    documentation files and multiple jar files. After 
+    downloading the zip file, unzip the file and copy only 
+    jce1.2.2/lib/jce1_2_2.jar file to directory 
+      ${derby.source}/tools/java
+
+
+
+2.2.5 Download Java Compiler Compiler (JavaCC) version 3.1
+
+JavaCC 3.1 (javacc-3.1.zip or javacc-3.1.tar.gz) can be 
+downloaded from:
+    https://javacc.dev.java.net/
+
+Note: The latest available version of JavaCC is 3.2.
+However, JavaCC 3.1 is the requirement for Derby build
+environment.
+
+The downloaded file (javacc-3.1.zip or javacc-3.1.tar.gz) 
+contains documentation and other files. After downloading 
+the zip or tar file, unzip or untar the file and copy only 
+javacc-3.1/bin/lib/javacc.jar file to directory 
+   ${derby.source}/tools/java 
+
+
+
+2.2.6 Download jakarta-servlet API 4 (Servlet 2.4)
+
+jakarta-servlet API 4 (jakarta-servletapi-4-yyyymmdd.zip or
+jakarta-servletapi-4-yyyymmdd.tar.gz) can be downloaded from:
+   http://cvs.apache.org/builds/jakarta-servletapi-4/nightly/
+
+Note: There is zip and tar file for nightly build for every day.
+Download the zip or tar file for latest day.
+ 
+The downloaded file (jakarta-servletapi-4-yyyymmdd.zip or
+jakarta-servletapi-4-yyyymmdd.tar.gz) contains documentation and 
+other files. After downloading the zip or tar file, unzip or 
+untar the file and copy only jakarta-servletapi-4/lib/servlet.jar 
+file to directory 
+   ${derby.source}/tools/java 
+
+
+
+2.2.7 Download OSGi Service Platform release 3 (osgi.jar) (Optional)
+
+This is an optional section.
+The reason is that osgi.jar is required to only build the 
+class org.apache.derby.osgi.EmbeddedActivator. This class 
+and jar file manifest entries created in derby.jar allow 
+that jar file to be an OSGi bundle. If osgi.jar is not 
+present EmbeddedActivator will not be build and derby.jar 
+will not contain the manifest entries to be an OSGi bundle.
+
+OSGi Service Platform release 3 (osgi.jar) can be downloaded from: 
+   http://osgi.org
+
+Note: You will need to register to download OSGi Service Platform 
+      release 3.
+
+The downloaded file should be copied to directory
+   ${derby.source}/tools/java 
+
+
+
+Note: After following the steps in sections 2.2.4-2.2.7 of this
+document, you should have the following:
+
+${derby.source}/tools/java/javacc.jar
+${derby.source}/tools/java/jce1_2_2.jar 
+${derby.source}/tools/java/jdbc2_0-stdext.jar
+${derby.source}/tools/java/jta-1_0_1B-classes.zip 
+${derby.source}/tools/java/servlet.jar
+${derby.source}/tools/java/osgi.jar
+
+
+
+2.2.8 Download and Install Jikes 1.14 (Optional)
+
+This is an optional section.
+
+Jikes is an open source java compiler that improves compile 
+speed over standard java compiler. If you would like to have 
+improved compile speed, you can proceed to install Jikes. 
+Jikes 1.14 is the required version for derby builds.
+
+Jikes 1.14 can be downloaded from:
+    http://www.ibm.com/developerworks/oss/jikes/
+     
+Install Jikes 1.14 in any directory. This directory will be 
+referred to as the ${jikes.dir} directory in the rest of this 
+document. 
+
+
+
+---------------------------------------------------------------
+3     Build instructions
+
+
+3.1   Set Required Environmental Variables
+
+(1) Create environment variable ANT_HOME  to point to the 
+    directory where you have installed Ant. For example:
+
+     setenv ANT_HOME ${ant.dir} -- On unix(csh)
+     export ANT_HOME=${ant.dir} -- On unix(ksh)
+     set ANT_HOME=${ant.dir}    -- On Windows
+
+(2) Modify the PATH environment variable to include the 
+    directory ${ant.dir}/bin in its list. This makes the "ant" 
+    command line script available, which will be used to 
+    actually perform the build. Also, if you opted to install
+    jikes in section 2.2.8 of this document, add ${jikes.dir} 
+    to the PATH as well. For example:
+
+     setenv PATH ${ant.dir}/bin:${jikes.dir}:$PATH -- On unix(csh)
+     export PATH=${ant.dir}/bin:${jikes.dir}:$PATH -- On unix(ksh)
+     set PATH=${ant.dir}\bin;${jikes.dir};%PATH%   -- On Windows
+
+(3) Create environment variable JAVA_HOME  to point to the 
+    directory where you have installed JDK 1.4.x. For example:
+
+     setenv JAVA_HOME ${jdk14.dir} -- On unix(csh).
+     export JAVA_HOME=${jdk14.dir} -- On unix(ksh)
+     set JAVA_HOME=${jdk14.dir}    -- On Windows
+
+
+
+3.2   Create property file
+
+You will need to create a property file to specify
+your environment and some of your options. Do the following
+to specify your environment and options:
+
+(1) Find out user home directory on your system. You can find  
+    user home directory by doing echo on variable %HOME% 
+    on windows and $home or $HOME on unix.
+
+(2) Create a file called "ant.properties" in user home 
+    directory and define the following variables in 
+    "ant.properties":
+   
+    - j14lib
+
+      This is a required variable which defines the location of
+      JDK 1.4.x. Define the variable as following:
+
+          j14lib=${jdk14.dir}/jre/lib
+      
+      where ${jdk14.dir} is the directory name where you have 
+      installed JDK 1.4.x. Check out section 2.2.2 of this document. 
+
+    - j13lib
+
+      This is a required variable which defines the location of
+      JDK 1.4.x. Define the variable as following:
+
+          j13lib=${jdk13.dir}/jre/lib
+
+      where ${jdk13.dir} is the directory name where you have 
+      installed JDK 1.3.x. Check out section 2.2.3 of this document.
+      
+    - build.compiler
+
+      This variable defines if standard java compiler or jikes is 
+      used for build. The default value of this variable is set to 
+      use standard java compiler for build. If you opted to install
+      jikes in section 2.2.8 of this document, you can give your 
+      option to use jikes for build by overwriting default value of 
+      this variable by setting it as following: 
+   
+          build.compiler=jikes
+
+    - proceed
+
+      This variable directs Ant to proceed past any build errors and  
+      complete rest of the build (when set to true) or stop build any 
+      time an error is found (when set to false). The default value 
+      for this variable is false. You can overwrite default value 
+      by setting it to true by defining the variable as following: 
+
+           proceed=true
+
+    - sane
+
+      By default this variable is set to true and builds
+      extra asserts and debugging information in the class
+      files. When set to false no extra asserts or debugging 
+      information is included in the class files, making Derby
+      run faster as it generates smaller class files.
+      You can overwrite default value by setting it to false by
+      defining the variable as following: 
+
+          sane=false
+
+      Typically applications embedding Derby would use jar files 
+      built with sane=false.
+
+3.3   Run Derby build
+
+(1) Go to directory ${derby.source}.
+
+(2) Run the following command to start build:
+     
+    >ant
+
+    The above command will build all classes into
+    ${derby.source}/classes. If you add this directory
+    in your classpath, you will have full functionality
+    of engine, tools, and network server. 
+
+(3) Run the following command to build all jars:
+    
+    >ant buildjars
+
+    The above command will build the following jar files:
+    - derby.jar (database engine), 
+    - derbytools.jar (utilities: sysinfo, dblook, ij) 
+    - derbynet.jar (network server).
+
+    You can run the ant command to build an individual jar
+    file as following:
+    - command "ant derbyjar" to build derby.jar
+    - command "ant derbytoolsjar" to build derbytools.jar
+    - command "ant derbynetjar" to build derbynet.jar
+
+Notes: 
+(1) The estimated total time for build completion is ~5-10 minutes.
+
+(2) Derby build environment is NOT dependency based build environment.
+    Make sure to check out explaination of "clobber" target in
+    section 4.1 of this document.
+
+
+
+3.4   Verify Derby build
+
+To verify if the Derby build was successful, do the
+following:
+
+(1) Run "ant" command again and nothing should happen. No 
+    files should get compiled, copied or generated. 
+
+(2) Check if the following directories were created:
+      - ${derby.source}/classes
+      - ${derby.source}/jars if you have built the 
+        jars in step 3 of section 3.3
+
+(3) Execute the following command:
+    
+    >java -cp ${derby.source}/classes org.apache.derby.tools.sysinfo
+
+    You can also execute one of the following commands if you 
+    have built the jars in step 3 of section 3.3:
+
+    For builds with sane=true
+    >java -cp ${derby.source}/jars/sane/derby.jar:${derby.source}/jars/sane/derbytools.jar org.apache.derby.tools.sysinfo
+
+    For builds with sane=false
+    >java -cp ${derby.source}/jars/insane/derby.jar:${derby.source}/jars/insane/derbytools.jar org.apache.derby.tools.sysinfo
+
+    The above commands should report the system info and output 
+    should look like the following:
+
+    ------------------ Java Information ------------------
+    Java Version:    1.4.1_07
+    Java Vendor:     Sun Microsystems Inc.
+    Java home:       C:\Program Files\Java\j2re1.4.1_07
+    Java classpath:  c:\derby\classes
+    OS name:         Windows 2000
+    OS architecture: x86
+    OS version:      5.0
+    Java user name:  derbyuser
+    Java user home:  C:\Documents and Settings\Administrator
+    Java user dir:   C:\derby
+    --------- Derby Information --------
+    [C:\derby\classes] 10.0.2.0 - (1)
+    ------------------------------------------------------
+    ----------------- Locale Information -----------------
+    ------------------------------------------------------
+
+
+(4) Execute the following command:
+    
+    >java -cp ${derby.source}/classes org.apache.derby.tools.ij 
+
+    You can also execute one of the following commands if you 
+    have built the jars in step 3 of section 3.3:
+
+    For builds with sane=true
+    >java -cp ${derby.source}/jars/sane/derby.jar:${derby.source}/jars/sane/derbytools.jar org.apache.derby.tools.ij 
+
+    For builds with sane=false
+    >java -cp ${derby.source}/jars/insane/derby.jar:${derby.source}/jars/insane/derbytools.jar org.apache.derby.tools.ij 
+                
+   
+(5) Execute the following statement: 
+
+    connect 'jdbc:derby:test;create=true'; 
+
+    The above statement should create and connect to a 
+    database with no errors.
+
+
+
+---------------------------------------------------------------
+4     Derby build miscellaneous information
+
+This section provides miscellaneous information about
+Derby builds. 
+
+
+
+4.1   Derby build targets
+
+Some of the main targets that can be called as
+"ant targetname" are as the  following:
+
+  source: to build source code. This is default target.
+
+  javadoc: to create javadoc for all source code.
+
+  publishedapi: to create javadoc for application api classes.
+
+  buildjars: to create jar files
+
+  clobber: remove all built objects except jars. You should run
+           this target if you have source code upgrade or
+           you changed the source code and you are getting
+           some errors.
+
+  clean: remove output directory (${derby.source}/classes)
+
+  cleanjars: remove jars directory (${derby.source}/jars)
+
+  cleandocs: remove javadoc directory (${derby.source}/javadoc)
+
+
+
+4.2   Derby source code upgrade
+
+After upgrading derby source code, do the following before 
+building the code as per instructions given in section 3.3:
+
+(1) Go to directory ${derby.source}.
+
+(2) Run the following command to clean up:
+
+    >ant clobber
+
+
+
+4.3   Derby Build flow
+
+This section provides the information on Derby build flow.
+This section can be skipped unless you are really interested
+in learning about Derby build flow.
+    
+Initially, Ant generates state.properties. This file contains 
+a single property, sanity, with a boolean value that determines 
+the sanity state of the build. 'Sanity' was a concept introduced 
+early in Cloudscape as a way of having assert functionality 
+in the code before Java actually supported such functionality 
+syntactically. It was a way to keep development 'sane,' 
+thus the name. Assertions are contained in an if-block based 
+on the static final boolean values SanityState.DEBUG or 
+SanityState.ASSERT, which are true in a sane (debug) build, 
+and false in an insane (non-debug/optimized) build. 
+Therefore, in an insane build, a smart compiler will not 
+write the code in the if-block into the classfile, since 
+it would never be run. 
+
+The source file containing the static final boolean values of the
+sanity state, org.apache.derby.iapi.services.sanity.SanityState 
+is then generated from a template. The sanity state defaults to 
+true. This also directs the compiler to turn on all debugging 
+options on the compiler. The sanity state can be set to insane 
+by running 'ant insane' or passing in the value -Dsane=false or 
+-Dsanity=false. Note that this file will be removed after 
+'ant clobber,' so if you are rebuilding from scratch and want 
+the build to be a non-debug build, run 'ant insane' before 
+building.
+
+Once the sanity state has been generated, Ant prints out for 
+reference the current properties that affect the build, 
+including base directory, output directory, compiler, 
+sanity state, and the value of the java property 'proceed.' 
+ 
+Next, the parser files are generated with JavaCC. Once the parser 
+files have been generated, the compilation of the source files 
+begins. The source is compiled in a specific order, that order 
+being: reference, internal API, public API, implementation. 
+At the end of the build, the properties files containing the 
+message files are copied into the output directory and the 
+version information properties files are generated.

Added: incubator/derby/code/trunk/build.xml
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/build.xml	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,770 @@
+<?xml version="1.0"?>
+
+<project default="buildsource" basedir=".">
+
+<!-- Set Properties -->
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+  <!-- Set property lib dir -->
+  <property name="properties.dir" value="tools/ant/properties"/>
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/sane${sanity}.properties"/>
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+  <!-- Release and version info -->
+  <property file="${properties.dir}/release.properties"/>
+
+<!-- Targets -->
+
+  <target name="buildsource" depends="init,engine,tools,drda,build,versioninfo"/>
+
+<!-- ==================================================================== -->
+<!--                       Initialize targets                             -->
+<!-- ==================================================================== -->
+
+  <target name="init" unless="init.done">
+    <tstamp/>
+    <mkdir dir="${out.dir}"/>
+    <!-- generate sanity state.properties if one does not exist -->
+    <available property="state.available" file="${state.file}"/>
+    <antcall target="ensuresanitystate"/>
+    <property file="${state.file}"/>
+    <property file="${properties.dir}/sane${sanity}.properties"/>
+    <antcall target="setissane"/>
+    <property name="init.done" value="true"/>
+  </target>
+
+  <target name="setissane">
+    <condition property="is.sane">
+      <equals arg1="${sanity}" arg2="true"/>
+    </condition>
+  </target>
+
+  <target name="ensuresanitystate" unless="state.available">
+    <antcall target="sane"/>
+  </target>
+
+  <target name="showenv" depends="init" unless="showenv.done">
+    <echo message=""/>
+    <echo message="Ant environment:"/>
+    <echo message="  Base Directory: ${basedir}"/>
+    <echo message="  Build output: ${out.dir}"/>
+    <echo message="  Compiler: ${build.compiler}"/>
+    <echo message="  Sane = ${sane}"/>
+    <echo message="  Proceed = ${proceed}"/>
+    <echo message=""/>
+    <property name="showenv.done" value="true"/>
+  </target>
+
+<!-- ==================================================================== -->
+<!--                     Build version info files                         -->
+<!-- ==================================================================== -->
+
+  <target name="versioninfo" depends="ckversioninfo,writeversioninfo"/>
+
+  <target name="ckversioninfo">
+    <condition property="versioninfo.available">
+      <and>
+        <available file="${out.dir}/org/apache/derby/info/DBMS.properties"/>
+        <available file="${out.dir}/org/apache/derby/info/tools.properties"/>
+        <available file="${out.dir}/org/apache/derby/info/net.properties"/>
+      </and>
+    </condition>
+  </target>
+
+  <target name="writeversioninfo" unless="versioninfo.available">
+    <mkdir dir="${out.dir}/org/apache/derby/info/"/>
+
+    <antcall target="infowriter">
+      <param name="info.buildnumber" value="1"/>
+      <param name="info.iname" value="Apache Derby Embedded Engine"/>
+      <param name="info.ename" value="Apache Derby"/>
+      <param name="info.productfile" value="codeline"/>
+      <param name="info.file" value="${out.dir}/org/apache/derby/info/DBMS.properties"/>
+    </antcall>
+    <antcall target="infowriter">
+      <param name="info.buildnumber" value="1"/>
+      <param name="info.iname" value="Apache Derby Tools"/>
+      <param name="info.ename" value="Apache Derby"/>
+      <param name="info.productfile" value="codeline"/>
+      <param name="info.file" value="${out.dir}/org/apache/derby/info/tools.properties"/>
+    </antcall>
+    <antcall target="infowriter">
+      <param name="info.buildnumber" value="1"/>
+      <param name="info.iname" value="Apache Derby Network Server"/>
+      <param name="info.ename" value="Apache Derby"/>
+      <param name="info.productfile" value="codeline"/>
+      <param name="info.file" value="${out.dir}/org/apache/derby/info/net.properties"/>
+    </antcall>
+  </target>
+
+  <target name="cleanversion">
+    <delete file="${out.dir}/org/apache/derby/info/DBMS.properties"/>
+    <delete file="${out.dir}/org/apache/derby/info/tools.properties"/>
+    <delete file="${out.dir}/org/apache/derby/info/net.properties"/>
+  </target>
+<!-- ==================================================================== -->
+<!--                         Info writer build target                     -->
+<!-- ==================================================================== -->
+
+  <target name="infowriter">
+    <propertyfile file="${info.file}" comment="${copyright.comment}">
+      <entry key="derby.version.major" value="${major}"/>
+      <entry key="derby.version.minor" value="${minor}"/>
+      <entry key="derby.version.maint" value="${maint}"/>
+      <entry key="derby.version.drdamaint" value="${drdamaint}"/>
+      <entry key="derby.build.number" value="${info.buildnumber}"/>
+      <entry key="derby.product.technology.name" value="${info.iname}"/>
+      <entry key="derby.product.external.name" value="${info.ename}"/>
+      <entry key="derby.product.external.version" value="${eversion}"/>
+      <entry key="derby.version.beta" value="${beta}"/>
+      <entry key="derby.product.vendor" value="${vendor}"/>
+      <entry key="derby.product.file" value="${info.productfile}"/>
+    </propertyfile>
+  </target>  
+
+
+<!-- ==================================================================== -->
+<!--                   Derby Engine build target                     -->
+<!-- ==================================================================== -->
+
+  <target name="engine" depends="state,parsers">
+    <ant dir="${derby.engine.src.dir}"/>
+    <antcall target="build"/>
+    <ant dir="${derby.engine.dir}/loc"/>
+    <antcall target="class_size_catalog"/>
+  </target>
+
+  <target name="tools" depends="engine">
+    <ant dir="${derby.tools.src.dir}"/>
+  </target>
+
+  <target name="drda" depends="engine">
+    <ant dir="${derby.drda.src.dir}"/>
+  </target>
+
+  <target name="build" >
+    <ant dir="${derby.build.src.dir}"/>
+  </target>
+
+<!-- ==================================================================== -->
+<!--                     Build SanityState.java                           -->
+<!-- ==================================================================== -->
+
+  <target name="getstate">
+    <condition property="needstate">
+      <or>
+        <not>
+          <equals arg1="${sane}" arg2="${sanity}"/>
+        </not>
+        <not>
+          <available file="${sanity.dir}/SanityState.java"/>
+        </not>
+      </or>
+    </condition>
+  </target>
+
+  <property name="state.file" value="${derby.engine.src.dir}/state.properties"/>
+  <property file="${state.file}"/>
+  <target name="state" if="needstate"
+          depends="showenv,getstate"
+          description="Build SanityState.java">
+    <echo message="  Generating SanityState.java..."/>
+    <property name="sane" value="true"/>
+    <filter token="SANE" value="${sane}"/>
+    <copy file="${sanity.dir}/SanityState.tmpl"
+          tofile="${sanity.dir}/SanityState.java"
+          overwrite="yes" filtering="on"/>
+    <property name="header" value="Generated file - do not modify!"/>
+    <propertyfile file="${state.file}" comment="${header}">
+      <entry key="sanity" value="${sane}" type="string"/>
+    </propertyfile>
+    <delete dir="${sanity.out.dir}"/>
+  </target>
+
+<!-- =================================================================== -->
+<!--                     Remove SanityState.java file                    -->
+<!-- =================================================================== -->
+  <target name="cleanstate">
+    <delete file="${derby.engine.src.dir}/state.properties"/>
+    <delete file="${sanity.dir}/SanityState.java"/>
+    <delete dir="${sanity.out.dir}"/>
+  </target>
+
+<!-- =================================================================== -->
+<!--                 Remove all built objects (except jars)              -->
+<!-- =================================================================== -->
+  <target name="clobber" depends="showenv,clean,cleanstate,cleanparsers,cleancatalog"/>
+
+<!-- =================================================================== -->
+<!--                       Remove output tree                            -->
+<!-- =================================================================== -->
+  <target name="clean">
+    <delete dir="${out.dir}"/>
+  </target>
+
+<!-- ==================================================================== -->
+<!--                         Build parsers                                -->
+<!-- ==================================================================== -->
+  <target name="parsers"
+          description="Build the parsers">
+    <ant dir="${derby.tools.dir}/impl/tools"  target="parser"/>
+    <ant dir="${derby.engine.dir}/impl/sql"  target="parser"/>
+  </target>
+
+  <target name="genParser" depends="chkparser" unless="parser.done">
+    <echo message="  ${msg}"/>
+    <delete>
+      <fileset dir="${directory}" includes="${rmfiles}"/>
+    </delete>
+    <java classname="javacc"
+          classpath="${jjpath}"
+                dir="${directory}"
+               fork="yes"
+        failonerror="true">
+      <arg value="${jjfile}"/>
+    </java>
+  </target>
+
+  <target name="chkparser">
+    <uptodate property="parser.done"
+              targetfile="${directory}/${chkfile}" >
+      <srcfiles dir="${directory}" includes="${jjfile}" />
+    </uptodate>
+  </target>
+
+<!-- =================================================================== -->
+<!--                     Remove parser-generated files                   -->
+<!-- =================================================================== -->
+  <target name="cleanparsers">
+    <delete>
+      <fileset dir="${derby.engine.dir}/impl/sql/compile" includes="SQLParser.java,SQLParserTokenManager.java,SQLParserConstants.java"/>
+    </delete>
+    <delete>
+      <fileset dir="${derby.tools.dir}/impl/tools/ij"
+            includes="ij.java ijTokenManager.java ijConstants.java Token.java,mtGrammar.java,mtGrammarConstants.java,mtGrammarTokenManager.java"/>
+    </delete>
+  </target>
+
+<!-- =================================================================== -->
+<!--                     Class Size Catalog build                        -->
+<!-- =================================================================== -->
+
+  <!-- Note that checking the up-to-date status of the files scanned by  -->
+  <!-- ClassSizeCrawler will not always result in the ClassSizeCatalog   -->
+  <!-- being updated properly. We would have to be able to scan the full -->
+  <!-- dependency tree. This does prevent recompilation in most cases,   -->
+  <!-- and requires it in the most obvious. If there is concern that     -->
+  <!-- the ClassSizeCatalog may have changed significantly since the     -->
+  <!-- last build, run cleancatalog and rebuild to regenerate it.        -->
+
+  <target name="class_size_catalog" depends="cscuptodate" unless="csc.uptodate"
+          description="create the class size catalog -- a java file">
+    <java classname="org.apache.derbyBuild.ClassSizeCrawler"
+          fork="yes"
+          failonerror="yes">
+      <classpath>
+        <pathelement path="${out.dir}"/>
+        <pathelement path="${compile.classpath}"/>
+      </classpath>
+      <jvmarg value="-DWS=${workspace}"/>
+      <jvmarg value="-DclassDir=${out.dir}"/>
+      <jvmarg value="-Dout=${derby.engine.src.dir}/${derby.dir}/iapi/services/cache/ClassSizeCatalog.java"/>
+      <jvmarg value="-Dprefix.1=org.apache.derby.iapi.types"/>            
+      <jvmarg value="-Dprefix.2=org.apache.derby.impl"/>
+      <arg value="org.apache.derby.iapi.types.DataValueDescriptor"/>
+      <arg value="org.apache.derby.impl.services.cache.CachedItem"/>
+      <arg value="org.apache.derby.impl.store.raw.data.RecordId"/>
+      <arg value="org.apache.derby.iapi.store.raw.ContainerKey"/>
+      <arg value="org.apache.derby.iapi.services.cache.SizedCacheable"/>
+      <arg value="java.lang.ref.WeakReference"/>
+      <arg value="java.math.BigDecimal"/>
+      <arg value="java.util.ArrayList"/>
+      <arg value="java.util.GregorianCalendar"/>
+    </java>
+
+    <javac
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="${debug}"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.engine.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${compile.classpath}"/>
+      </classpath>
+      <include name="${derby.dir}/iapi/services/cache/ClassSizeCatalog.java"/>
+    </javac>
+
+  </target>
+
+  <target name="cscuptodate">
+    <condition property="csc.uptodate">
+      <and>
+        <uptodate srcfile="${osengsrc.dir}/org/apache/derby/iapi/types/DataValueDescriptor.java"
+                  targetfile="${out.dir}/org/apache/derby/iapi/types/DataValueDescriptor.class"/>
+        <uptodate srcfile="${osengsrc.dir}/org/apache/derby/impl/services/cache/CachedItem.java"
+                  targetfile="${out.dir}/org/apache/derby/impl/services/cache/CachedItem.class"/>
+        <uptodate srcfile="${osengsrc.dir}/org/apache/derby/impl/store/raw/data/RecordId.java"
+                  targetfile="${out.dir}/org/apache/derby/impl/store/raw/data/RecordId.class"/>
+        <uptodate srcfile="${osengsrc.dir}/org/apache/derby/iapi/store/raw/ContainerKey.java"
+                  targetfile="${out.dir}/org/apache/derby/iapi/store/raw/ContainerKey.class"/>
+        <uptodate srcfile="${osengsrc.dir}/org/apache/derby/iapi/services/cache/SizedCacheable.java"
+                  targetfile="${out.dir}/org/apache/derby/iapi/services/cache/SizedCacheable.class"/>
+        <available file="${osengsrc.dir}/org/apache/derby/iapi/services/cache/ClassSizeCatalog.java"/>
+      </and>
+    </condition>
+  </target>
+
+  <target name="cleancatalog"
+          description="Remove the generated catalog java file.">
+    <delete file="${derby.engine.dir}/iapi/services/cache/ClassSizeCatalog.java"/>
+  </target>
+
+<!-- =================================================================== -->
+<!--                     Generate sanity.properties                      -->
+<!-- =================================================================== -->
+
+  <target name="sane">
+    <propertyfile file="${state.file}" comment="${header}">
+      <entry key="sanity" value="true" type="string"/>
+    </propertyfile>
+  </target>
+  <target name="insane">
+    <propertyfile file="${state.file}" comment="${header}">
+      <entry key="sanity" value="false" type="string"/>
+    </propertyfile>
+  </target>
+
+
+<!-- =================================================================== -->
+<!--                           Javadoc targets                           -->
+<!-- =================================================================== -->
+
+  <target name="javadoc" depends="publishedapi,derbydocs,toolsdocs,grammardocs"/>
+
+  <target name="publishedapi">
+
+    <delete dir="${basedir}/javadoc/publishedapi"/>
+    <delete dir="${basedir}/javadoc/sourcedir"/>
+    <mkdir dir="${basedir}/javadoc/publishedapi"/>
+    <mkdir dir="${basedir}/javadoc/sourcedir"/>
+
+    <!-- drda files -->
+    <mkdir dir="${basedir}/javadoc/sourcedir"/>
+    <copy todir="${basedir}/javadoc/sourcedir"> 
+      <fileset dir="${derby.drda.src.dir}"
+               includesfile="${javadoctools.dir}/publishedapi.ant"/>
+    </copy>
+	
+    <!-- engine files -->
+    <copy todir="${basedir}/javadoc/sourcedir">
+      <fileset dir="${derby.engine.src.dir}"
+               includesfile="${javadoctools.dir}/publishedapi.ant"/>
+    </copy>
+
+    <!-- tools files -->
+    <copy todir="${basedir}/javadoc/sourcedir">
+      <fileset dir="${derby.tools.src.dir}"
+               includesfile="${javadoctools.dir}/publishedapi.ant"/>
+    </copy>
+
+    <javadoc sourcepath="${basedir}/javadoc/sourcedir/"
+             classpath="${compile.classpath};${osgi};${servlet22};${out.dir}"
+             breakiterator="true"
+             destdir="${basedir}/javadoc/publishedapi"
+             packagenames="org.apache.derby.authentication,org.apache.derby.drda,org.apache.derby.jdbc.io,org.apache.derby.jdbc,org.apache.derby.tools"
+             Windowtitle="Apache Derby ${major}.${minor} API Documentation"
+             Doctitle="Apache Derby ${major}.${minor} API Documentation"
+             bottom="Apache Derby ${major}.${minor} API Documentation  -  &lt;i&gt;Copyright &amp;copy; IBM Corp. 1997,2004 All Rights Reserved.&lt;/i&gt;"/>
+
+    <delete dir="${basedir}/javadoc/sourcedir"/>
+
+  </target>
+
+  <target name="derbydocs">
+
+    <delete dir="${basedir}/javadoc/engine"/>
+    <mkdir dir="${basedir}/javadoc/engine"/>
+
+    <antcall target="javadocsubpackages">
+      <param name="javadoc.sourcepath" value="${derby.engine.src.dir};${derby.drda.src.dir};${derby.tools.src.dir}"/>
+      <param name="javadoc.classpath" value="${basedir}/classes;${java14compile.classpath};${jars.extras};${osgi}"/>
+      <param name="javadoc.destdir" value="${basedir}/javadoc/engine"/>
+      <param name="javadoc.subpackages" value="org.apache.derby"/>
+      <param name="javadoc.doctitle" value="Apache Derby V${major}.${minor} Engine Documentation"/>
+      <param name="javadoc.windowtitle" value="Apache Derby V${major}.${minor} Engine Documentation"/>
+      <param name="javadoc.bottom" value="Apache Derby V${major}.${minor} Engine Documentation  -  &lt;i&gt;Copyright &amp;copy; IBM Corp. 1997,2004 All Rights Reserved.&lt;/i&gt;"/>
+    </antcall>
+  </target>
+
+  <target name="toolsdocs">
+
+    <delete dir="${basedir}/javadoc/tools"/>
+    <mkdir dir="${basedir}/javadoc/tools"/>
+
+    <antcall target="dojjdocs">
+      <param name="jjtodoc" value="${derby.tools.dir}/impl/tools/ij/ij.jj"/>
+      <param name="jjdoctarget" value="${basedir}/javadoc/tools/ij.html"/>
+    </antcall>
+
+  </target>
+
+  <target name="grammardocs">
+
+    <delete dir="${basedir}/javadoc/language"/>
+    <mkdir dir="${basedir}/javadoc/language"/>	
+
+    <antcall target="dojjdocs">
+      <param name="jjtodoc" value="${derby.engine.dir}/impl/sql/compile/sqlgrammar.jj"/>
+      <param name="jjdoctarget" value="${basedir}/javadoc/language/sqlgrammar.html"/>
+    </antcall>
+
+  </target>
+
+  <target name="dojjdocs">
+
+    <java classname="jjdoc" fork="yes">
+      <classpath path="${javatools.dir}/javacc.jar;${compile.classpath}"/>
+      <arg value="-NOONE_TABLE"/>
+      <arg value="-output_file=${jjdoctarget}"/>
+      <arg value="${jjtodoc}"/>
+    </java>
+
+  </target>
+
+  <target name="javadocsubpackages">
+    <java classname="com.sun.tools.javadoc.Main" fork="yes">
+      <classpath path="${java.home}/../lib/tools.jar;${out.dir}"/>
+      <jvmarg value="-mx320M"/>
+      <arg value="-subpackages"/>
+      <arg value="org"/>
+      <arg value="-private"/>
+      <arg value="-breakiterator"/>
+      <arg value="-sourcepath"/>
+      <arg value="${javadoc.sourcepath}"/>
+      <arg value="-classpath"/>
+      <arg value="${javadoc.classpath}"/>
+      <arg value="-d"/>
+      <arg value="${javadoc.destdir}"/>
+      <arg value="-windowtitle"/>
+      <arg value="${javadoc.windowtitle}"/>
+      <arg value="-doctitle"/>
+      <arg value="${javadoc.doctitle}"/>
+      <arg value="-bottom"/>
+      <arg value="${javadoc.bottom}"/>
+      <arg value="-taglet"/>
+      <arg value="org.apache.derbyBuild.javadoc.FormatIdTaglet"/>
+      <arg value="-taglet"/>
+      <arg value="org.apache.derbyBuild.javadoc.PurposeTaglet"/>
+      <arg value="-taglet"/>
+      <arg value="org.apache.derbyBuild.javadoc.UpgradeTaglet"/>
+      <arg value="-taglet"/>
+      <arg value="org.apache.derbyBuild.javadoc.DiskLayoutTaglet"/>
+      <arg value="-taglet"/>
+      <arg value="org.apache.derbyBuild.javadoc.EndFormatTaglet"/>
+    </java>
+  </target>
+
+  <target name="cleandocs">
+
+    <delete dir="${basedir}/javadoc"/>
+
+  </target>
+
+<!-- =================================================================== -->
+<!--                               Jar targets                           -->
+<!-- =================================================================== -->
+
+  <target name="buildjarsclean" depends="cleanjars,initjars,derbyjar,derbytoolsjar,derbynetjar"/>
+  <target name="buildjars" depends="initjars,derbyjar,derbytoolsjar,derbynetjar"/>
+
+  <target name="initjars" depends="setsanityname">
+    <property name="derby.jar.dir" value="${basedir}/jars/${sanity.name}"/>
+    <property name="derby.jar.topdir" value="${basedir}/jars"/>
+    <mkdir dir="${derby.jar.dir}"/>
+    <mkdir dir="${derby.jar.dir}/lists"/>
+    <condition property="changenumber" value="1">
+      <not>
+        <isset property="changenumber"/>
+      </not>
+    </condition>
+  </target>
+
+
+<!-- - - - - - - - - - - - - - - derby.jar target - - - - - - - - - - - -->
+
+  <target name="derbyjar" depends="initjars">
+
+    <echo message="Beginning derby.jar ${sanity.name} build"/>
+
+    <concat destfile="${derby.jar.dir}/lists/otherDerbyClasses.properties">
+      <fileset dir="${basedir}/tools/jar" includes="*DBMS*.properties"/>
+    </concat>
+
+    <mkdir dir="${derby.jar.dir}/lists/org/apache/derby"/>
+    <java classname="org.apache.derbyBuild.propertyconfig">
+      <arg value="${out.dir}/org/apache/derby/modules.properties"/>
+      <arg value="derby"/>
+      <arg value="${derby.jar.dir}/lists/org/apache/derby/modules.properties"/>
+      <classpath>
+        <pathelement path="${out.dir}"/>
+      </classpath>
+    </java>
+
+    <!-- filter out EmbeddedActivator if osgi.jar is not available -->
+    <antcall target="filteractivator"/>
+
+    <echo message=" creating derby.jar class list "/>
+    <java classname="org.apache.derbyBuild.classlister" fork="yes">
+      <jvmarg value="-DcloudscapeOnly=true"/>
+      <jvmarg value="-Doutputfile=${derby.jar.dir}/lists/derby.list"/>
+      <arg value="${derby.jar.dir}/lists/otherDerbyClasses.properties"/> 
+      <arg value="${derby.jar.dir}/lists/org/apache/derby/modules.properties"/>
+      <classpath>
+        <pathelement path="${out.dir}"/> 
+      </classpath>
+    </java>
+
+    <!-- This next antcall generates a new properties file for the build.  -->
+    <!-- If a changenumber is passed into the build via a property file or -->
+    <!-- on the command line, the build number will be inserted into the   -->
+    <!-- build at this point.                                              -->
+ 
+    <echo message=" creating new DBMS.properties file"/>
+    <antcall target="infowriter">
+      <param name="info.iname" value="Apache Derby Embedded Engine"/>
+      <param name="info.ename" value="Apache Derby"/>
+      <param name="info.buildnumber" value="${changenumber}"/>
+      <param name="info.productfile" value="derby.jar"/>
+      <param name="info.file" value="${out.dir}//org/apache/derby/info/DBMS.properties"/>
+    </antcall>
+    <echo file="${derby.jar.dir}/lists/derby.list"
+          append="true"
+          message="org/apache/derby/info/DBMS.properties"/>
+
+    <!-- the next two targets are orthogonal. Only one will be executed, -->
+    <!-- depending on whether or not osgi.jar is available.              -->
+    <antcall target="derbyjarwithosgi"/>
+    <antcall target="derbyjarwithoutosgi"/>
+
+    <!-- add non-class files to jar -->
+
+    <jar destfile="${derby.jar.dir}/derby.jar" 
+         update="true"
+         compress="true">
+      <fileset dir="${out.dir}"
+               includes="org/apache/derby/loc/m?_en.properties,
+                         org/apache/derby/loc/m??_en.properties,
+                         org/apache/derby/loc/sysinfoMessages.properties,
+                         org/apache/derby/loc/toolsmessages.properties,
+                         org/apache/derby/impl/jdbc/metadata.properties,
+                         org/apache/derby/impl/sql/catalog/metadata_net.properties,
+                         org/apache/derby/info/DBMS.properties"/>
+      <fileset dir="${derby.jar.dir}/lists"
+               includes="org/apache/derby/modules.properties"/>
+    </jar>
+
+  </target>
+
+  <target name="filteractivator" depends="checkosgijar" if="osgijar.unavailable">
+
+    <replaceregexp file="${derby.jar.dir}/lists/otherDerbyClasses.properties"
+                   match="derby.module.osgi.activator=org.apache.derby.osgi.EmbeddedActivator"
+                   replace=""/>
+
+  </target>
+
+  <target name="derbyjarwithoutosgi" depends="checkosgijar" if="osgijar.unavailable">
+
+    <manifest file="${derby.jar.dir}/lists/smf.mf">
+      <attribute name="Bundle-Vendor" value="Apache Software Foundation"/>
+      <attribute name="Bundle-Name" value="Apache Derby ${major}.${minor}"/>
+      <attribute name="Bundle-Version" value="${major}.${minor}.${maint}"/>
+    </manifest> 
+
+    <jar destfile="${derby.jar.dir}/derby.jar"
+         basedir="${out.dir}"
+	 includesfile="${derby.jar.dir}/lists/derby.list"
+         compress="true"
+         filesonly="true"
+         manifest="${derby.jar.dir}/lists/smf.mf"/>
+
+  </target>
+
+  <target name="derbyjarwithosgi" depends="checkosgijar" if="osgijar.available">
+
+    <manifest file="${derby.jar.dir}/lists/smf.mf">
+      <attribute name="Bundle-Vendor" value="Apache Software Foundation"/>
+      <attribute name="Bundle-Activator" value="org.apache.derby.osgi.EmbeddedActivator"/>
+      <attribute name="Bundle-Name" value="Apache Derby ${major}.${minor}"/>
+      <attribute name="Bundle-Version" value="${major}.${minor}.${maint}"/>
+      <attribute name="Import-Package" value="java.sql"/>
+      <attribute name="DynamicImport-Package" value="*"/>
+      <attribute name="Export-Package" value="org.apache.derby.authentication,org.apache.derby.database,org.apache.derby.io,org.apache.derby.jdbc,org.apache.derby.vti"/> 
+    </manifest> 
+
+    <jar destfile="${derby.jar.dir}/derby.jar"
+         basedir="${out.dir}"
+	 includesfile="${derby.jar.dir}/lists/derby.list"
+         compress="true"
+         filesonly="true"
+         manifest="${derby.jar.dir}/lists/smf.mf"/>
+
+  </target>
+
+<!-- - - - - - - - - - - - -  derbytools.jar target - - - - - - - - - - -->
+
+  <target name="derbytoolsjar" depends="setsanityname">
+
+    <echo message="Beginning derbytools.jar ${sanity.name} build"/>
+
+    <echo message=" creating tools.list "/>
+    <java classname="org.apache.derbyBuild.classlister" fork="yes">
+      <jvmarg value="-Ddb2jtools=true"/>
+      <jvmarg value="-Doutputfile=${derby.jar.dir}/lists/derbytools.list"/>
+      <arg value="${basedir}/tools/jar/tools.properties"/>
+      <classpath>
+        <pathelement path="${out.dir}"/>
+      </classpath>
+    </java>
+    <replace file="${derby.jar.dir}/lists/derbytools.list" token="$$$$" value="$$"/>
+
+    <echo message=" creating new tools.properties file "/>
+    <antcall target="infowriter">
+      <param name="info.buildnumber" value="${changenumber}"/>
+      <param name="info.iname" value="Apache Derby Tools"/>
+      <param name="info.ename" value="Apache Derby"/>
+      <param name="info.productfile" value="derbytools.jar"/>
+      <param name="info.file" value="${out.dir}/org/apache/derby/info/tools.properties"/>
+    </antcall>
+
+    <delete file="${derby.jar.dir}/derbytools.jar"/>
+    <jar destfile="${derby.jar.dir}/derbytools.jar"
+         basedir="${out.dir}"
+         includesfile="${derby.jar.dir}/lists/derbytools.list"
+         compress="true"
+         filesonly="true"/>
+    <jar destfile="${derby.jar.dir}/derbytools.jar"
+         compress="true"
+         filesonly="true"
+         update="true">
+      <fileset dir="${out.dir}"
+               includes="org/apache/derby/loc/sysinfoMessages.properties,
+                         org/apache/derby/loc/toolsmessages.properties,
+                         org/apache/derby/info/tools.properties"/>
+    </jar>
+
+  </target>
+
+<!-- - - - - - - - - - - - - - derbynet.jar target - - - - - - - - - - - -->
+
+  <target name="derbynetjar" depends="setsanityname">
+
+    <echo message="Beginning derbynet.jar ${sanity.name} build"/>
+
+    <echo message=" creating net.list"/> 
+    <java classname="org.apache.derbyBuild.classlister" fork="yes">
+      <jvmarg value="-Ddb2jdrda=true"/>
+      <jvmarg value="-Doutputfile=${derby.jar.dir}/lists/derbynet.list"/>
+      <arg value="${basedir}/tools/jar/net.properties"/>
+      <classpath>
+        <pathelement path="${out.dir}"/>
+      </classpath>
+    </java>
+
+    <echo message=" creating new net.properties file "/>
+    <antcall target="infowriter">
+      <param name="info.buildnumber" value="${changenumber}"/>
+      <param name="info.iname" value="Apache Derby Network Server"/>
+      <param name="info.ename" value="Apache Derby"/>
+      <param name="info.productfile" value="derbynet.jar"/>
+      <param name="info.file" value="${out.dir}/org/apache/derby/info/net.properties"/>
+    </antcall>
+
+    <delete file="${derby.jar.dir}/derbynet.jar"/>
+    <jar destfile="${derby.jar.dir}/derbynet.jar"
+         basedir="${out.dir}"
+         includesfile="${derby.jar.dir}/lists/derbynet.list"
+         compress="true"
+         filesonly="true"/>
+    <jar destfile="${derby.jar.dir}/derbynet.jar"
+         compress="true"
+         filesonly="true"
+         update="true">
+      <fileset dir="${out.dir}"
+               includes="org/apache/derby/loc/drda/**,
+                         org/apache/derby/info/net.properties"/>
+    </jar>
+
+  </target>
+
+<!-- - - - - - - - - - - -  jar build helper targets  - - - - - - - - - -->
+
+  <target name="setsanityname" depends="init,setissane,sanitynamesane,sanitynameinsane"/>
+
+  <target name="sanitynamesane" if="is.sane">
+    <property name="sanity.name" value="sane"/>
+  </target>
+
+  <target name="sanitynameinsane" unless="is.sane">
+    <property name="sanity.name" value="insane"/>
+  </target>
+
+  <target name="checkosgijar" depends="setosgiavailable,setosgiunavailable"/>
+  <target name="setosgiavailable">
+    <condition property="osgijar.available">
+      <available file="${osgi}"/>
+    </condition>
+  </target>
+  <target name="setosgiunavailable">
+    <condition property="osgijar.unavailable">
+      <not>
+        <available file="${osgi}"/>
+      </not>
+    </condition>
+  </target>
+
+
+  <target name="cleanjars" depends="setsanityname">
+    <delete dir="${basedir}/jars/${sanity.name}"/>
+  </target>
+
+<!-- =================================================================== -->
+<!--                         Nightly build targets                       -->
+<!-- =================================================================== -->
+
+  <target name="buildworld">
+
+    <property name="proceed" value="true"/>
+
+    <!-- Build insane product jars -->
+    <antcall target="clobber"/>
+    <antcall target="insane"/>
+    <antcall target="buildsource"/>
+    <antcall target="buildsource"/>
+    <antcall target="jars"/>
+
+
+    <!-- Build sane product jars -->
+    <antcall target="clobber"/>
+    <antcall target="sane"/>
+    <antcall target="buildsource"/>
+    <antcall target="buildsource"/>
+    <antcall target="jars"/>
+
+    <!-- Build everything else -->
+    <antcall target="javadoc"/>
+
+  </target>
+
+</project>

Added: incubator/derby/code/trunk/java/build/build.xml
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/build.xml	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+
+<!-- ==================================================================== -->
+<!--                       Cloudscape build file                          -->
+<!-- ==================================================================== -->
+
+<project default="build" basedir="../..">
+
+<!-- ==================================================================== -->
+<!--                           Set properties                             -->
+<!-- ==================================================================== -->
+
+  <property name="properties.dir" value="tools/ant/properties"/>
+
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+
+  <!-- Parser properties -->
+  <property file="${properties.dir}/parser.properties"/>
+
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+
+  <!-- Release and Version info -->
+  <property file="${properties.dir}/release.properties"/>
+
+<!--             ============ Begin Targets ==============                -->
+ 
+  <target name="build" depends="build_base"
+          description="Build Derby build helpers">
+
+  </target>
+
+  <target name="build_base">
+    <ant dir="${derby.build.dir}"/>
+  </target>
+
+
+<!--             ============= End Targets ==============                -->
+
+<!--             ============= End Project ==============                -->
+
+</project>
+

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/ClassSizeCrawler.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/ClassSizeCrawler.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,303 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.iapi.services.cache
+   (C) Copyright IBM Corp. 2003, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derbyBuild;
+
+import org.apache.derby.iapi.services.cache.ClassSize;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.lang.SecurityException;
+import java.lang.ClassNotFoundException;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * This class implements a program that catalogs the size estimate coefficients of various classes.
+ * @see ClassSize#getSizeCoefficients.
+ *<p>
+ * The program is invoked as:
+ *<p>
+ * java -DWS=<i>work-space</i> [-DclassDir=<i>class-dir</i>] [-Dout=<i>out-file</i> [-Dprefix[.<i>x</i>=<i>package-prefix</i>]] [-Dverbose=true] org.apache.derby.iapi.services.cache.ClassSizeCrawler <i>class-or-interface</i> ...<br>
+ *<p>
+ * This program gets the size coefficients for each class in the <i>class-or-interface</i> list,
+ * and for each class that implements an interface in the list. If there is an interface in the list
+ * this program crawls through the classes hierarcy, starting at points specified by the prefix
+ * properties, looking for classes that implement the interfaces.
+ *<p>
+ * If the <i>class-or-interface</i> list is empty then this program searches for implementations
+ * of org.apache.derby.iapi.types.DataValueDescriptor, and at least one prefix property
+ * must be specified
+ *<p>
+ * The catalog is written as a java source file
+ * into <i>out-file</i>, by default
+ * <i>work-space</i>/java/org.apache.derby.iapi.services.cache.ClassSizeCatalog.java.
+ *<p>
+ * <i>work-space</i> is the directory containing the java and classes directories. $WS in the
+ * standard development environment. This property is required.
+ *<p>
+ * <i>class-dir</i> is the directory containing the compiled classes. By default it is <i>work-space</i>/classes.
+ *<p>
+ * <i>package-prefix</i> is the first part of a package name. e.g. "com.ibm.db2j.impl". At least
+ * one prefix property must be specified if there is an interface in the list.
+ *<p>
+ * For example:<br>
+ * <pre>
+ * <code>
+ * java -DWS=$WS \
+ *      -Dprefix.1=org.apache.derby.iapi.types \
+ *      org.apache.derby.iapi.services.cache.ClassSizeCrawler \
+ *        org.apache.derby.iapi.types.DataValueDescriptor \
+ *        java.math.BigDecimal \
+ *        org.apache.derby.impl.services.cache.Generic.CachedItem
+ *</code>
+ *</pre>
+ */
+public class ClassSizeCrawler
+{
+    public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2003_2004;
+
+    public static void main( String[] arg)
+    {
+        String[] classAndInterfaceList = {"org.apache.derby.iapi.types.DataValueDescriptor"};
+        if(arg.length > 0)
+            classAndInterfaceList = arg;
+        Class[] interfaceList = new Class[classAndInterfaceList.length];
+        int interfaceCount = 0;
+        Class[] classList = new Class[classAndInterfaceList.length];
+        int classCount = 0;
+
+        Class classSizeClass = ClassSize.class; // Make sure that the garbage collector does not unload it
+        ClassSize.setDummyCatalog();
+        /* Most of the classes we will catalog invoke ClassSize.estimateBaseFromCatalog in
+         * their static initializer. This dummy the catalog out so that this will not generate
+         * errors. We will not actually use the classes, just examine their fields.
+         */
+
+        for( int i = 0; i < classAndInterfaceList.length; i++)
+        {
+            Class cls = null;
+            try
+            {
+                cls = Class.forName( classAndInterfaceList[i]);
+            }
+            catch( ClassNotFoundException cnfe)
+            {
+                System.err.println( "*** Could not find class " + classAndInterfaceList[i]);
+                System.exit(1);
+            }
+            if( cls.isInterface())
+                interfaceList[ interfaceCount++] = cls;
+            else
+                classList[ classCount++] = cls;
+        }
+
+        String WS = System.getProperty( "WS");
+        if( WS == null)
+        {
+            System.err.println( "*** WS is not set.");
+            System.exit(1);
+        }
+
+        StringBuffer baseDir = new StringBuffer( System.getProperty( "classDir", ""));
+        if( baseDir.length() == 0)
+        {
+            baseDir.append( WS);
+            baseDir.append( '/');
+            baseDir.append( "classes");
+        }
+        int baseDirLength = baseDir.length();
+
+        StringBuffer packagePrefix = new StringBuffer( );
+
+        Hashtable classSizes = new Hashtable();
+
+        ClassSizeCrawler crawler = new ClassSizeCrawler(interfaceList, interfaceCount, classSizes);
+
+        if( interfaceCount > 0)
+        {
+            boolean gotPrefix = false;
+            // Crawl through the class hierarchies for classes implementing the interfaces
+            for( Enumeration e = System.getProperties().propertyNames();
+                 e.hasMoreElements();)
+            {
+                String propertyName = (String) e.nextElement();
+                if( propertyName.equals( "prefix") || propertyName.startsWith( "prefix."))
+                {
+                    gotPrefix = true;
+                    packagePrefix.setLength( 0);
+                    packagePrefix.append( System.getProperty( propertyName));
+                    baseDir.setLength( baseDirLength);
+                    if( packagePrefix.length() > 0)
+                    {
+                        baseDir.append( '/');
+                        for( int offset = 0; offset < packagePrefix.length(); offset++)
+                        {
+                            char c = packagePrefix.charAt( offset);
+                            if( c == '.')
+                                baseDir.append( '/');
+                            else
+                                baseDir.append( c);
+                        }
+                    }
+                    crawler.crawl( new File( baseDir.toString()), packagePrefix);
+                }
+            }
+            if( ! gotPrefix)
+            {
+                System.err.println( "*** Could not search the class hierarchy because no starting");
+                System.err.println( "    prefixes where specified.");
+                System.exit(1);
+            }
+        }
+        for( int i = 0; i < classCount; i++)
+            crawler.addClass( classList[i]);
+
+        baseDir.setLength( baseDirLength);
+        String outputFileName =
+          System.getProperty( "out", WS + "/java/org.apache.derby.iapi.services.cache.ClassSizeCatalog.java");
+        try
+        {
+            Calendar cal = Calendar.getInstance();
+            cal.setTime( new Date());
+            int year = cal.get( Calendar.YEAR);
+            PrintWriter out = new PrintWriter( new FileWriter( outputFileName));
+            out.print( "/* IBM Confidential\n" +
+                       " *\n" +
+                       " * Product ID: 5697-F53\n" +
+                       " *\n" +
+                       " * (C) Copyright IBM Corp. " + year + "\n" +
+                       " *\n" +
+                       " * The source code for this program is not published or otherwise divested\n" +
+                       " * of its trade secrets, irrespective of what has been deposited with the\n" +
+                       " * U.S. Copyright Office.\n" +
+                       " */\n");
+            out.print( "package org.apache.derby.iapi.services.cache;\n" +
+                       "import java.util.Hashtable;\n" +
+                       "class ClassSizeCatalog extends java.util.Hashtable\n" +
+                       "{\n" +
+                       "    public static final String copyrightNotice = \"(c) Copyright IBM Corp. 2003. All Rights Reserved.\";\n" +
+                       "    ClassSizeCatalog()\n" +
+                       "    {\n");
+            for( Enumeration e = classSizes.keys();
+                 e.hasMoreElements();)
+            {
+                String className = (String) e.nextElement();
+                int[] coeff = (int[]) classSizes.get( className);
+                out.print( "        put( \"" + className + "\", new int[]{" + coeff[0] + "," + coeff[1] + "});\n");
+            }
+            out.print("    }\n" +
+                      "}\n");
+            out.flush();
+            out.close();
+        }
+        catch( IOException ioe)
+        {
+            System.err.println( "*** Cannot write to " + outputFileName);
+            System.err.println( "   " + ioe.getMessage());
+            System.exit(1);
+        }
+    } // end of main
+
+    private Class[] interfaceList; // Search for classes that implement these interfaces
+    private int interfaceCount;
+    private Hashtable classSizes;
+    private boolean verbose = false;
+
+    private ClassSizeCrawler( Class[] interfaceList,
+                              int interfaceCount,
+                              Hashtable classSizes)
+    {
+        this.interfaceList = interfaceList;
+        this.classSizes = classSizes;
+        this.interfaceCount = interfaceCount;
+        verbose = new Boolean( System.getProperty( "verbose", "false")).booleanValue();
+    }
+
+    private void crawl( File curDir, StringBuffer className)
+    {
+        if( verbose)
+            System.out.println( "Searching directory " + curDir.getPath());
+
+        try
+        {
+            if( ! curDir.isDirectory())
+            {
+                System.err.println( "*** " + curDir.getPath() + " is not a directory.");
+                System.exit(1);
+            }
+        }
+        catch( SecurityException se)
+        {
+            System.err.println( "Cannot access " + curDir.getPath());
+            System.exit(1);
+        }
+        String[] filenames = curDir.list( );
+        if( className.length() != 0)
+            className.append( ".");
+
+        int classNameLength = className.length();
+        for( int fileIdx = 0; fileIdx < filenames.length; fileIdx++)
+        {
+            if( filenames[fileIdx].endsWith( ".class"))
+            {
+                // Strip off the ".class" suffix
+                String s = filenames[fileIdx].substring( 0, filenames[fileIdx].length() - 6);
+                className.append( s);
+                Class targetClass = null;
+                String targetClassName = className.toString();
+                try
+                {
+                    targetClass = Class.forName( targetClassName);
+                    if( !targetClass.isInterface())
+                    {
+                        for( int interfaceIdx = 0; interfaceIdx < interfaceCount; interfaceIdx++)
+                        {
+                            if( interfaceList[interfaceIdx].isAssignableFrom( targetClass))
+                                addClass( targetClass);
+                        }
+                    }
+                }
+                catch( ClassNotFoundException cnfe)
+                {
+                    System.err.println( "Could not find class " + targetClassName);
+                    System.exit(1);
+                }
+                catch( Throwable t){}
+                className.setLength( classNameLength);
+            }
+            else
+            {
+                File nextDir = new File( curDir, filenames[fileIdx]);
+                if( nextDir.isDirectory())
+                {
+                    className.append( filenames[fileIdx]);
+                    crawl( nextDir, className);
+                    className.setLength( classNameLength);
+                }
+            }
+        }
+    } // end of crawl
+
+    private void addClass( Class targetClass)
+    {
+        int[] coefficients = ClassSize.getSizeCoefficients( targetClass);
+        if( verbose)
+            System.out.println( targetClass.getName() + " " + coefficients[0] + ", " + coefficients[1]);
+        classSizes.put( targetClass.getName(), coefficients);
+    } // end of addClass
+} // end of ClassSizeCrawler

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/build.xml
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/build.xml	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+
+<project default="build" basedir="../../../../../..">
+
+<!-- Set Properties -->
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+  <!-- Set property lib dir -->
+  <property name="properties.dir" value="tools/ant/properties"/>
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+
+<!-- Targets -->
+  <target name="build" depends="compile"/>
+
+  <target name="compile">
+    <javac
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="${debug}"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.build.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${compile.classpath};${java.home}/../lib/tools.jar"/>
+      </classpath>
+      <include name="org/apache/derbyBuild/**"/>
+    </javac>
+  </target>
+</project>

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,726 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild
+   (C) Copyright IBM Corp. 1997, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derbyBuild;
+
+import org.apache.derby.iapi.services.classfile.*;
+import org.apache.derby.iapi.util.ByteArray;
+import java.util.*;
+import java.util.zip.*;
+import java.io.*;
+
+import java.io.*;
+
+/**
+
+	A tool that generates a list of required classes from a
+	set of properties files. The value of any property within a property
+	file that starts with 'derby.module.' is taken as a class name.
+	That class name and all the clases it requires are listed to
+	System.out, to facilitate building a zip file. Classes that
+	start with 'java.' or 'javax.' are not listed and are not
+	checked for dependent classes.
+	<P>
+	If the class name starts with 'com.ibm.db2j.' then a messages.properties
+	file is searched for corresponding to that class, if one exists then
+	is is added to the list of files printed.
+	<P>
+	The search path for the classes is $CLASSPATH
+	<P>
+	If the system property cloudscapeOnly is set to true then only classes
+	and message.properties files are listed that start with com.ibm.db2j.
+	<P>
+	The output for each class or properties file is a relative file
+	name that uses '/' as the file separator. e.g.
+
+	com/ibm/db2j/core/Setup.class
+
+  <P>
+	The output order of the classes & files is random.
+    <P>
+
+
+    Usage: java [-DignoreWebLogic=true] [-Dverbose=true] [-DcloudscapeOnly=true] [-DruntimeOnly=true] 
+	[-Ddb2jtools=true]
+    [-DportingOnly=true] [-Doutputfile=<filename>] org.apache.derbyBuild.classlister 
+    property_file [ property_file ... ]
+**/
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+
+
+public class classlister { private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_1997_2004;
+
+	protected String[] sets;
+	protected Hashtable foundClasses;
+	//protected ClassUtilitiesFactory cuf;
+
+	protected boolean cloudscapeOnly = false;
+	protected boolean portingOnly = false;
+	protected boolean ignoreWebLogic = false;
+	protected boolean verbose = false;
+	protected boolean skipJava = true;
+	protected boolean skipJavax = true;
+	protected boolean skipOrg = true;
+	protected boolean skipInformix = true;
+	protected boolean skipDB2 = true;
+	protected boolean skipDB2e = true;
+        protected boolean skipSun = true;
+	protected boolean showAll = false;
+	protected boolean keepRolling = false;
+	protected boolean showOne = false;
+	protected Hashtable masterClassList = new Hashtable();
+    protected String classpath[] = null;
+    protected String outputfile;
+    protected Hashtable classpathHash;
+	protected int indent = 0;
+	protected int errorCount = 0;
+	protected PrintWriter pwOut;
+	protected PrintStream psOut;
+
+	protected boolean db2jtools;
+	protected boolean db2jdrda;
+
+	protected boolean keepDependencyHistory;
+
+	protected static final String[] propFiles = {
+		"messages.properties",
+		"instructions.properties",
+                "metadata.properties"
+	};
+
+	public static void main(String args[]) throws IOException {
+
+		classlister me = new classlister();
+
+		me.sets = args;
+
+		me.run();
+		if (me.errorCount > 0)
+		{
+			System.out.println(me.errorCount + " errors encountered.");
+			System.exit(1);
+		}
+	}
+
+	public classlister() {
+		cloudscapeOnly = Boolean.getBoolean("cloudscapeOnly");
+		portingOnly = Boolean.getBoolean("portingOnly");
+        ignoreWebLogic = Boolean.getBoolean("ignoreWebLogic");
+        verbose = Boolean.getBoolean("verbose");
+        skipJava = ! Boolean.getBoolean("doJava");
+        skipJavax = ! Boolean.getBoolean("doJavax");
+        skipOrg = ! Boolean.getBoolean("doOrg");
+        showAll = Boolean.getBoolean("showAll");
+        showOne = Boolean.getBoolean("showOne");
+        keepRolling = Boolean.getBoolean("keepRolling");
+        outputfile = System.getProperty("outputfile");
+		db2jtools = Boolean.getBoolean("db2jtools");
+		db2jdrda = Boolean.getBoolean("db2jdrda");
+
+		keepDependencyHistory = showOne || showAll;
+	}
+
+	public void run() 
+	{
+		//System.out.println("outputfile: " + outputfile);
+		try
+		{
+		    File outFile = new File(outputfile);
+		    pwOut = new PrintWriter( new BufferedWriter
+                (new FileWriter(outFile.getPath()), 10000), true );
+        }
+        catch (IOException ioe)
+        {
+            System.out.println(ioe);
+            System.exit(1);
+        }
+	    
+		loadClasspath();
+		//cuf = new ModifyClasses();
+
+		foundClasses = new Hashtable(3000, 0.8f);  
+		
+		for (int i = 0; i < sets.length; i++) 
+		{
+
+			// If a set name ends in '.class' then take it as a class
+			// name of the form com.acme.foo.MyClass.class.
+			try 
+			{
+
+				String s = sets[i];
+
+				if (s.endsWith(".class")) {
+
+					findDependencies(s.substring(0, s.length() - 6));
+				} else {
+
+					FileInputStream fis = new FileInputStream(s);
+
+					Properties pset = new Properties();
+
+					pset.load(fis);
+
+					findClasses(pset);
+				}
+
+			} 
+			catch (IOException ioe) 
+			{
+				System.err.println(ioe.toString());
+				System.exit(1);
+			}
+		}
+        if (pwOut == null)
+        {
+            System.out.println("Need to specify an outputfile");
+            System.exit(1);
+        }
+		for (Enumeration e = foundClasses.keys(); e.hasMoreElements(); ) {
+			String name = (String) e.nextElement();
+			String type = (String) foundClasses.get(name);
+			if (type.equals("class")) {
+                if (ignoreWebLogic) {
+                    if (name.startsWith("weblogic")) {
+                        continue;
+                    }
+                }
+
+
+				if (isCloudscapeCode(name)) {
+
+					if (name.startsWith("com.ibm.db2j.porting.")) {
+						if (cloudscapeOnly)
+							continue;
+					} else {
+						if (portingOnly)
+							continue;
+					}
+
+				} else {
+					if (cloudscapeOnly || portingOnly)
+						continue;
+				}
+				pwOut.println(name.replace('.', '/') + ".class");
+			}
+			else {
+				// is a file name
+				if (name.startsWith("com/ibm/db2j/")) {
+					if (portingOnly) {
+						continue;
+					}
+				} else {
+					if (cloudscapeOnly || portingOnly)
+						continue;
+				}
+
+				pwOut.println(name);
+			}
+		}
+		if (showAll)
+		{
+			showAllItems();
+		}
+		if (showOne)
+		{
+			showAllItemsOneLevel();
+		}
+	}
+
+
+	protected void findClasses(Properties pset) throws IOException {
+
+		for (Enumeration e = pset.propertyNames(); e.hasMoreElements(); ) {
+			String key = (String) e.nextElement();
+			if (key.startsWith("derby.module.")) {
+				if (verbose) {
+					pwOut.println(pset.getProperty(key) + " needs ");
+				}
+				findDependencies(pset.getProperty(key));
+			}
+		}
+	}
+
+    protected void loadClasspath()
+    {
+        classpathHash = new Hashtable();
+            try
+            {
+                String classpathString = System.getProperty("java.class.path");
+				if (verbose)
+					pwOut.println("classpath: " + classpathString);
+                StringTokenizer st = new StringTokenizer(classpathString, File.pathSeparator);
+                int entries = st.countTokens();
+                classpath = new String[entries];
+                for (int i = 0; i < entries; i++)
+                {
+                    classpath[i] = st.nextToken();
+                }
+            }
+            catch (SecurityException se)
+            {
+                pwOut.println("**error** SecurityException getting classpath");
+                System.exit(1);
+            }
+        for (int i = 0; i < classpath.length; i++)
+        {
+            String pathEntry = classpath[i];
+            if (pathEntry.toUpperCase(java.util.Locale.ENGLISH).endsWith(".ZIP") ||
+                pathEntry.toUpperCase(java.util.Locale.ENGLISH).endsWith(".JAR") )
+            {
+                ZipFile zipfile = null;
+                try
+                {
+                    zipfile = new ZipFile(pathEntry.replace('/', File.separatorChar));
+                }
+                catch (IOException ioe)
+                {
+                    // can't do anything about it; zipfile doesn't exists
+                    // it can happen if the person sticks a directory called
+                    // foo.zip in the classpath or foo.zip doesn't exist as
+                    // a file
+                }
+                if (zipfile != null)
+                {
+
+                    classpathHash.put(pathEntry, zipfile);
+                }
+                else
+                {
+					if (verbose)
+					{
+	                    pwOut.println("Ignoring <zip> entry: " + pathEntry);
+					}
+	
+                }
+            }
+            else
+            {
+                File file = new File(pathEntry);
+
+                if (file.exists() && file.isDirectory())
+                {
+                    classpathHash.put(pathEntry, file);
+                }
+                else
+                {
+                   	if (verbose)
+					{ 
+                    	pwOut.println("Ignoring <dir> entry: " + pathEntry);
+					}
+                }
+            }
+        }
+    }
+
+
+    protected InputStream locateClass(String className, boolean beVerbose)
+    {
+        if (className.startsWith("/"))
+        {
+            className = className.substring(1);
+        }
+        if (beVerbose)
+        {
+            pwOut.println("Looking for " + className);
+        }
+
+        if (classpath == null)
+        {
+            loadClasspath();
+        }
+
+        for (int i = 0; i < classpath.length; i++)
+        {
+            String pathEntry = classpath[i];
+            Object hash = classpathHash.get(pathEntry);
+            if (hash != null)
+            {
+                if (hash instanceof ZipFile)
+                try
+                {
+                    ZipFile zipfile = (ZipFile) hash;
+
+                    ZipEntry entry = zipfile.getEntry(className);
+
+                    if (entry != null)
+                    {
+                        InputStream is = zipfile.getInputStream(entry);
+                        DataInputStream dis= new DataInputStream(new BufferedInputStream(is));
+                        return dis;
+                    }
+                }
+                catch (IOException ioe)
+                {
+                    if (beVerbose)
+                    {
+                        pwOut.println("IOException loading ZipFile or creating InputStream " +
+                            " from it");
+                        pwOut.println(ioe);
+                    }
+                }
+                else if (hash instanceof File)
+                {
+                    File file = new File((File)hash, className.replace('/', File.separatorChar));
+                    if (beVerbose)
+                    {
+                        pwOut.println("looking to load file: " + file.getName());
+                    }
+                    if (file.exists())
+                    {
+                        if (beVerbose)
+                        {
+                            pwOut.println(" found it!");
+                        }
+                        try
+                        {
+                            FileInputStream fis = new FileInputStream(file);
+                            return new BufferedInputStream(fis, 8192);
+                        }
+                        catch (IOException ioe)
+                        {
+                            if (beVerbose)
+                            {
+                                pwOut.println("IOException creating FileInputStream");
+                                pwOut.println(ioe);
+                                return null;
+                            }
+                        }
+                    }
+                }
+            }
+            //
+        }
+
+        // could not find it
+        if (beVerbose)
+        {
+            pwOut.println("returing null on purpose");
+        }
+        return null;
+    }
+
+	protected void findDependencies(String className) throws IOException {
+		indent++;
+		try {
+		if (className.startsWith("java.") && skipJava)
+		{
+			pwOut.println("Skipping JAVA " + className);
+			return;
+		}
+		if (className.startsWith("javax.") && skipJavax)
+		{
+			//System.out.println("Skipping JAVAX " + className);
+		    return;
+		}
+                if (className.startsWith("sun.") && skipSun)
+                {
+                        //System.out.println("Skipping Sun " + className);
+                    return;
+                }
+		if (className.startsWith("org.") && skipOrg)
+		{
+		    // Allow opensource org.apache.derby classes
+                    if (!className.startsWith("org.apache.derby")) 
+		    {
+			//System.out.println("Skipping org " + className);
+			return;
+		    }
+		}
+		if (className.startsWith("com.informix.") && skipInformix)
+		{
+			//System.out.println("Skipping Informix " + className);
+		    return;
+		}
+		if (className.startsWith("com.ibm.mobileservices.") && skipDB2e)
+		{
+			//System.out.println("Skipping DB2e " + className);
+		    return;
+		}
+		if (className.startsWith("common.") && skipDB2)
+		{
+			//System.out.println("Skipping DB2 common " + className);
+		    return;
+		}
+
+        if (ignoreWebLogic)
+        {
+            if (className.startsWith("weblogic."))
+			{
+                return;
+			}
+        }
+
+		if (db2jtools || db2jdrda) {
+
+			// for tools skip classes that are part of the db2j product api
+			// they should be pulled in from cs.jar or any client.jar
+			if (
+				   className.startsWith("org.apache.derby.authentication.")
+				|| className.startsWith("org.apache.derby.catalog.")
+				|| className.startsWith("org.apache.derby.iapi.db.")
+				|| className.startsWith("org.apache.derby.diag.")
+				|| className.startsWith("org.apache.derby.jdbc.")
+				|| className.startsWith("org.apache.derby.vti.")
+				)
+			{
+				return;
+			}
+		}
+
+		// drda explicitly brings in some database engine classes.
+		// they must be picke dup from cs.jar and not put in
+		// the network server jar.
+		if (db2jdrda) {
+
+			if (
+				   className.startsWith("org.apache.derby.impl.sql")
+				|| className.startsWith("org.apache.derby.impl.jdbc")
+				|| className.startsWith("org.apache.derby.impl.services")
+				|| className.startsWith("org.apache.derby.iapi.")
+				)
+			{
+				return;
+			}
+		}
+
+		// already seen class
+		if (foundClasses.get(className) != null)
+			return;
+
+		if (verbose) {
+			for (int i =0; i < indent; i++)
+			{
+				System.out.print(".");
+			}
+			System.out.println(className);
+		}
+
+		/*
+			org.apache.derby.iapi.reference.ClassName &
+			RegisteredFormatIds has a list of all registered classes, If we pull this in then
+			we will pull in the complete set of classes. So we add this to our list but don't
+			dependency check it.
+		*/
+		boolean dontCheckDependencies = false;
+		/*
+		if (className.equals("org.apache.derby.iapi.reference.ClassName") ||
+			className.equals("org.apache.derby.iapi.services.io.RegisteredFormatIds")) {
+			dontCheckDependencies = true;
+		}
+		*/
+
+
+
+        try
+        {
+			Hashtable localHashtable = null;
+			
+			if (keepDependencyHistory) {
+				localHashtable = (Hashtable) masterClassList.get(className);
+				if (localHashtable == null)
+				{
+					localHashtable = new Hashtable();
+					masterClassList.put(className, localHashtable);
+				}
+			}
+
+		    foundClasses.put(className, "class");
+
+			if (dontCheckDependencies)
+				return;
+
+			String fileName = "/" + className.replace('.', '/') + ".class";
+
+			InputStream is = locateClass(fileName, false);
+
+			if (is == null) {
+				pwOut.println("**error** Got NULL when looking for fileName = " + fileName);
+				if (!keepRolling)
+				{
+					System.exit(1);
+				}
+				else
+				{
+					errorCount++;
+				}
+			}
+			//byte[] classData = new byte[is.available()];
+			//is.read(classData);
+
+			ClassInvestigator ch = ClassInvestigator.load(is);
+			is.close();
+
+		    for (Enumeration e = ch/*.getClassInfo()*/.referencedClasses(); e.hasMoreElements(); ) {
+			    String x = (String) e.nextElement();
+				// skip microsoft classes
+				if (x.startsWith("com.ms."))
+				{
+					continue;
+				}
+
+				if (!org.apache.derby.iapi.services.sanity.SanityManager.DEBUG) {
+					if (x.indexOf("SanityManager") != -1) {
+
+						boolean printSanityWarning = true;
+
+						int ld = className.lastIndexOf(".");
+						if (ld != -1) {
+							if (className.lastIndexOf("T_") == ld + 1)
+								printSanityWarning = false;
+							else if (className.lastIndexOf("T_") == ld + 1)
+								printSanityWarning = false;
+							else if (className.lastIndexOf("D_") == ld + 1)
+								printSanityWarning = false;
+							else if (className.lastIndexOf("TEST_") == ld + 1)
+								printSanityWarning = false;
+							else if (className.endsWith("SanityManager"))
+								printSanityWarning = false;
+						}
+
+						if (printSanityWarning)
+							System.out.println("SANITY >>> " + fileName);
+					}
+				}
+
+				if (keepDependencyHistory && (localHashtable.get(x) == null))
+				{
+						
+					localHashtable.put(x, "class");
+				}
+			    findDependencies(x);
+            }
+		} 
+        catch (NullPointerException npe)
+		{
+			pwOut.println("**error** Got NullPointerException in findDependencies when looking up ");
+			pwOut.println(className);
+			
+			npe.printStackTrace();
+			if (!keepRolling)
+			{
+				System.exit(1);
+			}
+			errorCount++;
+		}
+
+		// look for properties only with cloudscape code ...
+		if (!isCloudscapeCode(className))
+			return;
+
+		String packageName = className.substring(0, className.lastIndexOf('.') + 1);
+
+		for (int i = 0; i < propFiles.length; i++) {
+			String fileName = "/" + packageName.replace('.', '/') + propFiles[i];
+			if (foundClasses.get(fileName) != null)
+				continue;
+
+			InputStream is = getClass().getResourceAsStream(fileName);
+			if (is == null)
+				continue;
+			is.close();
+
+
+			foundClasses.put(fileName.substring(1), "file");
+		}
+} finally {
+		indent--;
+	}
+	}
+	protected boolean isCloudscapeCode(String name) {
+		return name.startsWith("com.ibm.db2j.") ||
+		       name.startsWith("com.ihost.cs.") ||
+		       name.startsWith("db2j.") ||
+		       name.startsWith("org.apache.derby");
+	}
+
+
+	protected void showAllItems()
+	{
+		Enumeration e = masterClassList.keys();
+		pwOut.println("------------Printing all dependents--------------");
+		while (e.hasMoreElements())
+		{
+			String kid = (String) e.nextElement();
+			pwOut.println(kid );
+			Hashtable scoreboard = new Hashtable();
+			Hashtable grandkids = (Hashtable) masterClassList.get(kid);
+			unrollHashtable("", grandkids, scoreboard, 1);
+		}
+	}
+
+
+	protected void showAllItemsOneLevel()
+	{
+		pwOut.println("Showing all dependencies");
+		pwOut.println("One level only");
+		pwOut.println("-----------------------------------");
+		
+		Enumeration e = masterClassList.keys();
+		while (e.hasMoreElements())
+		{
+			String key = (String) e.nextElement();
+			pwOut.println(key);
+			Hashtable h = (Hashtable) masterClassList.get(key);
+			Enumeration e2 = h.keys();
+			Hashtable h2 = new Hashtable();
+			while (e2.hasMoreElements())
+			{
+				String key2 = (String) e2.nextElement();
+				pwOut.println("\t" + key2);
+			}
+		}
+	}
+
+
+	protected void unrollHashtable( String parent, Hashtable current, Hashtable scoreboard, int indentLevel)
+	{
+		String indentString = "  ";
+		Enumeration e = current.keys();
+		String key = null;
+ 
+		while (e.hasMoreElements())
+		{
+			key = (String) e.nextElement();
+			if (key.equals(parent))
+			{
+				continue;
+			}
+			pwOut.print(indentLevel + ":");
+
+			Integer value = (Integer) scoreboard.get(key);
+			if (value != null )
+			{
+				for (int i = 0; i < indentLevel; i++)
+				{
+					pwOut.print(indentString);
+				}
+				pwOut.println(key + "*****REPEATED class back at level " + value + "****");
+				return;
+			}
+			for (int i = 0; i < indentLevel; i++)
+			{
+				pwOut.print(indentString);
+			}
+			pwOut.println(key);
+
+			Hashtable currentsChildren = (Hashtable) masterClassList.get(key);
+	scoreboard.put(key, new Integer(indentLevel));
+			unrollHashtable(key, currentsChildren, scoreboard, (indentLevel+1));
+			scoreboard.put(key, new Integer(indentLevel));
+			
+		}
+	}
+			
+
+}

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/DiskLayoutTaglet.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/DiskLayoutTaglet.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,130 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild.javadoc
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derbyBuild.javadoc;
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+
+public class DiskLayoutTaglet implements Taglet {
+	/**
+		IBM Copyright &copy notice.
+	*/
+	public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+    private String NAME = "disk_layout";
+    private String ROWNAME = "Disk Layout";
+    /**
+     * Returns the name of this taglet
+     * @return NAME
+     */
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * disk_layout not expected to be used in field documentation.
+     * @return false
+     */
+    public boolean inField() {
+        return false;
+    }
+
+    /**
+     * disk_layout not expected to be used in constructor documentation.
+     * @return false
+     */
+    public boolean inConstructor() {
+        return false;
+    }
+
+    /**
+     * disk_layout not expected to be used in constructor documentation.
+     * @return false
+     */
+    public boolean inMethod() {
+        return false;
+    }
+
+    /**
+     * disk_layout can be used in overview documentation.
+     * @return true
+     */
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * disk_layout can be used in package documentation.
+     * @return true
+     */
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * disk_layout can be used in type documentation.
+     * @return true
+     */
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * disk_layout is not an inline tag.
+     * @return false
+     */
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    /**
+     * Register this Taglet.
+     * @param tagletMap
+     */
+    public static void register(Map tagletMap) {
+       DiskLayoutTaglet tag = new DiskLayoutTaglet();
+       Taglet t = (Taglet) tagletMap.get(tag.getName());
+       if (t != null) {
+           tagletMap.remove(tag.getName());
+       }
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Embed the contents of the disk_layout tag as a row
+     * in the disk format table. Close the table.
+     * @param tag The tag to embed to the disk format the table.
+     */
+    public String toString(Tag tag) {
+        return "<tr><td>" + ROWNAME + "</td>"
+               + "<td>" + tag.text() + "</td></tr></table>\n";
+    }
+
+    /**
+     * Embed multiple disk_layout tags as cells in the disk format table.
+     * Close the table.
+     * @param tags An array of tags to add to the disk format table.
+     */
+    public String toString(Tag[] tags) {
+        if (tags.length == 0) {
+            return null;
+        }
+        String result = "<tr><td>" + ROWNAME + "</td><td>" ;
+        for (int i = 0; i < tags.length; i++) {
+            if (i > 0) {
+                result += "";
+            }
+            result += tags[i].text() + "</td></tr>";
+        }
+        return result + "</table></dt>\n";
+    }
+}
+

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/EndFormatTaglet.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/EndFormatTaglet.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,129 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild.javadoc
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derbyBuild.javadoc;
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+
+// Adapted from ToDoTaglet.java, Copyright  2002.
+
+public class EndFormatTaglet implements Taglet {
+    /**
+		IBM Copyright &copy notice.
+	*/
+	public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+    private String NAME = "end_format";
+    private String ROWNAME = "end_format";
+
+    /**
+     * Returns the name of this taglet
+     * @return NAME
+     */
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * end_format not expected to be used in field documentation.
+     * @return false
+     */
+    public boolean inField() {
+        return false;
+    }
+
+    /**
+     * end_format not expected to be used in constructor documentation.
+     * @return false
+     */
+    public boolean inConstructor() {
+        return false;
+    }
+
+    /**
+     * end_format not expected to be used in method documentation.
+     * @return false
+     */
+    public boolean inMethod() {
+        return false;
+    }
+
+    /**
+     * end_format can be used in overview documentation.
+     * @return true
+     */
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * end_format can be used in package documentation.
+     * @return true
+     */
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * end_format can be used in type documentation.
+     * @return true
+     */
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * end_format is not an inline tag.
+     * @return false
+     */
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    /**
+     * Register this Taglet.
+     * @param tagletMap
+     */
+    public static void register(Map tagletMap) {
+       EndFormatTaglet tag = new EndFormatTaglet();
+       Taglet t = (Taglet) tagletMap.get(tag.getName());
+       if (t != null) {
+           tagletMap.remove(tag.getName());
+       }
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * No-op. Not currently used.
+     * @param tag The tag to embed to the disk format table.
+     */
+    public String toString(Tag tag) {
+        return "";
+    }
+
+    /**
+     * No-op. Not currently used.
+     * @param tags An array of tags to add to the disk format table.
+     */
+    public String toString(Tag[] tags) {
+        if (tags.length == 0) {
+            return null;
+        }
+        String result = "";
+        for (int i = 0; i < tags.length; i++) {
+            if (i > 0) {
+                result += "";
+            }
+            result += "";
+        }
+        return result + "\n";
+    }
+}
+

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/FormatIdTaglet.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/FormatIdTaglet.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,131 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild.javadoc
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derbyBuild.javadoc;
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+
+public class FormatIdTaglet implements Taglet {
+	/**
+		IBM Copyright &copy notice.
+	*/
+	public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+    private String NAME = "format_id";
+    private String ROWNAME = "Format ID";
+
+    /**
+     * Returns the name of this taglet
+     * @return NAME
+     */
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * format_id not expected to be used in field documentation.
+     * @return false
+     */
+    public boolean inField() {
+        return false;
+    }
+
+
+    /**
+     * format_id not expected to be used in constructor documentation.
+     * @return false
+     */
+    public boolean inConstructor() {
+        return false;
+    }
+
+    /**
+     * format_id not expected to be used in method documentation.
+     * @return false
+     */
+    public boolean inMethod() {
+        return false;
+    }
+
+    /**
+     * format_id can be used in overview documentation.
+     * @return true
+     */
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * format_id can be used in package documentation.
+     * @return true
+     */
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * format_id can be used in type documentation.
+     * @return true
+     */
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * format_id is not an inline tag.
+     * @return false
+     */
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    /**
+     * Register this Taglet.
+     * @param tagletMap
+     */
+    public static void register(Map tagletMap) {
+       FormatIdTaglet tag = new FormatIdTaglet();
+       Taglet t = (Taglet) tagletMap.get(tag.getName());
+       if (t != null) {
+           tagletMap.remove(tag.getName());
+       }
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Embed the contents of the format_id tag as a row
+     * in the disk format table.
+     * @param tag The tag to embed to the disk format the table.
+     */
+    public String toString(Tag tag) {
+        return "\n<dt><table cellpadding=2 cellspacing=2><tr><td>" + ROWNAME + "</td>"
+               + "<td>" + tag.text() + "</td></tr>\n";
+    }
+
+    /**
+     * Embed multiple format_id tags as cells in the disk format table.
+     * @param tags An array of tags to add to the disk format table.
+     */
+    public String toString(Tag[] tags) {
+        if (tags.length == 0) {
+            return null;
+        }
+        String result = "<table cellpadding=2 cellspacing=2><tr><td>" + ROWNAME + "</td><td>" ;
+        for (int i = 0; i < tags.length; i++) {
+            if (i > 0) {
+                result += "";
+            }
+            result += tags[i].text() + "</td></tr>";
+        }
+        return result + "\n";
+    }
+}
+

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/PurposeTaglet.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/PurposeTaglet.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,132 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild.javadoc
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derbyBuild.javadoc;
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+
+// Adapted from ToDoTaglet.java, Copyright  2002.
+
+public class PurposeTaglet implements Taglet {
+	/**
+		IBM Copyright &copy notice.
+	*/
+	public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+    private String NAME = "purpose";
+    private String ROWNAME = "Purpose";
+
+    /**
+     * Returns the name of this taglet
+     * @return NAME
+     */
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * purpose not expected to be used in field documentation.
+     * @return false
+     */
+    public boolean inField() {
+        return false;
+    }
+
+    /**
+     * purpose not expected to be used in constructor documentation.
+     * @return false
+     */
+    public boolean inConstructor() {
+        return false;
+    }
+
+    /**
+     * purpose not expected to be used in method documentation.
+     * @return false
+     */
+    public boolean inMethod() {
+        return false;
+    }
+
+    /**
+     * purpose can be used in overview documentation.
+     * @return true
+     */
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * purpose can be used in package documentation.
+     * @return true
+     */
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * purpose can be used in type documentation.
+     * @return true
+     */
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * purpose is not an inline tag.
+     * @return false
+     */
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    /**
+     * Register this Taglet.
+     * @param tagletMap
+     */
+    public static void register(Map tagletMap) {
+       PurposeTaglet tag = new PurposeTaglet();
+       Taglet t = (Taglet) tagletMap.get(tag.getName());
+       if (t != null) {
+           tagletMap.remove(tag.getName());
+       }
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Embed the contents of the purpose tag as a row
+     * in the disk format table.
+     * @param tag The tag to embed to the disk format the table.
+     */
+    public String toString(Tag tag) {
+        return "<tr><td>" + ROWNAME + "</td>"
+               + "<td>" + tag.text() + "</td></tr>\n";
+    }
+
+    /**
+     * Embed multiple purpose tags as cells in the disk format table.
+     * @param tags An array of tags to add to the disk format table.
+     */
+    public String toString(Tag[] tags) {
+        if (tags.length == 0) {
+            return null;
+        }
+        String result = "<tr><td>" + ROWNAME + "</td><td>";
+        for (int i = 0; i < tags.length; i++) {
+            if (i > 0) {
+                result += "";
+            }
+            result += tags[i].text() + "</td></tr>";
+        }
+        return result + "\n";
+    }
+}
+

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/UpgradeTaglet.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/javadoc/UpgradeTaglet.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,130 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild.javadoc
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derbyBuild.javadoc;
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+
+public class UpgradeTaglet implements Taglet {
+    /**
+		IBM Copyright &copy notice.
+	*/
+	public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+    private String NAME = "upgrade";
+    private String ROWNAME = "Upgrade";
+
+    /**
+     * Returns the name of this taglet
+     * @return NAME
+     */
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * upgrade not expected to be used in field documentation.
+     * @return false
+     */
+    public boolean inField() {
+        return false;
+    }
+
+    /**
+     * upgrade not expected to be used in constructor documentation.
+     * @return false
+     */
+    public boolean inConstructor() {
+        return false;
+    }
+
+    /**
+     * upgrade not expected to be used in method documentation.
+     * @return false
+     */
+    public boolean inMethod() {
+        return false;
+    }
+
+    /**
+     * upgrade can be used in overview documentation.
+     * @return true
+     */
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * upgrade can be used in package documentation.
+     * @return true
+     */
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * upgrade can be used in type documentation.
+     * @return true
+     */
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * upgrade is not an inline tag.
+     * @return false
+     */
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    /**
+     * Register this Taglet.
+     * @param tagletMap
+     */
+    public static void register(Map tagletMap) {
+       UpgradeTaglet tag = new UpgradeTaglet();
+       Taglet t = (Taglet) tagletMap.get(tag.getName());
+       if (t != null) {
+           tagletMap.remove(tag.getName());
+       }
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Embed the contents of the upgrade tag as a row
+     * in the disk format table.
+     * @param tag The tag to embed to the disk format the table.
+     */
+    public String toString(Tag tag) {
+        return "<tr><td>" + ROWNAME + "</td>"
+               + "<td>" + tag.text() + "</td></tr>\n";
+    }
+
+    /**
+     * Embed multiple upgrade tags as cells in the disk format table.
+     * @param tags An array of tags to add to the disk format table.
+     */
+    public String toString(Tag[] tags) {
+        if (tags.length == 0) {
+            return null;
+        }
+        String result = "<tr><td>" + ROWNAME + "</td><td>";
+        for (int i = 0; i < tags.length; i++) {
+            if (i > 0) {
+                result += "";
+            }
+            result += tags[i].text() + "</td></tr>";
+        }
+        return result + "\n";
+    }
+}
+

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/propertyconfig.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/propertyconfig.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,340 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild
+   (C) Copyright IBM Corp. 2000, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derbyBuild;
+import java.util.Properties;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.File;
+
+import java.util.StringTokenizer;
+import java.util.Properties;
+import java.util.Enumeration;
+
+
+/**
+ * 
+ * Usage: 
+ * java propertyConfig <master file> <config> <output file>
+ * <B> e.g., java propertyConfig dbms.properties cloudsync
+ * cloudsync.dbms.properties 
+ *
+ * <P>
+ * This program takes a master property file, and using the configuration
+ * specification, generate an output file that only contains the properties
+ * for that particular configuration.
+ *
+ * <P>
+ * For the different types of legitamite configurations, please see
+ * org.apache.derby.modules.properties
+ *
+ * <P>
+ * PropertySplitter will look at cloudscape.config.<tag> to see which
+ * configuration a particular module belongs to.
+ * <B>E.g., cloudscape.config.dataComm.listen=cloudtarget,cloudsync
+ * <B>this means all properties associated with dataComm.listen will be
+ * in the output properties file only if we are generating for the cloudsync or
+ * cloudtarget configuration.  They will not be in the output properties file
+ * if we are generating for the cloud or cloudscape configuration.
+ * 
+ */
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+
+public class propertyconfig { private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2000_2004;
+
+	public static String header = 
+		"######## This is a generated file, do not edit.\n" +
+		"#\n# This file is generated as by propertyConfig\n" +
+		"#\n";
+
+	public static String footer = 
+		"\n######## This is a generated file, do not edit.\n";
+
+	public static void main(String[] args) throws IOException
+	{
+		if (args.length != 3)
+			printUsageAndExit();
+
+		File masterfile = new File(args[0]);
+		File outputfile = new File(args[2]);
+
+		if (!masterfile.exists())
+			printUsageAndExit();
+
+		// OK, got the input cleared up, now do the processing
+		Properties masterProp = new Properties();
+		FileInputStream is = new FileInputStream(masterfile);
+
+		try
+		{
+			masterProp.load(is);
+		}
+		finally
+		{
+			if (is != null)
+				is.close();
+		}
+
+		process(masterProp, args[1], outputfile);
+	}
+
+	/**
+	 * For each module with a particular tag in derby.module.<tag>, see if
+	 * there is any configuration restriction.  If there is no
+	 * cloudscape.config.<tag> property, then this module should be present in
+	 * all configurations.  If there is a cloudscape.config.<tag>, then this
+	 * module should only be present in the configurations listed.
+	 *
+	 * <br>If this module should be present or this configuration, then gather
+	 * up all the properties belong to this module and send it to the output
+	 * file.
+	 *
+	 */
+	private static void process(Properties moduleList, String config, 
+								File outputfile)
+					throws IOException
+	{
+		Properties outputProp = new Properties();
+
+		// copy this code from
+		// org.apache.derby.impl.services.monitor.BaseMonitor 
+		//
+		for (Enumeration e = moduleList.propertyNames(); e.hasMoreElements(); ) 
+		{
+			String key = (String) e.nextElement();
+			if (key.startsWith("derby.module."))
+			{
+				String tag = key.substring("derby.module.".length());
+
+				// Check to see if it has any configuration requirements 
+				String configKey = "cloudscape.config.".concat(tag);
+				String configProp = moduleList.getProperty(configKey);
+				
+				boolean match = false;
+
+				if (configProp != null) 
+				{
+					StringTokenizer st = new StringTokenizer(configProp, ",");
+					while(st.hasMoreTokens()) 
+					{
+
+						String s = st.nextToken().trim();
+
+						// if config spec says all, it should not have other
+						// configurations
+						if (s.equalsIgnoreCase("all") &&
+							!configProp.trim().equals("all"))
+						{
+							System.out.println("illegal config specification "
+											   + key);
+							System.exit(3);
+						}
+
+						// if config spec says none, it should not have other
+						// configurations
+						if (s.equalsIgnoreCase("none") &&
+							!configProp.trim().equals("none"))
+						{
+							System.out.println("illegal config specification "
+											   + key);
+							System.exit(4);
+						}
+
+						if (s.equalsIgnoreCase(config) ||
+							s.equalsIgnoreCase("all"))
+						{
+							match = true;
+							break;
+						}
+					}
+				}
+				else
+				{
+					// no config property, this module goes to all configs
+					System.out.println("Need config specification for " + key);
+					System.exit(2);
+				}
+
+				if (match)
+				{
+					// gather up all relavant properties and put it in
+					// outputProp
+
+					// derby.module.<tag>
+					outputProp.put(key, moduleList.getProperty(key));
+
+					// don't output cloudscape.config.<tag>
+					// that line only has meaning to this program
+
+					// derby.env.classes.<tag>
+					String envKey = "derby.env.classes.".concat(tag);
+					if (moduleList.getProperty(envKey) != null)
+						outputProp.put(envKey, moduleList.getProperty(envKey));
+
+					// derby.env.jdk.<tag>
+					// 
+					// some of the configs only support one java env.  Some modules
+					// have alternate implementation for running on java1 and
+					// java2 platforms.  If we get rid of, say, the java2
+					// implementation, then the monitor won't load the java1
+					// implementation if that module specifies that it should
+					// only be loaded in a java1 environment.  The result is
+					// that some critical modules will be missing and the
+					// database won't boot.
+					//
+					// the convention is, for modules that have both java1 and
+					// java2 implementation, they must named the module as
+					// derby.env.jdk.<name>J1 or
+					// derby.env.jdk.<name>J2
+					// in other words, the <tag> must end with J1 or J2.
+					//
+					// If a config only use one of the two implementation, then
+					// this program will not put the one env.jdk line to the
+					// output properties.  As a result, this one implementation
+					// will be loaded when run in any environment.
+					//
+					// This does not apply to any module that only has one
+					// implementation that runs on a specific jdk environment.
+					//
+					//derby.env.jdk.<tag>
+					envKey = "derby.env.jdk.".concat(tag);
+
+					if (moduleList.getProperty(envKey) != null)
+					{
+						// by default keep the jdk env specification with the
+						// config  
+						boolean saveEnvKey = true;
+
+						// figure out if this is a tag of the form <name>J1 or
+						// <name>J2.
+						if (tag.endsWith("J1") || tag.endsWith("J2"))
+						{
+							// ok, this is a module with alternate
+							// implementation for java 1 and java 2.  If this
+							// config ditches one of them, then do not output
+							// the env line
+							int length = tag.length() - 2;
+							String alternateTag = tag.substring(0, length);
+							
+							if (tag.endsWith("J1"))
+								alternateTag += "J2";
+							else
+								alternateTag += "J1";
+
+							// see if 
+							// 1) this module has an alternate impl for the 
+							// other jdk and 
+							// 2) this config is not going to pick it up.
+							//
+							
+							String alternateImplKey = 
+								"derby.module."+ alternateTag;
+							String alternateJDKEnv = 
+								"derby.env.jdk."+ alternateTag;
+							String alternateImplConfigKey =
+								"cloudscape.config."+alternateTag;
+
+							// if any of of these are not present, then we
+							// don't have a problem because either there is no
+							// alternate implementation, or the alternate
+							// implementation is not based on jdk, or the
+							// alternate jdk based implemenation will also be
+							// present in this configuration
+
+							if ((moduleList.getProperty(alternateImplKey) != null) &&
+								(moduleList.getProperty(alternateJDKEnv) != null) && 
+								(moduleList.getProperty(alternateImplConfigKey) != null))
+							{
+								// there is an alternate impl that is jdk based
+								// and it has a config tag.  Let's see if it is
+								// part of this config.
+								String alternateConfigProp =
+									moduleList.getProperty(alternateImplConfigKey);
+
+								// we know that there are
+								// derby.module.<tag>J2 and
+								// derby.module.<tag>J1 and
+								// derby.env.jdk.<tag>J2 and
+								// derby.env.jdk.<tag>J1 and
+								// cloudscape.config.<tag>J2 and 
+								// cloudscape.config.<tag>J1
+								StringTokenizer st2 = new
+									StringTokenizer(alternateConfigProp, ",");
+
+								boolean ok = false;
+								while(st2.hasMoreTokens()) 
+								{
+									String s = st2.nextToken().trim();
+
+									if (s.equalsIgnoreCase(config) ||
+										s.equalsIgnoreCase("all"))
+									{
+										ok = true;
+										break;
+									}
+								}
+								// the alternate module impl is not part of
+								// this config, do not save the jdk env key
+								if (!ok) 
+									saveEnvKey = false;
+							}
+						}
+
+						if (saveEnvKey)
+							outputProp.put(envKey, moduleList.getProperty(envKey));
+					}
+					
+
+
+					// NOTE, if other types of properties are added to
+					// modules.properties, be sure to add it here too.
+				}
+			}
+		}
+
+		FileOutputStream os = new FileOutputStream(outputfile);
+		try
+		{
+			outputProp.save(os, 
+							header.
+							concat("# config is ").concat(config).
+							concat(footer));
+		}
+		finally
+		{
+			if (os != null)
+				os.close();
+		}
+	}
+
+
+	private static void printUsageAndExit()
+	{
+		StringBuffer buf = new StringBuffer(400);
+
+		buf.append("Usage propertyConfig <masterFile> <config> <outputFile>\n")
+			.append("masterFile must be a pre-existing properties file ")
+			.append("containing all the modules properites\n")
+			.append("config must be a configuration defined in ")
+			.append("org.apache.derby.modules.properties.\n")
+			.append("outputFile must not be a pre-existing properties file.\n\n")
+			.append("propertyConfig will generate the outputFile based on")
+			.append("the masterfile and the configuration specified.")
+			.append("\n\nE.g., java propertyConfig dbms.properties cloudsync dbms.cloudsync.properties\n");
+		
+
+		System.out.println(buf.toString());
+		System.exit(1);
+	}
+}

Added: incubator/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,87 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derbyBuild
+   (C) Copyright IBM Corp. 2000, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derbyBuild;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.derby.iapi.services.i18n.MessageService;
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+
+public class splitmessages { private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2000_2004;
+
+	/**
+		arg[0] is the destination directory
+		arg[1] is the source file.
+	*/
+
+	public static void main(String[] args) throws Exception {
+
+
+		Properties p = new Properties();
+
+		File dir = new File(args[0]);
+
+		File source = new File(args[1]);
+		String s = source.getName();
+		// loose the suffix
+		s = s.substring(0, s.lastIndexOf('.'));
+		// now get the locale
+		String locale = s.substring(s.indexOf('_'));
+
+		boolean addBase = "_en".equals(locale);
+
+
+		InputStream is = new BufferedInputStream(new FileInputStream(source), 64 * 1024);
+
+		p.load(is);
+		is.close();
+
+
+		Properties[] c = new Properties[50];
+		for (int i = 0; i < 50; i++) {
+			c[i] = new Properties();
+		}
+
+		for (Enumeration e = p.keys(); e.hasMoreElements(); ) {
+			String key = (String) e.nextElement();
+
+			c[MessageService.hashString50(key)].put(key, p.getProperty(key));
+		}
+
+		for (int i = 0; i < 50; i++) {
+			if (c[i].size() == 0)
+				continue;
+			OutputStream fos = new BufferedOutputStream(
+				new FileOutputStream(new File(dir, "m"+i+locale+".properties")), 16 * 1024);
+
+			c[i].save(fos, (String) null);
+			fos.flush();
+			fos.close();
+
+			if (addBase) {
+				// add duplicate english file as the base
+				fos = new BufferedOutputStream(
+					new FileOutputStream(new File(dir, "m"+i+".properties")), 16 * 1024);
+				c[i].save(fos, (String) null);
+				fos.flush();
+				fos.close();
+			}
+
+
+		}
+
+		System.out.println("split messages" + locale);
+	}
+}

Added: incubator/derby/code/trunk/java/drda/build.xml
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/build.xml	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<!-- ==================================================================== -->
+<!--                       Cloudscape build file                          -->
+<!-- ==================================================================== -->
+
+<project default="drda" basedir="../..">
+
+<!-- ==================================================================== -->
+<!--                           Set properties                             -->
+<!-- ==================================================================== -->
+
+  <property name="properties.dir" value="tools/ant/properties"/>
+
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+
+  <!-- Parser properties -->
+  <property file="${properties.dir}/parser.properties"/>
+
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+
+  <!-- Release and Version info -->
+  <property file="${properties.dir}/release.properties"/>
+
+<!--             ============ Begin Targets ==============                -->
+ 
+  <target name="drda" >
+    <ant dir="${derby.drda.dir}/impl/drda"/>
+    <ant dir="${derby.drda.dir}/drda"/>
+    <ant dir="${derby.drda.dir}/loc/drda"/>
+  </target>
+
+
+<!--             ============= End Targets ==============                -->
+
+<!--             ============= End Project ==============                -->
+
+</project>
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetServlet.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetServlet.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,1039 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.drda;
+
+import java.io.*;
+import java.util.*;
+
+import java.sql.*;
+import java.net.*;
+
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.derby.iapi.tools.i18n.LocalizedResource;
+import org.apache.derby.iapi.reference.Property;
+
+/**
+	This servlet can be used to start Cloudscape Network Server from a remote location.
+	<P>
+	These servlet configuration parameters are understood by this servlet.
+	<UL>
+	<LI><PRE>portNumber</PRE> - Port number to use. The default is 1527.
+	<LI><PRE>startNetworkServerOnInit</PRE> - Starts the Cloudscape Network Server at servlet 
+			initialization if 'true'.
+	<LI><PRE>tracingDirectory</PRE> - Directory for trace files
+	</UL>
+
+*/
+public class NetServlet extends HttpServlet {
+	/**
+		IBM Copyright &copy notice.
+	*/
+ 
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+	private final static int MAX_CONNECT_TRYS = 20;
+	private final static String SERVLET_PROP_MESSAGES =  "org.apache.derby.loc.drda.servlet";
+	private final static String SERVLET_ADDRESS = "csnet";
+
+	private String formHeader = null;
+	private String host = "localhost";
+	private int portNumber=1527;
+	private String tracingDirectory;
+	private boolean logStatus= false;	/* Logging off */
+	private boolean traceStatus = false;	/* Tracing off */
+	private String[] knownLang = {"en","es","de_DE", "fr", "it", "ja_JP",
+			"ko_KR", "zh_CN", "zh_TW"};
+	private String locale;
+
+	private final static int NOT_GIVEN = -2;
+	private final static int INVALID = -3;
+
+	private NetworkServerControl server;
+	private PrintWriter out;
+
+	// for doPri block
+	private Runnable service;
+
+	/**
+		Initialize the servlet.
+		Configuration parameters:
+		<UL>
+		<LI><PRE>portNumber</PRE> - Port number
+		<LI><PRE>traceDirectory</PRE> - location of trace directory
+		<LI><PRE>startNetworkServerOnInit</PRE> - start the server on initialization
+		</UL>
+	*/
+	public void init(ServletConfig config)
+		throws ServletException
+	{
+
+		LocalizedResource langUtil = new LocalizedResource();
+				
+		String port = config.getInitParameter("portNumber");
+		if (port != null) {
+			int p = Integer.valueOf(port).intValue();
+			if (p > 0)
+				portNumber = p;
+		}
+
+		String tracingDirectory = config.getInitParameter("tracingDirectory");
+
+		String startup = config.getInitParameter("startNetworkServerOnInit");
+
+		// test if the server is already running
+		try {
+			//don't send output to console
+			if (server == null)
+				server = new NetworkServerControl(InetAddress.getByName(host), portNumber);
+			if (isServerStarted(server,1))
+				return;
+		} catch (Exception e) {}
+
+		if (startup != null) {
+			boolean start = Boolean.valueOf(startup).booleanValue();
+			if (start)
+			{
+				runServer(langUtil, null, null);
+				return;
+			}
+		}
+	}
+
+	/**
+		Get the form of NetServlet. Provides buttons and forms to control the
+		Network server.
+	*/
+	public void doGet (HttpServletRequest request, HttpServletResponse response)
+	        throws ServletException, IOException
+	{
+		String logOnMessage;
+		String logOffMessage;
+		String traceOnMessage;
+		String traceOffMessage;
+		String traceOnOffMessage;
+		String startMessage;
+		String stopMessage;
+		String returnMessage;
+		String traceSessionMessage;
+		String traceDirMessage;
+		String contMessage;
+		String setParamMessage;
+		String setParamMessage2;
+		String netParamMessage;
+		LocalizedResource langUtil;
+		
+		langUtil = getCurrentAppUI(request);
+		response.setContentType("text/html; charset=UTF-8");
+		
+		//prevent caching of the servlet since contents can change - beetle 4649
+		response.setHeader("Cache-Control", "no-cache,no-store");
+
+		formHeader = "<form enctype='multipart/form-data; charset=UTF-8' action='" +
+			request.getRequestURI() +" '>";
+
+		out = new PrintWriter(new
+ 			OutputStreamWriter(response.getOutputStream(), "UTF8"),true);
+		
+		//inialize messages
+		logOnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_LogOn"));
+		logOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_LogOff"));
+		traceOnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOn"));
+		traceOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOff"));
+		startMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Start"));
+		stopMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Stop"));
+		traceSessionMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceSessButton"));
+		traceOnOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOnOff"));
+		returnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Return"));
+		traceDirMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceDir"));
+		contMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Continue"));
+		setParamMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_SetParam"));
+		setParamMessage2 = escapeSingleQuotes(langUtil.getTextMessage("SRV_SetParam2"));
+		netParamMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_NetParam"));
+
+		printBanner(langUtil);
+		// set up a server we can use
+		if (server == null) {
+			try {
+				server = new NetworkServerControl();
+			}catch (Exception e) {
+				printErrorForm(langUtil, request, e, returnMessage);
+				return;
+			}
+		}
+		server.setClientLocale(locale);
+		String form = getForm(request);
+		String doAction = getDoAction(request);
+		// if doAction is set, use it to determine form
+		if (doAction != null )
+		{
+			if (doAction.equals(traceOnOffMessage))
+				form = traceSessionMessage;
+			else
+				form = doAction;
+		}
+		// if no form, determine form based on server status
+		boolean serverStatus = getServerStatus();
+		if (form == null)
+		{
+			if (serverStatus)
+				form = startMessage;
+			else
+				form = stopMessage;
+		}
+		else if (form.equals(startMessage))
+		{
+			if (!serverStatus)  {
+				runServer(langUtil, request, returnMessage);
+			}
+		}
+		else if (form.equals(stopMessage))
+		{
+			if (serverStatus)   {
+				shutdownServer(langUtil, request, returnMessage);
+			}
+			setDefaults();
+					
+		}
+		else if (form.equals(returnMessage) || form.equals(returnMessage))
+		{
+			// check if server is still running and use that to determine which form
+			if (serverStatus)
+			{
+				form = startMessage;
+			}
+			else
+			{
+				form = stopMessage;
+			}
+		}
+
+		out.println( formHeader);
+		// display forms
+
+		form = escapeSingleQuotes(form);
+		doAction = escapeSingleQuotes(doAction);
+	  	if (form.equals(startMessage))
+		{
+			String logButton = getLogging(request);
+			String traceButton = getTrace(request);
+			if (logButton !=  null && logButton.equals(logOnMessage))
+			{
+				if (logging(langUtil, true, request, returnMessage))
+					logStatus = true;
+			}
+			if (logButton !=  null && logButton.equals(logOffMessage))
+			{
+				if (logging(langUtil, false, request, returnMessage))
+					logStatus = false;
+			}
+			if (traceButton !=  null && traceButton.equals(traceOnMessage))
+			{
+				if (traceAll(langUtil, true, request, returnMessage))
+					traceStatus = true;
+			}
+			if (traceButton !=  null && traceButton.equals(traceOffMessage))
+			{
+				if (traceAll(langUtil, false, request, returnMessage))
+					traceStatus = false;
+			}
+			displayCurrentStatus(request, langUtil, returnMessage);
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_StopButton")+"</h4>" );
+			out.println( "<INPUT type=submit name=form value='"+ stopMessage + "'>" );
+
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_LogButton2")+"</h4>" );
+
+			if (logStatus)
+			{
+				out.println( "<INPUT type=submit name=logform value='"+logOffMessage + "'>" );
+			}
+			else
+			{
+				out.println( "<INPUT type=submit name=logform value='"+logOnMessage + "'>" );
+			}
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceButton2")+"</h4>" );
+			if (traceStatus)
+			{
+				out.println( "<INPUT type=submit name=traceform value='"+traceOffMessage+ "'>" );
+			}
+			else
+			{
+				out.println( "<INPUT type=submit name=traceform value='"+traceOnMessage + "'>" );
+			}
+
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceSession")+"</h4>" );
+			out.println( "<INPUT type=submit name=form value='"+ traceSessionMessage + "'>" );
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceDirButton")+"</h4>" );
+			out.println( "<INPUT type=submit name=form value='"+ traceDirMessage + "'>" );
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_ThreadButton")+"</h4>" );
+			out.println( "<INPUT type=submit name=form value='"+ netParamMessage+ "'>" );
+		}
+		else if (form.equals(stopMessage))
+		{
+
+			printAsContentHeader(langUtil.getTextMessage("SRV_NotStarted"));
+			String logButton = getLogging(request);
+			String traceButton =  getTrace(request);
+			if (logButton !=  null && logButton.equals(logOnMessage))
+				logStatus = true;
+			if (logButton !=  null && logButton.equals(logOffMessage))
+				logStatus = false;
+			if (traceButton !=  null && traceButton.equals(traceOnMessage))
+				traceStatus = true;
+			if (traceButton !=  null && traceButton.equals(traceOffMessage))
+				traceStatus = false;
+			if (logStatus)
+			{
+				out.println( "<h4>"+langUtil.getTextMessage("SRV_LogOffButton")+"</h4>" );
+				out.println( "<INPUT type=submit name=logform value='"+logOffMessage + "'>" );
+			}
+			else
+			{
+				out.println( "<h4>"+langUtil.getTextMessage("SRV_LogOnButton")+"</h4>" );
+				out.println( "<INPUT type=submit name=logform value='"+logOnMessage + "'>" );
+			}
+			if (traceStatus)
+			{
+				out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceOffButton")+"</h4>" );
+				out.println( "<INPUT type=submit name=traceform value='"+traceOffMessage + "'>" );
+			}
+			else
+			{
+				out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceOnButton")+"</h4>" );
+				out.println( "<INPUT type=submit name=traceform value='"+traceOnMessage + "'>" );
+			}
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_StartButton")+"</h4>" );
+			out.println( "<INPUT type=submit name=form value='"+startMessage+ "'>" );
+		}
+		else if (form.equals(traceSessionMessage))
+		{
+			if (doAction != null)
+			{
+				if (doAction.equals(traceOnOffMessage))
+				{
+					String sessionid = request.getParameter("sessionid");
+					int session = 0;
+					try {
+					 	session = (new Integer(sessionid)).intValue();
+					} catch (Exception e) {
+						printErrorForm(langUtil, request,
+							langUtil.getTextMessage("SRV_InvalidVal",
+							sessionid, langUtil.getTextMessage("SRV_SessionID")),
+							returnMessage);
+						return;
+					}
+					Properties p = null;
+					try {
+						p = server.getCurrentProperties();
+					} catch (Exception e) {
+						printErrorForm(langUtil, request, e, returnMessage);
+						return;
+					}
+					// if it's on, turn it off, if its off, turn it on
+					boolean val;
+					if (p.getProperty(Property.DRDA_PROP_TRACE+sessionid) != null)
+						val = false;
+					else
+						val = true;
+					if (traceSession(langUtil, val, session, request, returnMessage))
+					{
+						if (val)
+							out.println( "<h4>"+langUtil.getTextMessage("SRV_StatusTraceNoOn", sessionid)+"</h4>");
+						else
+							out.println( "<h4>"+langUtil.getTextMessage("SRV_StatusTraceNoOff", sessionid)+"</h4>");
+					}
+					else
+						return;
+						
+				}
+			}
+			printAsContentHeader(langUtil.getTextMessage("SRV_TraceSessButton"));
+			out.println( "<h4>" + getHtmlLabelledMessageInstance(langUtil,
+				"SRV_SessionID", "sessionId") + "</h4>");
+			out.println( "<INPUT type=text name=sessionid size=10 maxlength=10 " +
+				"id='sessionId' value=''>");
+			out.println( "<h4> </h4>");
+			out.println( "<INPUT type=submit name=doaction value='"+traceOnOffMessage+ "'>" );
+			out.println( "<INPUT type=submit name=form value='"+returnMessage+ "'>" );
+		}
+		else if (form.equals(traceDirMessage))
+		{
+			boolean set = false;
+			String traceDirectory = null;
+			printAsContentHeader(traceDirMessage);
+			if (doAction != null)
+			{
+				if (doAction.equals(traceDirMessage))
+				{
+					traceDirectory = getParam(request, "tracedirectory");
+					if (traceDirectory(langUtil, traceDirectory, request,
+							returnMessage) )
+						set = true;
+					else
+						return;
+					
+				}
+			}
+			if (set)
+			{
+				out.println( "<h2>"+langUtil.getTextMessage("SRV_TraceDirDone", traceDirectory)+"</h2>");
+				out.println( "<INPUT type=submit name=form value='"+returnMessage+"'>" );
+			}
+			else
+			{
+				out.println( "<h4>" + getHtmlLabelledMessageInstance(langUtil,
+					"SRV_TraceDir", "tracedir") + "</h4>");
+				out.println( "<INPUT type=text name=tracedirectory size=60 maxlength=256 " +
+					"id='tracedir' value=''>");
+				out.println( "<h4> </h4>");
+				out.println( "<INPUT type=submit name=doaction value='"+traceDirMessage+ "'>" );
+				out.println( "<INPUT type=submit name=form value='"+returnMessage+ "'>" );
+			}
+		}
+		else if (form.equals(netParamMessage))
+		{
+			int maxThreads = 0;
+			int timeSlice = 0;
+			String maxName = langUtil.getTextMessage("SRV_NewMaxThreads");
+			String sliceName = langUtil.getTextMessage("SRV_NewTimeSlice");
+			try {
+				Properties p = server.getCurrentProperties();
+				String val = p.getProperty(Property.DRDA_PROP_MAXTHREADS);
+				maxThreads= (new Integer(val)).intValue();
+				val = p.getProperty(Property.DRDA_PROP_TIMESLICE);
+				timeSlice= (new Integer(val)).intValue();
+			} catch (Exception e) {
+				printErrorForm(langUtil, request, e, returnMessage);
+				return;
+			}
+			if (doAction != null && doAction.equals(netParamMessage))
+			{
+				int newMaxThreads = getIntParameter(request, "newmaxthreads", 
+					"SRV_NewMaxThreads", langUtil, returnMessage);
+				int newTimeSlice = (newMaxThreads == INVALID) ? NOT_GIVEN :
+					getIntParameter(request, "newtimeslice", "SRV_NewTimeSlice", langUtil, 
+						returnMessage);
+				if ((newMaxThreads == INVALID) || (newTimeSlice == INVALID))
+					return;
+				else if (!(newMaxThreads == NOT_GIVEN && newTimeSlice == NOT_GIVEN))
+				{
+					if (newMaxThreads != NOT_GIVEN)
+						maxThreads = newMaxThreads;
+					if (newTimeSlice != NOT_GIVEN)
+						timeSlice = newTimeSlice;
+					if (!setNetParam(langUtil, maxThreads, timeSlice, request,
+							returnMessage))
+						return;
+				}
+			}
+			
+			out.println(formHeader);
+			printAsContentHeader(netParamMessage);
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_MaxThreads", new Integer(maxThreads).toString()) +"</h4>");
+			out.println( "<h4>"+langUtil.getTextMessage("SRV_TimeSlice", new Integer(timeSlice).toString()) +"</h4>");
+			out.println( "<h4> </h4>");
+			out.println( "<h4> <label for='newmaxthreads'>"+maxName+"</label> </h4>");
+			out.println( "<INPUT type=text name=newmaxthreads size=10 maxlength=10 " +
+				"id='newmaxthreads' value=''>" );
+			out.println( "<h4> <label for='newslice'>"+sliceName+"</label> </h4>");
+			out.println( "<INPUT type=text name=newtimeslice size=10 maxlength=10 " +
+				"id='newslice' value=''>" );
+			out.println( "<h4> </h4>");
+			out.println( "<INPUT type=submit name=doaction value='"+netParamMessage+ "'>" );
+			out.println( "<INPUT type=submit name=form value='"+returnMessage+ "'>" );
+		}
+		else
+		{
+			System.out.println("Internal Error: Unknown form, "+ form);
+			out.println("Internal Error: Unknown form, "+ form);
+
+
+		}
+
+		out.println( "</html>" ); 
+		out.println( "</body>" ); 	
+
+	}
+
+	/**
+		Get the form of NetServlet. Provides a buttons and form to control the
+		Network server
+
+	*/
+	public void doPost (HttpServletRequest request, HttpServletResponse response)
+	        throws ServletException, IOException
+	{
+		// simply call the doGet()
+		doGet(request, response);
+	}
+
+	private String getForm(HttpServletRequest request)  throws java.io.IOException{
+		return getParam(request, "form");
+	}
+	private String getDoAction(HttpServletRequest request) throws java.io.IOException {
+		return getParam(request, "doaction");
+	}
+	private String getLogging(HttpServletRequest request) throws java.io.IOException {
+		return getParam(request, "logform");
+	}
+	private String getTrace(HttpServletRequest request) throws java.io.IOException {
+		return getParam(request, "traceform");
+	}
+
+	/**
+	 *  get UTF8 parameter value and decode international characters
+	 *  @param request   HttpServletRequest
+	 *  @param paramName  Parameter name
+	 *  @return decoded String
+	 */
+	private String getParam(HttpServletRequest request, String paramName) throws
+	java.io.IOException { 
+				
+		String newValue= null;
+		String value = request.getParameter(paramName);
+		if (value == null)
+			return value;
+		newValue = new String(value.getBytes("ISO-8859-1"),"UTF8");
+		return newValue;
+	}
+
+	/**
+	 *	Start the network server and attempt to connect to it before
+	 *	returning
+	 *
+	 * @param localAppUI	AppUI to use to translate messages
+	 * @param request HttpServetRequest for error forms
+	 * @param returnMessage	localized continue message for continue button on error form	
+	 * @exception ServletException throws an exception if error in starting the 
+	 * 		Network Server during initialization
+	 */
+	private void runServer(LocalizedResource localUtil, HttpServletRequest request,
+		String returnMessage)
+		throws ServletException
+	{
+		service = new Runnable() {
+			public void run() {
+				try {
+					//Echo server output to console
+					NetworkServerControl runserver = new
+						NetworkServerControl(InetAddress.getByName(host),
+											 portNumber);
+					runserver.start(null);
+				}
+				catch (Exception e) {
+					throw new RuntimeException(e.getMessage());
+				}
+			}
+		};
+		Thread servThread = null;
+		try {
+			servThread = (Thread) AccessController.doPrivileged(
+								new PrivilegedExceptionAction() {
+									public Object run() throws Exception
+									{
+										return new Thread(service);
+									}
+								}
+							);
+		}
+		catch (Exception e) {
+			throw new RuntimeException(e.getMessage());
+		}
+		servThread.start();
+
+		// try to connect to server
+		try {
+			boolean connectWorked = false;
+			int t = 0;
+			do
+			{
+				t++;
+				try {
+						Thread.sleep(100);
+				} catch (InterruptedException ie) {
+					throw new ServletException(localUtil.getTextMessage("SRV_Interupt"));
+				}
+				try {
+					if (isServerStarted(server,1))
+						connectWorked = true;
+				} catch (Exception e) {} //ignore error we'll just try again
+				
+			}while (!connectWorked && t < MAX_CONNECT_TRYS);
+			if (t >= MAX_CONNECT_TRYS)
+				throw new Exception(localUtil.getTextMessage("SRV_MaxTrys",
+					new Integer(MAX_CONNECT_TRYS).toString()));
+			// turn logging on if required
+			if (logStatus)
+				server.logConnections(true);
+			// turn tracing on
+			if (traceStatus)
+				server.trace(true);
+		}catch (Exception e) {
+			if (out != null)
+				printErrorForm(localUtil, request, e, returnMessage);
+			else
+				throw new ServletException(e.getMessage());
+		}
+	}
+	/**
+	 *	Display an error form
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param request HttpServetRequest for error forms
+	 * @param e		Exception to be displayed
+	 * @param returnMessage	localized continue message for continue button on error form
+	 */
+	private void printErrorForm(LocalizedResource localUtil, HttpServletRequest request,
+		Exception e, String returnMessage)
+	{
+		printAsContentHeader(localUtil.getTextMessage("SRV_NetworkServerError"));
+		out.println( "<h4>"+localUtil.getTextMessage("SRV_Message", e.getMessage()) + "</h4>" );
+		out.println( "<INPUT type=submit name=form value='"+returnMessage+"'>" );
+		out.println( "</html>" );
+		out.println( "</body>" );
+	}
+	/**
+	 *	Display an error form
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param request HttpServetRequest for error forms
+	 * @param msg	String to be displayed
+	 * @param returnMessage	localized continue message for continue button on error form
+	 */
+	private void printErrorForm(LocalizedResource localUtil, HttpServletRequest request,
+		String msg, String returnMessage)
+	{
+		printAsContentHeader(localUtil.getTextMessage("SRV_NetworkServerError"));
+		out.println( "<h4>"+localUtil.getTextMessage("SRV_Message", msg) + "</h4>" );
+		out.println( "<INPUT type=submit name=form value='"+returnMessage+"'>" );
+		out.println( "</html>" ); 
+		out.println( "</body>" ); 	
+	}
+	/**
+	 *	Display the current Network server status
+	 *
+	 * @param request	HttpServetRequest for  forms
+	 * @param appUI		appUI to use for localizing messages
+	 * @param returnMessage	localized continue message for continue button on error form	
+	 */
+	private void displayCurrentStatus(HttpServletRequest request,
+		LocalizedResource localUtil, String returnMessage)
+	{
+		try {
+
+			printAsContentHeader(localUtil.getTextMessage("SRV_Started"));
+			Properties p = server.getCurrentProperties();
+			String val = p.getProperty(Property.DRDA_PROP_LOGCONNECTIONS);
+			if (val.equals("true"))
+				logStatus = true;
+			else
+				logStatus = false;
+			if (logStatus)
+				out.println( "<h4>"+localUtil.getTextMessage("SRV_StatusLogOn")+"</h4>");
+			else
+				out.println( "<h4>"+localUtil.getTextMessage("SRV_StatusLogOff")+"</h4>");
+			val = p.getProperty(Property.DRDA_PROP_TRACEALL);
+			if (val.equals("true"))
+				traceStatus = true;
+			else
+				traceStatus = false;
+			if (traceStatus)
+				out.println( "<h4>"+localUtil.getTextMessage("SRV_StatusTraceOn")+"</h4>");
+			else
+				out.println( "<h4>"+localUtil.getTextMessage("SRV_StatusTraceOff")+"</h4>");
+		}
+		catch (Exception e) {
+			printErrorForm(localUtil, request, e, returnMessage);
+		}
+	}
+	/**
+	 *	Get the currrent server status by using test connection
+	 *
+	 * @return true if server is up and reachable; false; otherwise
+	 */
+	private boolean getServerStatus()
+	{
+		try {
+			
+			if (isServerStarted(server,1))
+				return true;
+		} catch (Exception e) {}
+		return false;
+	}
+	/**
+	 *	Shutdown the network server
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param request HttpServetRequest for  forms
+	 * @param returnMessage	localized continue message for continue button on error form	
+	 * @return true if succeeded; false; otherwise
+	 */
+	private boolean shutdownServer(LocalizedResource localUtil,
+		HttpServletRequest request, String returnMessage)
+	{
+		boolean retval = false;
+		try {
+			server.shutdown();
+			retval = true;
+		} catch (Exception e) 
+		{
+			printErrorForm(localUtil, request, e, returnMessage);
+		}
+		return retval;
+	}
+	/**
+	 *	Turn logging of connections on
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param request HttpServetRequest for  forms
+	 * @param returnMessage	localized continue message for continue button on error form	
+	 * @return true if succeeded; false; otherwise
+	 */
+	private boolean logging(LocalizedResource localUtil, boolean val,
+		HttpServletRequest request, String returnMessage)
+	{
+		boolean retval = false;
+		try {
+			server.logConnections(val);
+			retval = true;
+		} catch (Exception e) 
+		{
+			printErrorForm(localUtil, request, e, returnMessage);
+		}
+		return retval;
+	}
+	/**
+	 *	Change tracing for all sessions 
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param val	if true, turn tracing on, if false turn it off
+	 * @param request HttpServetRequest for  forms
+	 * @param returnMessage	localized continue message for continue button on error form	
+	 * @return true if succeeded; false; otherwise
+	 */
+	private boolean traceAll(LocalizedResource localUtil, boolean val,
+		HttpServletRequest request, String returnMessage)
+	{
+		boolean retval = false;
+		try {
+			server.trace(val);
+			retval = true;
+		} catch (Exception e) 
+		{
+			printErrorForm(localUtil, request, e, returnMessage);
+		}
+		return retval;
+	}
+	/**
+	 *	Change tracing for a given session
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param val	if true, turn tracing on, if false turn it off
+	 * @param session	session to trace
+	 * @param request HttpServetRequest for  forms
+	 * @param returnMessage	localized continue message for continue button on error form	
+	 * @return true if succeeded; false; otherwise
+	 */
+	private boolean traceSession(LocalizedResource localUtil, boolean val, int session,
+		HttpServletRequest request, String returnMessage)
+	{
+		boolean retval = false;
+		try {
+			server.trace(session, val);
+			retval = true;
+		} catch (Exception e) 
+		{
+			printErrorForm(localUtil, request, e, returnMessage);
+		}
+		return retval;
+	}
+
+	/**
+	 * Set trace directory
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param traceDirectory	directory for trace files
+	 * @param request 			HttpServetRequest for  forms
+	 * @param returnMessage		localized continue message for continue 
+	 *							button on error form	
+	 * @return true if succeeded; false; otherwise
+	 */
+	private boolean traceDirectory(LocalizedResource localUtil, String traceDirectory,
+		HttpServletRequest request, String returnMessage)
+	{
+		boolean retval = false;
+
+		if ((traceDirectory == null) || traceDirectory.equals("")) {
+			printErrorForm(localUtil, request,
+				localUtil.getTextMessage("SRV_MissingParam",
+				localUtil.getTextMessage("SRV_TraceDir")), returnMessage);
+
+			return retval;
+		}
+
+		try {
+			server.setTraceDirectory(traceDirectory);
+			retval = true;
+		} catch (Exception e) 
+		{
+			printErrorForm(localUtil, request, e, returnMessage);
+		}
+		return retval;
+	}
+
+	/**
+	 * Set Network server parameters
+	 *
+	 * @param appUI	AppUI to use to translate messages
+	 * @param max				maximum number of threads
+	 * @param slice				time slice for each connection
+	 * @param request 			HttpServetRequest for  forms
+	 * @param returnMessage		localized continue message for continue 
+	 *							button on error form	
+	 * @return true if succeeded; false; otherwise
+	 */
+	private boolean setNetParam(LocalizedResource localUtil, int max, int slice,
+		HttpServletRequest request, String returnMessage)
+	{
+		boolean retval = false;
+
+		try {
+			server.setMaxThreads(max);
+			server.setTimeSlice(slice);
+			retval = true;
+		} catch (Exception e) 
+		{
+			printErrorForm(localUtil, request, e, returnMessage);
+		}
+		return retval;
+	}
+
+
+	/** 
+	 * Set defaults for logging and tracing (both off)
+	 */
+	private void setDefaults()
+	{
+		logStatus = false;
+		traceStatus = false;
+	}
+	/**
+	 * Get an integer parameter
+	 *
+	 * @param request 			HttpServetRequest for  forms
+	 * @param name				parameter name
+	 * @param fieldKey			Key for the name of the field we're reading.
+	 * @param appUI				appUI to use in localizing messages
+	 * @param returnMessage		localized continue message for continue 
+	 *							button on error form	
+	 */
+	private int getIntParameter(HttpServletRequest request,
+			String name, String fieldKey, LocalizedResource localUtil, String returnMessage)
+	{
+		String val = request.getParameter(name);
+		int retval;
+		if (val == null || val.equals(""))
+			return NOT_GIVEN;
+		try {
+		 	retval = (new Integer(val)).intValue();
+		} catch (Exception e) {
+			printErrorForm(localUtil, request,localUtil.getTextMessage("SRV_InvalidVal",
+				val, localUtil.getTextMessage(fieldKey)), returnMessage);
+			return INVALID;
+		}
+		if (retval < 0) {
+		// negative integers not allowed for the parameters we're getting.
+			printErrorForm(localUtil, request, localUtil.getTextMessage("SRV_InvalidVal",
+				val, localUtil.getTextMessage(fieldKey)), returnMessage);
+			return INVALID;
+		}
+		return retval;
+	}
+	/**
+	 * Print Cloudscape Network Server banner
+	 */
+	private void printBanner(LocalizedResource localUtil)
+	{
+		out.println("<a href=\"#navskip\">[ " +
+		localUtil.getTextMessage("SRV_SkipToContent") + " ]</a>");
+		out.println("  -  <a href=\"" + SERVLET_ADDRESS + "\">[ " +
+		localUtil.getTextMessage("SRV_BackToMain") + " ]</a>");
+		out.println( "<html>" );		
+		out.println( "<title>"+localUtil.getTextMessage("SRV_Banner")+"</title>" );
+		out.println( "<body>" ); 	
+		out.println( "<hr>" );
+		out.println( "<h1>"+localUtil.getTextMessage("SRV_Banner")+"</h1>" );
+		out.println( "<hr>" );
+
+	}
+	/**
+	 * Determine the locale file needed for this browsers preferences
+	 * Defaults to the settings for db2j.locale and db2j.codeset if set
+	 *		English otherwise if browsers preferences can't be found
+	 *
+	 * @param request 			HttpServetRequest for forms
+	 * @return the appUI which fits the browsers preferences
+	 */
+	private LocalizedResource getCurrentAppUI(HttpServletRequest request)
+	{
+		LocalizedResource localUtil;
+		String acceptLanguage = request.getHeader("Accept-Language");
+		localUtil = new LocalizedResource(null,null,SERVLET_PROP_MESSAGES);
+		// if no language specified use one set by db2j.locale, db2j.codeset
+		locale = null;
+		if (acceptLanguage == null)
+		{
+        	localUtil.init();
+			return localUtil;
+		}
+		// Use a tokenizer ot separate acceptable languages
+		StringTokenizer tokenizer = new StringTokenizer(acceptLanguage, ",");
+		while (tokenizer.hasMoreTokens())
+		{
+			//Get the next acceptable language
+			String lang = tokenizer.nextToken();
+			lang = getLocStringFromLanguage(lang);
+			int langindex = translationAvailable(lang);
+			// have we found one
+			if (langindex != -1)
+			{
+				localUtil.init(null, lang, SERVLET_PROP_MESSAGES);
+				// locale will be passed to server, server routines will get set appropriately
+				locale = lang;
+				return localUtil;
+			}
+		}
+		// nothing worked use defaults
+        localUtil.init();
+		return localUtil;
+		
+	}
+	/**
+	 * Get locale string from language which may have qvalue set
+	 * 
+	 * @param lang	language string to parse
+	 *
+	 * @return stripped language string to use in matching
+	 */
+	private String getLocStringFromLanguage(String lang)
+	{
+		int semi;
+		// Cut off any q-value that might come after a semi-colon
+		if ((semi = lang.indexOf(';')) != -1)
+		{
+			lang = lang.substring(0, semi);
+		}
+		// trim any whitespace
+		lang = lang.trim();
+		
+		return lang;
+	}
+	/**
+	 * Check if the required translation is available
+	 *
+	 * @param lang	language we are looking for
+	 * 
+	 * @return index into language array if found, -1 otherwise;
+	 */
+	private int translationAvailable(String lang)
+	{
+		for (int i = 0; i < knownLang.length; i++)
+			if (knownLang[i].toUpperCase(Locale.ENGLISH).equals(lang.toUpperCase(Locale.ENGLISH)))
+				return i;
+		return -1;
+	}
+
+	/**
+	 * get an HTML labelled message from the resource bundle file, according to
+	 * the given key.
+	 */
+	public String getHtmlLabelledMessageInstance(LocalizedResource localUtil, String key, String id) {
+
+		if (id == null)
+			id = "";
+
+		return ("<label for='" + id + "'>" + localUtil.getTextMessage(key) +
+			"</label>");
+
+	}
+
+	/**
+	 * Print the received string as a header.
+	 * @param str The string to be printed as a header.
+	 */
+	private void printAsContentHeader(String str) {
+
+		out.println("<a name=\"navskip\"></a><h2>" + str + "</h2>");
+		return;
+
+	}
+
+	/**
+	 * If the received string has one or more single quotes
+	 * in it, replace each one with the HTML escape-code
+	 * for a single quote (apostrophe) so that the string 
+	 * can be properly displayed on a submit button.
+	 * @param str The string in which we want to escape
+	 *  single quotes.
+	 */
+	private String escapeSingleQuotes(String str) {
+
+		if ((str == null) || (str.indexOf("'") < 0))
+			return str;
+
+		char [] cA = str.toCharArray();
+
+		// Worst (and extremely unlikely) case is every 
+		// character is a single quote, which means the
+		// escaped string would need to be 4 times as long.
+		char [] result = new char[4*cA.length];
+
+		int j = 0;
+		for (int i = 0; i < cA.length; i++) {
+
+			if (cA[i] == '\'') {
+				result[j++] = '&';
+				result[j++] = '#';
+				result[j++] = '3';
+				result[j++] = '9';
+			}
+			else
+				result[j++] = cA[i];
+
+		}
+
+		return new String(result, 0, j);
+
+	}
+
+	private static boolean isServerStarted(NetworkServerControl server, int ntries)
+	{
+		for (int i = 1; i <= ntries; i ++)
+		{
+			try {
+				Thread.sleep(500);
+				server.ping();
+				return true;
+			}
+			catch (Exception e) {
+				if (i == ntries)
+					return false;
+			}
+		}
+		return false;
+	}
+	
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,468 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.drda
+   (C) Copyright IBM Corp. 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.drda;
+
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.util.Properties;
+import org.apache.derby.iapi.reference.Property;
+
+import org.apache.derby.impl.drda.DB2jServerImpl;
+
+/** 
+	NetworkServerControl provides the ability to start a Network Server or 
+	connect to a running Network Server to shutdown, configure or retreive 
+	diagnostic information.  With the exception of ping, these commands 
+	can  only be performed from the  machine on which the server is running.  
+	Commands can be performed from  the command line with the following 
+	arguments:
+
+	<P>
+	<UL>
+	<LI>start [-h &lt;host>] [-p &lt;portnumber>]:  This starts the network
+	server on the port/host specified or on localhost, port 1527 if no
+	host/port is specified and no properties are set to override the 
+	defaults. By default Network Server will only listen for 
+	connections from the machine on which it is running. 
+	Use -h 0.0.0.0 to listen on all interfaces or -h &lt;hostname> to listen 
+	on a specific interface on a  multiple IP machine. </LI>
+
+	<LI>shutdown [-h &lt;host>][-p &lt;portnumber>]: This shutdowns the network 	server on the host and port specified or on the local host and port 
+	1527(default) if no host or port is specified.  </LI> 
+
+	<LI>ping [-h &lt;host>] [-p &lt;portnumber>] 
+	This will test whether the Network Server is up.
+	</LI>
+
+	<LI>sysinfo [-h &lt;host>] [-p &lt;portnumber>]:  This prints 
+	classpath and version  information about the Network Server, 
+	the JVM and the Cloudscape server. 
+
+	<LI>runtimeinfo [-h &lt;host] [-p &lt;portnumber]: This prints
+	extensive debbugging information about sessions, threads, 
+	prepared statements, and memory usage for the running Network Server.
+	</LI>
+
+	<LI>logconnections {on | off} [-h &lt;host>] [-p &lt;portnumber>]:  
+	This turns logging of connections and disconnections on and off.  
+	Connections and disconnections are logged to derby.log. 
+	Default is off.</LI>
+
+	<LI>maxthreads &lt;max> [-h &lt;host>][-p &lt;portnumber>]:  
+	This sets the maximum number of threads that can be used for connections. 
+	Default 0 (unlimitted).
+	</LI>
+
+	<LI>timeslice &lt;milliseconds> [-h &lt;host>][-p &lt;portnumber>]: 
+	This sets the time each session can have using a connection thread 
+	before yielding to a waiting session. Default is 0 (no yeild).
+	
+	</LI>
+
+	<LI>trace {on | off} [-s &lt;session id>] [-h &lt;host>] [-p &lt;portnumber>]: 
+	This turns drda tracing on or off for the specified session or if no 
+	session is  specified for all sessions. Default is off</LI>
+
+
+	<LI>tracedirectory &lt;tracedirectory> [-h &lt;host>] [-p &lt;portnumber>]: 
+	This changes where new trace files will be placed. 
+	For sessions with tracing already turned on,  
+	trace files remain in the previous location. 
+	Default is clousdcape.system.home</LI>
+
+	</UL>
+	<P>Properties can be set in the derby.properties file or on the command line.
+	Properties on the command line take precedence over properties in the 
+	derby.properties file.  Arguments on the command line take precedence
+	over properties. 
+	The following is a list of properties that can be set for 
+	NetworkServerControl:
+
+	<UL><LI>derby.drda.portNumber=&lt;port number>: This property 
+	indicates which port should be used for the Network Server. </LI>
+
+	<LI>derby.drda.host=&lt;host name  or ip address >: This property 
+	indicates the ip address to which NetworkServerControl should connect 
+
+	<LI>derby.drda.traceDirectory=&lt;trace directory>: This property 
+	indicates where to put trace files. </LI>
+
+	<LI>derby.drda.traceAll=true:  This property turns on tracing for
+	all sessions. Default is tracing is off.</LI>
+
+	<LI>derby.drda.logConnections=true:  This property turns on logging
+	of connections and disconnections. Default is connections are not logged.</LI>
+
+	<LI>derby.drda.minThreads=&lt;value>: If this property
+	is set, the &lt;value> number of threads will be created when the Network Server is
+	booted. </LI>
+
+	<LI>derby.drda.maxThreads=&lt;value>: If this property
+	is set, the &lt;value> is the maximum number of connection threads that will be 
+	created.  If a session starts when there are no connection threads available
+	and the maximum number of threads has been reached, it will wait until a 
+	conection thread becomes available. </LI>
+
+	<LI>derby.drda.timeSlice=&lt;milliseconds>: If this property
+	is set, the connection threads will not check for waiting sessions until the
+	current session has been working for &lt;milliseconds>.  
+	A value of 0 causes the thread to work on the current session until the 
+	session exits. If this property is not set, the default value is 0. </LI>
+	
+</LI>
+
+<P><B>Examples.</B>
+
+	<P>This is an example of shutting down the server on port 1621.
+	<PRE> 
+	java org.apache.derby.drda.NetworkServerControl shutdown -p 1621
+	</PRE>
+
+	<P>This is an example of turning tracing on for session 3
+	<PRE>
+	java org.apache.derby.drda.NetworkServerControl  trace on -s 3 
+	</PRE>
+
+	<P>This is an example of starting and then shutting down the network 
+	   server on port 1621 on machine myhost   
+	<PRE>
+	java org.apache.derby.drda.NetworkServerControl  start -h myhost -p 1621
+	java org.apache.derby.drda.NetworkServerControl  shutdown -h myhost -p 1621
+	</PRE>
+
+	<P> This is an example of starting and shutting down the Network Server in the example
+	above with the API.
+	<PRE>
+	
+	NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("myhost"),1621)
+
+	serverControl.shutdown();
+	</PRE>
+
+	
+*/
+
+public class NetworkServerControl{ 
+
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2004;
+
+
+	
+	public final static int DEFAULT_PORTNUMBER = 1527;
+	private DB2jServerImpl serverImpl;
+
+	// constructor
+
+	/**
+	 * 
+	 * Creates a NetworkServerControl object that is configured to control
+	 * a Network Server on a  specified port and InetAddress.
+	 *<P>
+	 * <B> Examples: </B>
+	 * <P>
+	 * To configure for port 1621 and listen on the loopback address:
+	 *<PRE>
+	 *  NetworkServerControl  util = new
+	 * NetworkServerControl(InetAddress.getByName("localhost"), 1621);
+	 * </PRE>
+	 *
+	 * @param address     The IP address of the Network Server host.
+	 *                     address cannot be null.
+
+	 * @param portNumber  port number server is to used. If <= 0,
+	 *                    default port number is used
+	 *                       
+	 * @throws             Exception on error
+	 */
+	public NetworkServerControl(InetAddress address,int portNumber) throws Exception
+	{
+		
+		serverImpl = new DB2jServerImpl(address, 
+										portNumber);
+
+	}
+	
+
+	/**
+	 * 
+	 * Creates a NetworkServerControl object that is configured to control
+	 * a Network Server on the default host(localhost)
+	 * and the default port(1527) unless derby.drda.portNumber and 
+	 * derby.drda.host are set.
+	 * <P><PRE>
+	 * new NetworkServerControl() 
+	 *
+	 * is equivalent to calling
+	 *
+	 * new NetworkServerControl(InetAddress.getByName("localhost"),1527);
+	 * </PRE>
+	 *
+	 * @throws             Exception on error
+	 */
+	public NetworkServerControl() throws Exception
+	{
+		
+		serverImpl = new DB2jServerImpl();
+
+	}
+	
+    
+	/**
+	 * main routine for NetworkServerControl
+	 *
+	 * @param args	array of arguments indicating command to be executed.
+	 * See class comments for more information
+	 */
+    public static void main(String args[]) {
+		DB2jServerImpl.execute(args);
+		
+	}
+
+	/**********************************************************************
+	 * Public NetworkServerControl  commands
+	 * The server commands throw exceptions for errors, so that users can handle
+	 * them themselves.
+	 ************************************************************************
+	 **/
+
+	/** Start a Network Server
+	 *  This method will launch a separate thread and start Network Server.
+	 *  This method  may return before the server is ready to accept connections.
+	 *  Use the ping method to verify that the server has started.
+	 *
+	 * <P>
+	 *  Note: an alternate method to starting the Network Server with the API,
+	 *  is to use the derby.drda.startNetworkServer property in 
+	 *  cloudscape.properties.
+	 *  
+	 * 
+	 * @param consoleWriter   PrintWriter to which server console will be 
+	 *                        output. Null will disable console output. 
+	 *
+	 * @exception Exception if there is an error starting the server.
+	 *
+	 * @see #shutdown
+	 */
+	public void start(PrintWriter consoleWriter) throws Exception
+	{
+		serverImpl.start(consoleWriter);
+	}
+
+	
+
+	/**
+	 * Shutdown a Network Server.
+	 * Shuts down the Network Server listening on the port and InetAddress
+	 * specified in the constructor for this NetworkServerControl object.
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void shutdown()
+		throws Exception
+	{
+		serverImpl.shutdown();
+	}
+
+	/**
+	 * Check if Network Server is started
+	 * Excecutes and returns without error if the server has started
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void  ping() throws Exception
+	{
+		 serverImpl.ping();
+	}
+
+	/**
+	 * Turn tracing on or off for the specified connection 
+	 * on the Network Server.
+	 *
+	 * @param on true to turn tracing on, false to turn tracing off.
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void trace(boolean on)
+		throws Exception
+	{
+		serverImpl.trace(on);
+	}
+
+
+	/**
+	 * Turn tracing on or off for all connections on the Network Server.
+	 *
+	 * @param connNum connection number. Note: Connection numbers will print
+	 *                in the Cloudscape error log if logConnections is on
+	 * @param on true to turn tracing on, false to turn tracing off.
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void trace(int connNum, boolean on)
+		throws Exception
+	{
+		serverImpl.trace(connNum, on);
+	}
+
+	/**
+	 * Turn logging connections on or off. When logging is turned on a message is
+	 * written to the Cloudscape error log each time a connection 
+	 * connects or disconnects.
+	 *
+	 * @param on			true to turn on, false to turn  off
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void logConnections(boolean on)
+		throws Exception
+	{
+		serverImpl.logConnections(on);
+	}
+
+	/**
+	 * Set directory for trace files. The directory must be on the machine
+	 * where the server is running.
+	 *
+	 * @param traceDirectory	directory for trace files on machine 
+	 *                          where server is running
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void setTraceDirectory(String traceDirectory)
+		throws Exception
+	{
+		serverImpl.sendSetTraceDirectory(traceDirectory);
+	}
+
+	/**
+	 * Return classpath and version information about the running 
+	 * Network Server. 
+	 *
+	 * @return sysinfo output
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public String getSysinfo()
+		throws Exception
+	{
+		
+		return serverImpl.sysinfo();
+	}
+
+	/**
+	 * Return detailed session runtime information about sessions,
+	 * prepared statements, and memory usage for the running Network Server. 
+	 *
+	 * @return run time information
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public String getRuntimeInfo()
+		throws Exception
+	{
+		return serverImpl.runtimeInfo();
+	}
+
+
+	/**
+	 * Set Network Server maxthread parameter.  This is the maximum number 
+	 * of threads that will be used for JDBC client connections.   setTimeSlice
+	 * should also be set so that clients will yield appropriately.
+	 *
+	 * @param max		maximum number of connection threads.
+	 *                  If <= 0, connection threads will be created when 
+	 *                  there are no free connection threads.
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 * @see #setTimeSlice
+	 */
+	public void setMaxThreads(int max) throws Exception
+	{
+		serverImpl.netSetMaxThreads(max);
+	}
+
+
+	/** Returns the current maxThreads setting for the running Network Server
+	 * 
+	 * @return maxThreads setting 
+	 * @exception Exception	throws an exception if an error occurs
+	 * @see #setMaxThreads
+	 */
+	public int getMaxThreads() throws Exception
+	{
+	    String val =serverImpl.getCurrentProperties().getProperty(Property.DRDA_PROP_MAXTHREADS);
+
+		
+		return Integer.parseInt(val);
+	}
+
+	/**
+	 * Set Network Server connection time slice parameter.  
+	 * This should be set and is only relevant if setMaxThreads > 0.
+	 *
+	 * @param timeslice	number of milliseconds given to each session before yielding to 
+	 *						another session, if <=0, never yield. 
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 * @see #setMaxThreads
+	 */
+	public void setTimeSlice(int timeslice) throws Exception
+	{
+		serverImpl.netSetTimeSlice(timeslice);
+	}
+
+	/** Return the current timeSlice setting for the running Network Server
+	 * 
+	 * @return timeSlice  setting
+	 * @exception Exception throws an exception if an error occurs
+	 * @see #setTimeSlice
+	 */
+	public int getTimeSlice() throws Exception
+	{
+		String val  =
+			serverImpl.getCurrentProperties().getProperty(Property.DRDA_PROP_TIMESLICE);
+		return Integer.parseInt(val);
+	}
+
+
+
+	/**
+	 * Get current Network server properties
+	 *
+	 * @return Properties object containing Network server properties
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public Properties getCurrentProperties() throws Exception
+	{
+		return serverImpl.getCurrentProperties();
+	}
+
+	/** Protected methods ***/
+
+	/***
+	 * set the client locale. Used by servlet for localization
+	 * @param locale  Locale to use
+	 *
+	 */
+		  
+	protected void setClientLocale(String locale)
+	{
+		serverImpl.clientLocale = locale;
+	}
+}
+
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/drda/build.xml
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/drda/build.xml	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+
+<project default="drda" basedir="../../../../../..">
+
+<!-- Set Properties -->
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+  <!-- Set property lib dir -->
+  <property name="properties.dir" value="tools/ant/properties"/>
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+
+<!-- Targets -->
+  <target name="drda" depends="compile,servlet"/>
+
+  <target name="compile">
+    <javac
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="${debug}"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.drda.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${compile.classpath}"/>
+      </classpath>
+      <include name="${derby.dir}/drda/*.java"/>
+      <exclude name="${derby.dir}/drda/NetServlet.java"/>
+    </javac>
+  </target>
+
+  <target name="servlet" depends="checkservletjar" if="servletjar.available">
+    <javac
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="${debug}"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.drda.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+	 	<pathelement location="${servlet22}"/>
+        <pathelement path="${compile.classpath}"/>
+      </classpath>
+	  <include name="${derby.dir}/drda/NetServlet.java"/>
+    </javac>
+  </target>
+
+  <target name="checkservletjar">
+    <available property="servletjar.available" file="${servlet22}"/>
+  </target>
+
+</project>
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,247 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.reference.DB2Limit;
+
+/**
+	AppRequester stores information about the application requester.
+	It is used so that multiple sessions can share information when they are
+	started from the same version of the application requester.
+*/
+class AppRequester
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+	protected static final int MGR_LEVEL_UNKNOWN = -1;
+
+	protected static final int UNKNOWN_CLIENT = 0;
+	protected static final int JCC_CLIENT = 1;
+	protected static final int CCC_CLIENT = 2;		// not yet supported.
+
+	private static final int [] MIN_MGR_LEVELS = {
+											3, // AGENT - JCC comes in at 3
+											4, // CCSIDMGR	
+											3, // CMNAPPC, 
+											4, // CMNSYNCPT
+											5, // CMNTCPIP
+											1, // DICTIONARY
+											3, // RDB
+											4, // RSYNCMGR
+											1, // SECMGR	
+											6, // SQLAM
+											1, // SUPERVISOR	
+											5, // SYNCPTMGR
+											7  // XAMGR
+											};
+	// Application requester information
+	protected String	extnam;			// External Name - EXCSAT
+	protected String	srvnam;			// Server Name - EXCSAT
+	protected String 	srvrlslv;		// Server Product Release Level - EXCSAT
+	protected String	srvclsnm;		// Server Class Name - EXCSAT
+	protected String	spvnam;			// Supervisor Name - EXCSAT
+	protected String	prdid;			// Product specific identifier - ACCRDB protected
+	private int[]		managerLevels = new int[CodePoint.MGR_CODEPOINTS.length];
+	private int 		clientType;
+	protected int		versionLevel;
+	protected int		releaseLevel;
+	protected int		modifyLevel;
+	
+
+	// constructor 
+	/** 
+	 * AppRequester constructor
+	 * 
+	 * @exception throws IOException
+	 */
+	protected AppRequester () 
+	{
+		for (int i = 0; i < CodePoint.MGR_CODEPOINTS.length; i++)
+			managerLevels[i] = MGR_LEVEL_UNKNOWN;
+	}
+
+	/**
+	 * get the Application requester manager level
+	 *
+	 * @param manager	codepoint for manager we are looking for
+	 *
+	 * @return manager level for that manager
+	 */
+	protected int getManagerLevel(int manager)
+	{
+		int mindex = CodePoint.getManagerIndex(manager);
+		if (SanityManager.DEBUG)
+		{
+			if (mindex < 0 || mindex > managerLevels.length)
+				SanityManager.THROWASSERT("Unknown manager "+ manager + " mindex = "+
+					mindex);
+		}
+		return managerLevels[mindex];
+	}
+
+	protected void setClientVersion(String productId)
+	{
+		prdid = productId;
+
+		versionLevel = Integer.parseInt(prdid.substring (3, 5));
+		releaseLevel = Integer.parseInt(prdid.substring (5, 7));
+		modifyLevel = Integer.parseInt(prdid.substring (7, 8));
+		if (srvrlslv == null)
+			clientType = UNKNOWN_CLIENT;
+		else if (srvrlslv.indexOf("JCC") != -1)
+			clientType = JCC_CLIENT;
+		else
+			clientType = UNKNOWN_CLIENT;
+	}
+
+	/**
+	 * Check if provided JCC version level is greaterThanOrEqualTo current level
+	 *
+	 * @param vLevel	Version level
+	 * @param rLevel	Release level
+	 * @param mLevel	Modification level
+	 */
+	 
+	protected boolean greaterThanOrEqualTo(int vLevel, int rLevel, int mLevel)
+	{
+		if (versionLevel > vLevel)
+				return true;
+		else if (versionLevel == vLevel) {
+				if (releaseLevel > rLevel)
+						return true;
+				else if (releaseLevel == rLevel)
+						if (modifyLevel >= mLevel)
+								return true;
+		}
+    	return false;
+	}
+
+	/** 
+	 * set Application requester manager level
+	 * if the manager level is less than the minimum manager level,
+	 * set the manager level to zero (saying we can't handle this
+	 * level), this will be returned
+	 * to the application requester and he can decide whether or not to
+	 * proceed
+	 * For CCSIDMGR, if the target server supports the CCSID manager but
+	 * not the CCSID requested, the value returned is FFFF
+	 * For now, we won't support the CCSIDMGR since JCC doesn't request it.
+	 *
+	 * @param manager	codepoint of the manager
+	 * @param managerLevel	level for that manager
+	 *
+	 */
+	protected void setManagerLevel(int manager, int managerLevel)
+	{
+		int i = CodePoint.getManagerIndex(manager);
+		if (SanityManager.DEBUG)
+		{
+			if (i < 0 || i > managerLevels.length)
+				SanityManager.THROWASSERT("Unknown manager "+ manager + " i = " + i);
+		}
+		if (managerLevel >= MIN_MGR_LEVELS[i])
+			managerLevels[i] = managerLevel;	
+		else
+			managerLevels[i] = 0;
+	}
+	
+	/**
+	 * Check if the application requester is the same as this one
+	 *
+	 * @param a	application requester to compare to
+	 * @return true if same false otherwise
+	 */
+	protected boolean equals(AppRequester a)
+	{
+		// check prdid - this should be different if they are different
+		if (!prdid.equals(a.prdid))
+			return false;
+
+		// check server product release level
+		if (notEquals(srvrlslv, a.srvrlslv))
+			return false;
+
+		// check server names
+		if (notEquals(extnam, a.extnam))
+			return false;
+
+		if (notEquals(srvnam, a.srvnam))
+			return false;
+
+		if (notEquals(srvclsnm, a.srvclsnm))
+			return false;
+
+		if (notEquals(spvnam, a.spvnam))
+			return false;
+
+		// check manager levels
+		for (int i = 0; i < managerLevels.length; i++)
+			if (managerLevels[i] != a.managerLevels[i])
+				return false;
+
+		// O.K. looks good
+		return true;
+	}
+	/**
+	 * Check whether two objects are not equal when 1 of the objects could
+	 * be null
+	 *
+ 	 * @param a	first object
+	 * @param b second object
+	 * @return true if not equals false otherwise
+	 */
+	private boolean notEquals(Object a, Object b)
+	{
+		if (a != null && b == null)
+			return true;
+		if (a == null && b != null)
+			return true;
+		if (a != null && !a.equals(b))
+			return true;
+		return false;
+	}
+
+	/**
+	 * Get the maximum length supported for an exception's message
+	 * parameter string.
+	 */
+
+	protected int supportedMessageParamLength() {
+
+		switch (clientType) {
+
+			case JCC_CLIENT:
+				return DB2Limit.DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH;
+			default:
+			// Default is the max for C clients, since that is more
+			// restricted than for JCC clients.  Note, though, that
+			// JCC clients are the only ones supported right now.
+				return DB2Limit.DB2_CCC_MAX_EXCEPTION_PARAM_LENGTH;
+
+		}
+
+	}
+
+	/**
+	 * Get the type of the client.
+	 */
+
+	protected int getClientType() {
+
+		return clientType;
+
+	}
+
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CcsidManager.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CcsidManager.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,68 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derby.impl.drda;
+
+// Peforms character conversions.
+abstract class CcsidManager
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+  private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+  byte space; // ' ' character
+  byte dot;   // '.' character
+
+  // Byte array used to convert numbers into
+  // bytes containing the character representation "value" for the particular ccsid.
+  byte[] numToCharRepresentation;
+
+  CcsidManager (byte space, byte dot, byte[] numToCharRepresentation)
+  {
+    this.space = space;
+    this.dot = dot;
+    this.numToCharRepresentation = numToCharRepresentation;
+  }
+
+
+  // Convert a Java String into bytes for a particular ccsid.
+  //
+  // @param sourceString A Java String to convert.
+  // @return A new byte array representing the String in a particular ccsid.
+  abstract byte[] convertFromUCS2 (String sourceString);
+
+
+  // Convert a Java String into bytes for a particular ccsid.
+  // The String is converted into a buffer provided by the caller.
+  //
+  // @param sourceString  A Java String to convert.
+  // @param buffer        The buffer to convert the String into.
+  // @param offset        Offset in buffer to start putting output.
+  // @return An int containing the buffer offset after conversion.
+  abstract int convertFromUCS2 (String sourceString,
+                                byte[] buffer,
+                                int offset);
+
+  // Convert a byte array representing characters in a particular ccsid into a Java String.
+  //
+  // @param sourceBytes An array of bytes to be converted.
+  // @return String A new Java String Object created after conversion.
+  abstract String convertToUCS2 (byte[] sourceBytes);
+
+
+  // Convert a byte array representing characters in a particular ccsid into a Java String.
+  //
+  // @param sourceBytes An array of bytes to be converted.
+  // @param offset  An offset indicating first byte to convert.
+  // @param numToConvert The number of bytes to be converted.
+  // @return A new Java String Object created after conversion.
+  abstract String convertToUCS2 (byte[] sourceBytes, int offset, int numToConvert);
+
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CharacterEncodings.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CharacterEncodings.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,380 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+public final class CharacterEncodings
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+   private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+  // This is a static class, so hide the default constructor.
+  private CharacterEncodings () {}
+
+  //private static java.util.Hashtable javaEncodingToCCSIDTable__ = new java.util.Hashtable();
+  private static java.util.Hashtable ccsidToJavaEncodingTable__ = new java.util.Hashtable();
+
+  static {
+    populate_ccsidToJavaEncodingTable();
+    //populate_javaEncodingToCCSIDTable();
+  }
+
+  /*
+  static void populate_javaEncodingToCCSIDTable ()
+  {
+    javaEncodingToCCSIDTable__.put ("Cp037", new Integer (37));
+    javaEncodingToCCSIDTable__.put ("Cp273", new Integer (273));
+    javaEncodingToCCSIDTable__.put ("Cp277", new Integer (277));
+    javaEncodingToCCSIDTable__.put ("Cp278", new Integer (278));
+    javaEncodingToCCSIDTable__.put ("Cp280", new Integer (280));
+    javaEncodingToCCSIDTable__.put ("Cp284", new Integer (284));
+    javaEncodingToCCSIDTable__.put ("Cp285", new Integer (285));
+    javaEncodingToCCSIDTable__.put ("Cp297", new Integer (297));
+    javaEncodingToCCSIDTable__.put ("Cp420", new Integer (420));
+    javaEncodingToCCSIDTable__.put ("Cp424", new Integer (424));
+    javaEncodingToCCSIDTable__.put ("Cp747", new Integer (437));
+    javaEncodingToCCSIDTable__.put ("Cp500", new Integer (500));
+    javaEncodingToCCSIDTable__.put ("Cp737", new Integer (737));
+    javaEncodingToCCSIDTable__.put ("Cp775", new Integer (775));
+    javaEncodingToCCSIDTable__.put ("ISO8859_7", new Integer (813));
+    javaEncodingToCCSIDTable__.put ("ISO8859_1", new Integer (819));
+    javaEncodingToCCSIDTable__.put ("Cp838", new Integer (838));
+    javaEncodingToCCSIDTable__.put ("Cp850", new Integer (850));
+    javaEncodingToCCSIDTable__.put ("Cp852", new Integer (852));
+    javaEncodingToCCSIDTable__.put ("Cp855", new Integer (855));
+    javaEncodingToCCSIDTable__.put ("Cp856", new Integer (856));
+    javaEncodingToCCSIDTable__.put ("Cp857", new Integer (857));
+    javaEncodingToCCSIDTable__.put ("Cp858", new Integer (858));
+    javaEncodingToCCSIDTable__.put ("Cp860", new Integer (860));
+    javaEncodingToCCSIDTable__.put ("Cp861", new Integer (861));
+    javaEncodingToCCSIDTable__.put ("Cp862", new Integer (862));
+    javaEncodingToCCSIDTable__.put ("Cp863", new Integer (863));
+    javaEncodingToCCSIDTable__.put ("Cp864", new Integer (864));
+    javaEncodingToCCSIDTable__.put ("Cp865", new Integer (865));
+    javaEncodingToCCSIDTable__.put ("Cp866", new Integer (866));
+    javaEncodingToCCSIDTable__.put ("Cp868", new Integer (868));
+    javaEncodingToCCSIDTable__.put ("Cp869", new Integer (869));
+    javaEncodingToCCSIDTable__.put ("Cp870", new Integer (870));
+    javaEncodingToCCSIDTable__.put ("Cp871", new Integer (871));
+    javaEncodingToCCSIDTable__.put ("Cp874", new Integer (874));
+    javaEncodingToCCSIDTable__.put ("Cp875", new Integer (875));
+    javaEncodingToCCSIDTable__.put ("KOI8_R", new Integer (878));
+    javaEncodingToCCSIDTable__.put ("ISO8859_2", new Integer (912));
+    javaEncodingToCCSIDTable__.put ("ISO8859_3", new Integer (913));
+    javaEncodingToCCSIDTable__.put ("ISO8859_4", new Integer (914));
+    javaEncodingToCCSIDTable__.put ("ISO8859_5", new Integer (915));
+    javaEncodingToCCSIDTable__.put ("ISO8859_8", new Integer (916));
+    javaEncodingToCCSIDTable__.put ("Cp918", new Integer (918));
+    javaEncodingToCCSIDTable__.put ("ISO8859_9", new Integer (920));
+    javaEncodingToCCSIDTable__.put ("ISO8859_15_FDIS", new Integer (923));
+    javaEncodingToCCSIDTable__.put ("Cp921", new Integer (921));
+    javaEncodingToCCSIDTable__.put ("Cp922", new Integer (922));
+    javaEncodingToCCSIDTable__.put ("Cp930", new Integer (930));
+    javaEncodingToCCSIDTable__.put ("Cp933", new Integer (933));
+    javaEncodingToCCSIDTable__.put ("Cp935", new Integer (935));
+    javaEncodingToCCSIDTable__.put ("Cp937", new Integer (937));
+    javaEncodingToCCSIDTable__.put ("Cp939", new Integer (939));
+    javaEncodingToCCSIDTable__.put ("Cp948", new Integer (948));
+    javaEncodingToCCSIDTable__.put ("Cp950", new Integer (950));
+    javaEncodingToCCSIDTable__.put ("Cp964", new Integer (964));
+    javaEncodingToCCSIDTable__.put ("Cp970", new Integer (970));
+    javaEncodingToCCSIDTable__.put ("Cp1006", new Integer (1006));
+    javaEncodingToCCSIDTable__.put ("Cp1025", new Integer (1025));
+    javaEncodingToCCSIDTable__.put ("Cp1026", new Integer (1026));
+    javaEncodingToCCSIDTable__.put ("Cp1046", new Integer (1046));
+    javaEncodingToCCSIDTable__.put ("ISO8859_6", new Integer (1089));
+    javaEncodingToCCSIDTable__.put ("Cp1097", new Integer (1097));
+    javaEncodingToCCSIDTable__.put ("Cp1098", new Integer (1098));
+    javaEncodingToCCSIDTable__.put ("Cp1112", new Integer (1112));
+    javaEncodingToCCSIDTable__.put ("Cp1122", new Integer (1122));
+    javaEncodingToCCSIDTable__.put ("Cp1123", new Integer (1123));
+    javaEncodingToCCSIDTable__.put ("Cp1124", new Integer (1124));
+    javaEncodingToCCSIDTable__.put ("Cp1140", new Integer (1140));
+    javaEncodingToCCSIDTable__.put ("Cp1141", new Integer (1141));
+    javaEncodingToCCSIDTable__.put ("Cp1142", new Integer (1142));
+    javaEncodingToCCSIDTable__.put ("Cp1143", new Integer (1143));
+    javaEncodingToCCSIDTable__.put ("Cp1144", new Integer (1144));
+    javaEncodingToCCSIDTable__.put ("Cp1145", new Integer (1145));
+    javaEncodingToCCSIDTable__.put ("Cp1146", new Integer (1146));
+    javaEncodingToCCSIDTable__.put ("Cp1147", new Integer (1147));
+    javaEncodingToCCSIDTable__.put ("Cp1148", new Integer (1148));
+    javaEncodingToCCSIDTable__.put ("Cp1149", new Integer (1149));
+    javaEncodingToCCSIDTable__.put ("UTF8", new Integer (1208));
+    javaEncodingToCCSIDTable__.put ("Cp1250", new Integer (1250));
+    javaEncodingToCCSIDTable__.put ("Cp1251", new Integer (1251));
+    javaEncodingToCCSIDTable__.put ("Cp1252", new Integer (1252));
+    javaEncodingToCCSIDTable__.put ("Cp1253", new Integer (1253));
+    javaEncodingToCCSIDTable__.put ("Cp1254", new Integer (1254));
+    javaEncodingToCCSIDTable__.put ("Cp1255", new Integer (1255));
+    javaEncodingToCCSIDTable__.put ("Cp1256", new Integer (1256));
+    javaEncodingToCCSIDTable__.put ("Cp1257", new Integer (1257));
+    javaEncodingToCCSIDTable__.put ("Cp1258", new Integer (1258));
+    javaEncodingToCCSIDTable__.put ("MacGreek", new Integer (1280));
+    javaEncodingToCCSIDTable__.put ("MacTurkish", new Integer (1281));
+    javaEncodingToCCSIDTable__.put ("MacCyrillic", new Integer (1283));
+    javaEncodingToCCSIDTable__.put ("MacCroatian", new Integer (1284));
+    javaEncodingToCCSIDTable__.put ("MacRomania", new Integer (1285));
+    javaEncodingToCCSIDTable__.put ("MacIceland", new Integer (1286));
+    javaEncodingToCCSIDTable__.put ("Cp1381", new Integer (1381));
+    javaEncodingToCCSIDTable__.put ("Cp1383", new Integer (1383));
+    javaEncodingToCCSIDTable__.put ("Cp33722", new Integer (33722));
+
+    javaEncodingToCCSIDTable__.put ("Cp290", new Integer (8482));
+    javaEncodingToCCSIDTable__.put ("Cp300", new Integer (16684));
+    javaEncodingToCCSIDTable__.put ("Cp930", new Integer (1390));
+    javaEncodingToCCSIDTable__.put ("Cp833", new Integer (13121));
+    javaEncodingToCCSIDTable__.put ("Cp834", new Integer (4930));
+    javaEncodingToCCSIDTable__.put ("Cp836", new Integer (13124));
+    javaEncodingToCCSIDTable__.put ("Cp837", new Integer (4933));
+    javaEncodingToCCSIDTable__.put ("Cp943", new Integer (941));
+    javaEncodingToCCSIDTable__.put ("Cp1027", new Integer (5123));
+    javaEncodingToCCSIDTable__.put ("Cp1043", new Integer (904));
+    javaEncodingToCCSIDTable__.put ("Cp1114", new Integer (5210));
+    javaEncodingToCCSIDTable__.put ("ASCII", new Integer (367));
+    javaEncodingToCCSIDTable__.put ("MS932", new Integer (932));
+    javaEncodingToCCSIDTable__.put ("UnicodeBigUnmarked", new Integer (1200));
+    javaEncodingToCCSIDTable__.put ("Cp943", new Integer (943));
+    javaEncodingToCCSIDTable__.put ("Cp1362", new Integer (1114));
+    javaEncodingToCCSIDTable__.put ("Cp301", new Integer (301));
+    javaEncodingToCCSIDTable__.put ("Cp1041", new Integer (1041));
+    javaEncodingToCCSIDTable__.put ("Cp1351", new Integer (1351));
+    javaEncodingToCCSIDTable__.put ("Cp1088", new Integer (1088));
+    javaEncodingToCCSIDTable__.put ("Cp951", new Integer (951));
+    javaEncodingToCCSIDTable__.put ("Cp971", new Integer (971));
+    javaEncodingToCCSIDTable__.put ("Cp1362", new Integer (1362));
+    javaEncodingToCCSIDTable__.put ("Cp1363", new Integer (1363));
+    javaEncodingToCCSIDTable__.put ("Cp1115", new Integer (1115));
+    javaEncodingToCCSIDTable__.put ("Cp1380", new Integer (1380));
+    javaEncodingToCCSIDTable__.put ("Cp1385", new Integer (1385));
+    javaEncodingToCCSIDTable__.put ("Cp947", new Integer (947));
+    javaEncodingToCCSIDTable__.put ("Cp942", new Integer (942));
+    javaEncodingToCCSIDTable__.put ("Cp897", new Integer (897));
+    javaEncodingToCCSIDTable__.put ("Cp949", new Integer (949));
+    javaEncodingToCCSIDTable__.put ("Cp1370", new Integer (1370));
+    javaEncodingToCCSIDTable__.put ("Cp927", new Integer (927));
+    javaEncodingToCCSIDTable__.put ("Cp1382", new Integer (1382));
+    javaEncodingToCCSIDTable__.put ("Cp1386", new Integer (1386));
+    javaEncodingToCCSIDTable__.put ("Cp835", new Integer (835));
+    javaEncodingToCCSIDTable__.put ("Cp1051", new Integer (1051));
+  }
+  */
+
+  static void populate_ccsidToJavaEncodingTable ()
+  {
+    ccsidToJavaEncodingTable__.put (new Integer (5346), "Cp1250");
+    ccsidToJavaEncodingTable__.put (new Integer (5347), "Cp1251");
+    ccsidToJavaEncodingTable__.put (new Integer (5348), "Cp1252");
+    ccsidToJavaEncodingTable__.put (new Integer (5349), "Cp1253");
+    ccsidToJavaEncodingTable__.put (new Integer (5350), "Cp1254");
+    ccsidToJavaEncodingTable__.put (new Integer (5351), "Cp1255");
+    ccsidToJavaEncodingTable__.put (new Integer (4909), "Cp813");
+    ccsidToJavaEncodingTable__.put (new Integer (858), "Cp850"); //we can't map 858 to Cp850 because 858 has Euro characters that Cp858 doesn't support
+    ccsidToJavaEncodingTable__.put (new Integer (872), "Cp855");
+    ccsidToJavaEncodingTable__.put (new Integer (867), "Cp862");
+    ccsidToJavaEncodingTable__.put (new Integer (17248), "Cp864");
+    ccsidToJavaEncodingTable__.put (new Integer (808), "Cp866");
+    ccsidToJavaEncodingTable__.put (new Integer (1162), "Cp847");
+    ccsidToJavaEncodingTable__.put (new Integer (9044), "Cp852");
+    ccsidToJavaEncodingTable__.put (new Integer (9048), "Cp856");
+    ccsidToJavaEncodingTable__.put (new Integer (9049), "Cp857");
+    ccsidToJavaEncodingTable__.put (new Integer (9061), "Cp869");
+    ccsidToJavaEncodingTable__.put (new Integer (901), "Cp921");
+    ccsidToJavaEncodingTable__.put (new Integer (902), "Cp922");
+    ccsidToJavaEncodingTable__.put (new Integer (21427), "Cp947");
+    ccsidToJavaEncodingTable__.put (new Integer (1370), "Cp950"); //we can't map 1370 to Cp1370 becasue 1370 has Euro character that Cp1370 doesn't support
+    ccsidToJavaEncodingTable__.put (new Integer (5104), "Cp1008");
+    ccsidToJavaEncodingTable__.put (new Integer (9238), "Cp1046");
+    ccsidToJavaEncodingTable__.put (new Integer (848), "Cp1125");
+    ccsidToJavaEncodingTable__.put (new Integer (1163), "Cp1129");
+    ccsidToJavaEncodingTable__.put (new Integer (849), "Cp1131");
+    ccsidToJavaEncodingTable__.put (new Integer (5352), "Cp1256");
+    ccsidToJavaEncodingTable__.put (new Integer (5353), "Cp1257");
+    ccsidToJavaEncodingTable__.put (new Integer (5354), "Cp1258");
+
+    ccsidToJavaEncodingTable__.put (new Integer (37), "Cp037");
+    ccsidToJavaEncodingTable__.put (new Integer (273), "Cp273");
+    ccsidToJavaEncodingTable__.put (new Integer (277), "Cp277");
+    ccsidToJavaEncodingTable__.put (new Integer (278), "Cp278");
+    ccsidToJavaEncodingTable__.put (new Integer (280), "Cp280");
+    ccsidToJavaEncodingTable__.put (new Integer (284), "Cp284");
+    ccsidToJavaEncodingTable__.put (new Integer (285), "Cp285");
+    ccsidToJavaEncodingTable__.put (new Integer (297), "Cp297");
+    ccsidToJavaEncodingTable__.put (new Integer (420), "Cp420");
+    ccsidToJavaEncodingTable__.put (new Integer (424), "Cp424");
+    ccsidToJavaEncodingTable__.put (new Integer (437), "Cp437");
+    ccsidToJavaEncodingTable__.put (new Integer (500), "Cp500");
+    ccsidToJavaEncodingTable__.put (new Integer (737), "Cp737");
+    ccsidToJavaEncodingTable__.put (new Integer (775), "Cp775");
+    ccsidToJavaEncodingTable__.put (new Integer (838), "Cp838");
+    ccsidToJavaEncodingTable__.put (new Integer (850), "Cp850");
+    ccsidToJavaEncodingTable__.put (new Integer (852), "Cp852");
+    ccsidToJavaEncodingTable__.put (new Integer (855), "Cp855");
+    ccsidToJavaEncodingTable__.put (new Integer (856), "Cp856");
+    ccsidToJavaEncodingTable__.put (new Integer (857), "Cp857");
+    //ccsidToJavaEncodingTable__.put (new Integer (858), "Cp858");
+    ccsidToJavaEncodingTable__.put (new Integer (860), "Cp860");
+    ccsidToJavaEncodingTable__.put (new Integer (861), "Cp861");
+    ccsidToJavaEncodingTable__.put (new Integer (862), "Cp862");
+    ccsidToJavaEncodingTable__.put (new Integer (863), "Cp863");
+    ccsidToJavaEncodingTable__.put (new Integer (864), "Cp864");
+    ccsidToJavaEncodingTable__.put (new Integer (865), "Cp865");
+    ccsidToJavaEncodingTable__.put (new Integer (866), "Cp866");
+    ccsidToJavaEncodingTable__.put (new Integer (868), "Cp868");
+    ccsidToJavaEncodingTable__.put (new Integer (869), "Cp869");
+    ccsidToJavaEncodingTable__.put (new Integer (870), "Cp870");
+    ccsidToJavaEncodingTable__.put (new Integer (871), "Cp871");
+    ccsidToJavaEncodingTable__.put (new Integer (874), "Cp874");
+    ccsidToJavaEncodingTable__.put (new Integer (875), "Cp875");
+    ccsidToJavaEncodingTable__.put (new Integer (918), "Cp918");
+    ccsidToJavaEncodingTable__.put (new Integer (921), "Cp921");
+    ccsidToJavaEncodingTable__.put (new Integer (922), "Cp922");
+    ccsidToJavaEncodingTable__.put (new Integer (930), "Cp930");
+    ccsidToJavaEncodingTable__.put (new Integer (933), "Cp933");
+    ccsidToJavaEncodingTable__.put (new Integer (935), "Cp935");
+    ccsidToJavaEncodingTable__.put (new Integer (937), "Cp937");
+    ccsidToJavaEncodingTable__.put (new Integer (939), "Cp939");
+    ccsidToJavaEncodingTable__.put (new Integer (948), "Cp948");
+    ccsidToJavaEncodingTable__.put (new Integer (950), "Cp950");
+    ccsidToJavaEncodingTable__.put (new Integer (964), "Cp964");
+    ccsidToJavaEncodingTable__.put (new Integer (970), "Cp970");
+    ccsidToJavaEncodingTable__.put (new Integer (1006), "Cp1006");
+    ccsidToJavaEncodingTable__.put (new Integer (1025), "Cp1025");
+    ccsidToJavaEncodingTable__.put (new Integer (1026), "Cp1026");
+    ccsidToJavaEncodingTable__.put (new Integer (1046), "Cp1046");
+    ccsidToJavaEncodingTable__.put (new Integer (1097), "Cp1097");
+    ccsidToJavaEncodingTable__.put (new Integer (1098), "Cp1098");
+    ccsidToJavaEncodingTable__.put (new Integer (1112), "Cp1112");
+    ccsidToJavaEncodingTable__.put (new Integer (1122), "Cp1122");
+    ccsidToJavaEncodingTable__.put (new Integer (1123), "Cp1123");
+    ccsidToJavaEncodingTable__.put (new Integer (1124), "Cp1124");
+    ccsidToJavaEncodingTable__.put (new Integer (1140), "Cp1140");
+    ccsidToJavaEncodingTable__.put (new Integer (1141), "Cp1141");
+    ccsidToJavaEncodingTable__.put (new Integer (1142), "Cp1142");
+    ccsidToJavaEncodingTable__.put (new Integer (1143), "Cp1143");
+    ccsidToJavaEncodingTable__.put (new Integer (1144), "Cp1144");
+    ccsidToJavaEncodingTable__.put (new Integer (1145), "Cp1145");
+    ccsidToJavaEncodingTable__.put (new Integer (1146), "Cp1146");
+    ccsidToJavaEncodingTable__.put (new Integer (1147), "Cp1147");
+    ccsidToJavaEncodingTable__.put (new Integer (1148), "Cp1148");
+    ccsidToJavaEncodingTable__.put (new Integer (1149), "Cp1149");
+    ccsidToJavaEncodingTable__.put (new Integer (1250), "Cp1250");
+    ccsidToJavaEncodingTable__.put (new Integer (1251), "Cp1251");
+    ccsidToJavaEncodingTable__.put (new Integer (1252), "Cp1252");
+    ccsidToJavaEncodingTable__.put (new Integer (1253), "Cp1253");
+    ccsidToJavaEncodingTable__.put (new Integer (1254), "Cp1254");
+    ccsidToJavaEncodingTable__.put (new Integer (1255), "Cp1255");
+    ccsidToJavaEncodingTable__.put (new Integer (1256), "Cp1256");
+    ccsidToJavaEncodingTable__.put (new Integer (1257), "Cp1257");
+    ccsidToJavaEncodingTable__.put (new Integer (1258), "Cp1258");
+    ccsidToJavaEncodingTable__.put (new Integer (1381), "Cp1381");
+    ccsidToJavaEncodingTable__.put (new Integer (1383), "Cp1383");
+    ccsidToJavaEncodingTable__.put (new Integer (33722), "Cp33722");
+    ccsidToJavaEncodingTable__.put (new Integer (943), "Cp943");
+    ccsidToJavaEncodingTable__.put (new Integer (1043), "Cp1043");
+
+    ccsidToJavaEncodingTable__.put (new Integer (813), "ISO8859_7");
+    ccsidToJavaEncodingTable__.put (new Integer (819), "ISO8859_1");
+    ccsidToJavaEncodingTable__.put (new Integer (878), "KOI8_R");
+    ccsidToJavaEncodingTable__.put (new Integer (912), "ISO8859_2");
+    ccsidToJavaEncodingTable__.put (new Integer (913), "ISO8859_3");
+    ccsidToJavaEncodingTable__.put (new Integer (914), "ISO8859_4");
+    ccsidToJavaEncodingTable__.put (new Integer (915), "ISO8859_5");
+    ccsidToJavaEncodingTable__.put (new Integer (916), "ISO8859_8");
+    ccsidToJavaEncodingTable__.put (new Integer (920), "ISO8859_9");
+    ccsidToJavaEncodingTable__.put (new Integer (923), "ISO8859_15_FDIS");
+    ccsidToJavaEncodingTable__.put (new Integer (1089), "ISO8859_6");
+    ccsidToJavaEncodingTable__.put (new Integer (1208), "UTF8");
+    ccsidToJavaEncodingTable__.put (new Integer (1280), "MacGreek");
+    ccsidToJavaEncodingTable__.put (new Integer (1281), "MacTurkish");
+    ccsidToJavaEncodingTable__.put (new Integer (1283), "MacCyrillic");
+    ccsidToJavaEncodingTable__.put (new Integer (1284), "MacCroatian");
+    ccsidToJavaEncodingTable__.put (new Integer (1285), "MacRomania");
+    ccsidToJavaEncodingTable__.put (new Integer (1286), "MacIceland");
+    ccsidToJavaEncodingTable__.put (new Integer (8482), "Cp290");
+    ccsidToJavaEncodingTable__.put (new Integer (16684), "Cp300");
+    ccsidToJavaEncodingTable__.put (new Integer (1390), "Cp930");
+    ccsidToJavaEncodingTable__.put (new Integer (13121), "Cp833");
+    ccsidToJavaEncodingTable__.put (new Integer (4930), "Cp834");
+    ccsidToJavaEncodingTable__.put (new Integer (13124), "Cp836");
+    ccsidToJavaEncodingTable__.put (new Integer (4933), "Cp837");
+    ccsidToJavaEncodingTable__.put (new Integer (941), "Cp943");
+    ccsidToJavaEncodingTable__.put (new Integer (5123), "Cp1027");
+    ccsidToJavaEncodingTable__.put (new Integer (904), "Cp1043");
+    ccsidToJavaEncodingTable__.put (new Integer (5210), "Cp1114");
+    ccsidToJavaEncodingTable__.put (new Integer (367), "ASCII");
+    ccsidToJavaEncodingTable__.put (new Integer (932), "MS932");
+    ccsidToJavaEncodingTable__.put (new Integer (1200), "UnicodeBigUnmarked");
+    ccsidToJavaEncodingTable__.put (new Integer (5026), "Cp930");
+    ccsidToJavaEncodingTable__.put (new Integer (1399), "Cp939");
+    ccsidToJavaEncodingTable__.put (new Integer (4396), "Cp300");
+    ccsidToJavaEncodingTable__.put (new Integer (1388), "Cp935");
+    ccsidToJavaEncodingTable__.put (new Integer (1364), "Cp933");
+    ccsidToJavaEncodingTable__.put (new Integer (5035), "Cp939");
+    ccsidToJavaEncodingTable__.put (new Integer (28709), "Cp37");
+    ccsidToJavaEncodingTable__.put (new Integer (1114), "Cp1362");
+    ccsidToJavaEncodingTable__.put (new Integer (954), "Cp33722");
+
+    //----the following codepages may  only be supported by IBMSDk 1.3.1
+    ccsidToJavaEncodingTable__.put (new Integer (301), "Cp301");
+    ccsidToJavaEncodingTable__.put (new Integer (1041), "Cp1041");
+    ccsidToJavaEncodingTable__.put (new Integer (1351), "Cp1351");
+    ccsidToJavaEncodingTable__.put (new Integer (1088), "Cp1088");
+    ccsidToJavaEncodingTable__.put (new Integer (951), "Cp951");
+    ccsidToJavaEncodingTable__.put (new Integer (971), "Cp971");
+    ccsidToJavaEncodingTable__.put (new Integer (1362), "Cp1362");
+    ccsidToJavaEncodingTable__.put (new Integer (1363), "Cp1363");
+    ccsidToJavaEncodingTable__.put (new Integer (1115), "Cp1115");
+    ccsidToJavaEncodingTable__.put (new Integer (1380), "Cp1380");
+    ccsidToJavaEncodingTable__.put (new Integer (1386), "Cp1386");
+    ccsidToJavaEncodingTable__.put (new Integer (1385), "Cp1385");
+    ccsidToJavaEncodingTable__.put (new Integer (947), "Cp947");
+    ccsidToJavaEncodingTable__.put (new Integer (942), "Cp942");
+    ccsidToJavaEncodingTable__.put (new Integer (897), "Cp897");
+    ccsidToJavaEncodingTable__.put (new Integer (949), "Cp949");
+    ccsidToJavaEncodingTable__.put (new Integer (927), "Cp927");
+    ccsidToJavaEncodingTable__.put (new Integer (1382), "Cp1382");
+    ccsidToJavaEncodingTable__.put (new Integer (290), "Cp290");
+    ccsidToJavaEncodingTable__.put (new Integer (300), "Cp300");
+    ccsidToJavaEncodingTable__.put (new Integer (1027), "Cp1027");
+    ccsidToJavaEncodingTable__.put (new Integer (16686), "Cp16686");
+    ccsidToJavaEncodingTable__.put (new Integer (833), "Cp833");
+    ccsidToJavaEncodingTable__.put (new Integer (834), "Cp834");
+    ccsidToJavaEncodingTable__.put (new Integer (836), "Cp836");
+    ccsidToJavaEncodingTable__.put (new Integer (837), "Cp837");
+    ccsidToJavaEncodingTable__.put (new Integer (835), "Cp835");
+    ccsidToJavaEncodingTable__.put (new Integer (895), "Cp33722");
+    ccsidToJavaEncodingTable__.put (new Integer (1051), "Cp1051");
+    ccsidToJavaEncodingTable__.put (new Integer (13488), "UnicodeBigUnmarked");
+
+  }
+
+  /*
+  public static int getCCSID (String javaEncoding) throws java.io.UnsupportedEncodingException
+  {
+    int ccsid = ((Integer) javaEncodingToCCSIDTable__.get (javaEncoding)).intValue();
+    if (ccsid == 0)
+      throw new java.io.UnsupportedEncodingException ("unsupported java encoding");
+    else
+      return ccsid;
+  }
+  */
+
+  public static String getJavaEncoding (int ccsid) throws java.io.UnsupportedEncodingException
+  {
+    String javaEncoding = (String) ccsidToJavaEncodingTable__.get (new Integer (ccsid));
+    if (javaEncoding == null)
+      throw new java.io.UnsupportedEncodingException ("unsupported ccsid");
+    else
+      return javaEncoding;
+  }
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/ClientThread.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,117 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.io.*;
+import java.net.*;
+import java.security.*;
+
+class ClientThread extends Thread {
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+ private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+	DB2jServerImpl parent;
+	ServerSocket serverSocket;
+	private int timeSlice;
+	private int connNum;
+	private String traceDir;
+	private boolean traceAll;
+
+		protected ClientThread (DB2jServerImpl dsi, ServerSocket ss) {
+
+			// Create a more meaningful name for this thread (but preserve its
+			// thread id from the default name).
+			DB2jServerImpl.setUniqueThreadName(this, "NetworkServerThread");
+
+			parent=dsi;
+			serverSocket=ss;
+			timeSlice=dsi.getTimeSlice();
+			traceDir=parent.getTraceDirectory();
+			traceAll=parent.getTraceAll();
+		}
+			
+		public void run() 
+		{
+
+			Socket clientSocket = null;
+			Session clientSession = null;
+
+
+			for (;;)
+			{
+				try {
+	          		try{
+	             			clientSocket = (Socket) AccessController.doPrivileged(
+						new PrivilegedExceptionAction() {
+							public Object run() throws IOException
+							{
+								return serverSocket.accept();
+							}
+						}
+					);
+					//set time out
+					
+					if (timeSlice != 0)
+						clientSocket.setSoTimeout(timeSlice);
+				} catch (PrivilegedActionException e) {
+					Exception e1 = e.getException();
+	            			if (e1 instanceof IOException){
+						synchronized(parent.getShutdownSync()) {
+							if (!parent.getShutdown())
+	                					parent.consolePropertyMessage("DRDA_UnableToAccept.S");
+							}
+					} else throw e1;
+	                		break;
+				} // end priv try/catch block
+				
+				connNum = parent.getNewConnNum();
+	                	parent.consolePropertyMessage("DRDA_ConnNumber.I", 
+							Integer.toString(connNum));
+
+				//create a new Session for this session
+				clientSession = new Session(connNum, clientSocket, 
+					traceDir, traceAll);
+
+				//add to Session list
+				parent.addToSessionTable(new Integer(connNum), clientSession);
+
+				//create a new thread for this connection if we need one
+				//and if we are allowed
+				if (parent.getFreeThreads() == 0 && 
+					(parent.getMaxThreads() == 0  || 
+					parent.getThreadList().size() < parent.getMaxThreads()))
+				{
+					DRDAConnThread thread = new DRDAConnThread(clientSession, 
+						parent, timeSlice, parent.getLogConnections());
+					parent.getThreadList().addElement(thread);
+					thread.start();
+				}
+				else //wait for a free thread
+					parent.runQueueAdd(clientSession);
+				}catch (Exception e) {
+					if (e instanceof InterruptedException)
+						return;
+					parent.consoleExceptionPrintTrace(e);
+				} // end outer try/catch block
+			} // end for(;;)
+
+		}// end run()
+}
+
+
+
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,798 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derby.impl.drda;
+
+// TBD:
+//	 organize into separate kinds of code points; impose organizational scheme.
+// TBD:
+//	 reconsider the various SECCHKCD_xx constants, perhaps we should hardwire.
+
+class CodePoint
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+	// --------------------code points for constant ddm data----------------------
+
+	// Indicates false state.  This 1-byte code point is used by some DDM parameters.
+	static final byte FALSE = -16;  // was 0xf0
+
+	// Indicates true state.  This 1-byte code point is used by some DDM parameters.
+	static final byte TRUE = -15;  // was 0xf1
+
+	// Zero indicator constant.
+	// Indicates data does flow.
+	static final int ZEROIND = 0x00;
+
+	static final int NULLDATA = 0xFF;
+
+	// Security check was successful.
+	static final int SECCHKCD_00 = 0x00;
+
+	// SECMEC value not supported.
+	static final int SECCHKCD_01 = 0x01;
+
+	// DCE informational status
+	static final int SECCHKCD_02 = 0x02;
+
+	// DCE retryable error.
+	static final int SECCHKCD_03 = 0x03;
+
+	// DCE non-retryable error.
+	static final int SECCHKCD_04 = 0x04;
+
+	// GSSAPI informaional status.
+	static final int SECCHKCD_05 = 0x05;
+
+	// GSSAPI retryable error.
+	static final int SECCHKCD_06 = 0x06;
+
+	// GSSAPI non-retryable error.
+	static final int SECCHKCD_07 = 0x07;
+
+	// Local security service info.
+	static final int SECCHKCD_08 = 0x08;
+
+	// Local security service retryable error.
+	static final int SECCHKCD_09 = 0x09;
+
+	// Local security service non-retryable error.
+	static final int SECCHKCD_0A = 0x0A;
+
+	// SECTKN missing or invalid.
+	static final int SECCHKCD_0B = 0x0B;
+
+	// Password expired.
+	static final int SECCHKCD_0E = 0x0E;
+
+	// Password invalid.
+	static final int SECCHKCD_0F = 0x0F;
+
+	// Password missing.
+	static final int SECCHKCD_10 = 0x10;
+
+	// Userid missing.
+	static final int SECCHKCD_12 = 0x12;
+
+	// Userid invalid.
+	static final int SECCHKCD_13 = 0x13;
+
+	// Userid revoked.
+	static final int SECCHKCD_14 = 0x14;
+
+	// New password invalid.
+	static final int SECCHKCD_15 = 0x15;
+
+	// ----------------------ddm code points--------------------------------------
+
+	final static int EXCSAT = 0x1041;
+	final static int SYNCCTL = 0x1055;
+	final static int SYNCRSY = 0x1069;
+	final static int ACCSEC = 0x106D;
+	final static int SECCHK = 0x106E;
+	final static int SYNCLOG = 0x106F;
+	final static int ACCRDB = 0x2001;
+	final static int BGNBND = 0x2002;
+	final static int BNDSQLSTT = 0x2004;
+	final static int CLSQRY = 0x2005;
+	final static int CNTQRY = 0x2006;
+	final static int DRPPKG = 0x2007;
+	final static int DSCSQLSTT = 0x2008;
+	final static int ENDBND = 0x2009;
+	final static int EXCSQLIMM = 0x200A;
+	final static int EXCSQLSTT = 0x200B;
+	final static int EXCSQLSET = 0x2014;
+	final static int OPNQRY = 0x200C;
+	final static int PRPSQLSTT = 0x200D;
+	final static int RDBCMM = 0x200E;
+	final static int RDBRLLBCK = 0x200F;
+	final static int REBIND = 0x2010;
+	final static int DSCRDBTBL = 0x2012;
+
+	final static int SQLDTA = 0x2412;
+	final static int SQLDTARD = 0x2413;
+	final static int SQLSTT = 0x2414;
+	final static int SQLATTR = 0x2450;
+	final static int SQLSTTVRB = 0x2419;
+	final static int QRYDSC = 0x241A;
+	final static int QRYDTA = 0x241B;
+	final static int SQLRSLRD = 0x240E;
+	final static int SQLCINRD = 0x240B;
+
+	// Access Security Reply Data.
+	// Contains the security information from a target server's
+	// security manager.  This information is returned in response
+	// to an ACCSEC command.
+	static final int ACCSECRD = 0x14AC;
+
+	// Agent codepoint constant.
+	static final int AGENT = 0x1403;
+
+	// The codepoint for codepoint
+	static final int CODPNT = 0x000C;
+
+	// The Codepoint for data representation of dictionary codepoint
+	static final int CODPNTDR = 0x0064;
+
+	// Subtypes for CODPNTR
+	static final int CSTMBCS = 0x2435;  // Multibyte default
+
+	// CCSID for Double-Byte Characters codepoint constant.
+	static final int CCSIDDBC = 0x119D;
+
+	// CCSID for Mixed-Byte Characters codepoint constant.
+	static final int CCSIDMBC = 0x119E;
+
+	// CCSID Manager.  Min. level 4.
+	// Provides character data conversion of the DDM parameters
+	// containing character data.
+	static final int CCSIDMGR = 0x14CC;
+
+	// CCSID for Single-Byte Characters codepoint constant.
+	static final int CCSIDSBC = 0x119C;
+
+	// LU 6.2 Conversational Communications Manager.
+	// Describes the communications manager that supports
+	// conversational protocols by using System Network
+	// Architecture Logical Unit 6.2 (SNA LU 6.2) local
+	// communications facilities.
+	static final int CMNAPPC = 0x1444;
+
+	// SNA LU 6.2 Sync Point Conversational Communications
+	// Manager.  Min. level 4.
+	// Provides an SNA LU 6.2 Conversational Communications
+	// Manager with sync point support.
+	static final int CMNSYNCPT = 0x147C;
+
+	// TCP/IP Communication Manager codepoint constant.  Min. level 5.
+	static final int CMNTCPIP = 0x1474;
+
+	// XA Manager codepoint constant
+	static final int XAMGR = 0x1C01;
+
+	// Correlation Token codepoint constant.
+	static final int CRRTKN = 0x2135;
+
+	// Target Default Value Return
+	static final int TRGDFTRT = 0x213B;
+
+	// It is a manager of a set of named descriptions of object.
+	static final int DICTIONARY = 0x1458;
+
+	// Manager dependency error code
+	static final int DEPERRCD = 0x119B;
+
+	// Description Error code
+	static final int DSCERRCD = 0x2101;
+
+	// Server Attributes Reply Data codepoint constant.
+	static final int EXCSATRD = 0x1443;
+
+	// External Name codepoint constant.
+	static final int EXTNAM = 0x115E;
+
+	// Fixed Row Query Protocol.
+	static final int FIXROWPRC = 0x2418;
+
+	// Force Fixed Row Query Protocol.
+	static final int FRCFIXROW = 0x2410;
+
+	// Limited Block Query Protocol.
+	static final int LMTBLKPRC = 0x2417;
+
+	// Manager Level List codepoint constant.
+	static final int MGRLVLLS = 0x1404;
+
+	// Manager Level Number Attribute constants.
+	// Specifies the level of a defined DDM manager.
+	static final int MGRLVLN = 0x1473;
+
+	// Monitor Events
+	static final int MONITOR = 0x1900;
+
+	// Monitor Reply Data
+	static final int MONITORRD = 0x1C00;
+
+	// New Password
+	static final int NEWPASSWORD = 0x11DE;
+
+	// Password
+	static final int PASSWORD = 0x11A1;
+
+	// Package Default Character Subtype codepoint constant.
+	static final int PKGDFTCST = 0x2125;
+
+	// Package Id
+	static final int PKGID = 0x2109;
+
+	// Maximum Number of extra Blocks
+	static final int MAXBLKEXT = 0x2141;
+
+	// Maximum result set count
+	static final int MAXRSLCNT = 0x2140;
+
+	// Result Set Flags
+	static final int RSLSETFLG = 0x2142;
+
+	// RDB Commit allowed
+	static final int RDBCMTOK = 0x2105;
+
+	// Package name & consistency token
+	static final int PKGNAMCT = 0x2112;
+
+	// list of PAKNAMCSN
+	static final int PKGSNLST = 0x2139;
+
+	// Conversational Protocol Error Code
+	static final int PRCCNVCD = 0x113F;
+
+	// Product Specific Identifier codepoint constant.
+	static final int PRDID = 0x112E;
+
+	// Output override
+	static final int OUTOVR = 0x2415;
+
+  	//Output override option
+	static final int OUTOVROPT = 0x2147;
+
+  	// Package Consistency Token
+	static final int PKGCNSTKN = 0x210D;
+
+	// Product Specific Data
+	static final int PRDDTA = 0x2104;
+
+	// Query Instance Identifier
+	static final int QRYINSID = 0x215B;
+
+	// Query Block Protocol Control
+	static final int QRYBLKCTL = 0x2132;
+
+	// Query Block Size
+	static final int QRYBLKSZ = 0x2114;
+
+	// Query Protocol Type
+	static final int QRYPRCTYP = 0x2102;
+
+	// Query Close Implicit
+	static final int QRYCLSIMP = 0x215D;
+
+	// Query Close Lock Release
+	static final int QRYCLSRLS = 0x215E;
+
+	// QRYOPTVAL - Query Optimization Value
+	static final int QRYOPTVAL = 0x215F;
+
+	// Cursor Allows Read and Delete Operations.
+	static final int QRYDEL = 0x2;
+
+	// Cursor is Read-only.
+	static final int QRYRDO = 0x1;
+
+	// Insensitive SCROLL
+	static final int QRYINS = 0x1;
+
+	// Number of fetch or Insert Rows
+	static final int NBRROW = 0x213A;
+
+	// Output expected
+	static final int OUTEXP = 0x2111;
+
+	// Procedure name
+	static final int PRCNAM = 0x2138; 
+
+	// Query Attribute for Updatability
+	static final int QRYATTUPD = 0x2150;
+
+	// Cursor Allows Read, Delete, and Update Operations.
+	static final int QRYUPD = 0x4;
+
+	// Relational Database codepoint constant.  Min. level 3.
+	static final int RDB = 0x240F;
+
+	// RDB Access Manager Class.
+	static final int RDBACCCL = 0x210F;
+
+	// RDB Allow Updates
+	static final int RDBALWUPD = 0x211A;
+
+	// Query Relative  Scrolling Action
+	static final int QRYRELSCR = 0x213C;
+
+	// Query Scroll Orientation
+	static final int QRYSCRORN = 0x2152;
+
+	// Query Row Number
+	static final int QRYROWNBR = 0x213D;
+
+	// Query Row Sensitivity
+	static final int QRYROWSNS = 0x2153;
+
+	// Query Refresh Answer set table 
+	static final int QRYRFRTBL = 0x213E;
+
+	// Query Attribute for Scrollability
+	static final int QRYATTSCR = 0x2149;
+
+	// Query Attribute for Sensitivity
+	static final int QRYATTSNS = 0x2157;
+
+	// Query Block Reset
+	static final int QRYBLKRST = 0x2154;
+
+	// Query Rowset Size
+	static final int QRYROWSET = 0x2156;
+
+	// Query Returns Data
+	static final int QRYRTNDTA = 0x2155;
+
+	// RDB interrupt token.
+	static final int RDBINTTKN = 0x2103;
+
+	// Relational Database Name codepoint constant.
+	static final int RDBNAM = 0x2110;
+
+	// RDB Collection Identifier
+	static final int RDBCOLID = 0x2108;
+
+	// Resource name information
+	static final int RSCNAM = 0x112D;
+
+	// Resource Type Information
+	static final int RSCTYP = 0x111F;
+
+	// Reason Code Information
+	static final int RSNCOD = 0x1127;
+
+	// Resynchronization Manager.  Min levl 5.
+	// It is a manager object of DDM that performs
+	// resynchronization for in-doubt units of work after
+	// a sync point operation failure.
+	static final int RSYNCMGR = 0x14C1;
+
+	// Retuan SQL Descriptor Area
+	static final int RTNSQLDA = 0x2116;
+
+	// Type of SQL Descriptor Area
+	static final int TYPSQLDA = 0x2146;
+
+	// Security Check Code codepoint constant.
+	static final int SECCHKCD = 0x11A4;
+
+	// Security Mechanism codepoint constant.
+	static final int SECMEC = 0x11A2;
+
+	// Security Manager codepoint constant.
+	static final int SECMGR = 0x1440;
+
+	// Security Manager Name codepoint constant.
+	static final int SECMGRNM = 0x1196;
+
+	// Security Token codepoint constant.
+	static final int SECTKN = 0x11DC;
+
+	// Return of EXTDTA Option
+	static final int RTNEXTDTA = 0x2148;
+
+	// Return of EXTDTA Option - Return EXTDTAs by Row
+	static final int RTNEXTROW = 0x1;
+
+	// Return of EXTDTA Option - Return All EXTDTAs for QRYDTA's Sent
+	static final int RTNEXTALL = 0x2;
+
+	// Supervisor name codepoint constant.
+	static final int SPVNAM = 0x115D;
+
+	// SQL Application Manager codepoint constant.  Min. level 3.
+	static final int SQLAM = 0x2407;
+
+	// SQL Communication Area Reply Data codepoint constant.
+	static final int SQLCARD = 0x2408;
+
+	// Hold Cursor Position
+	static final int SQLCSRHLD = 0x211F;
+
+	// SQLDA Reply Data codepoint constant.
+	static final int SQLDARD = 0x2411;
+
+	// Server Class Name codepoint constant.
+	static final int SRVCLSNM = 0x1147;
+
+	// Server Diagnostic Information codepoint constant.
+	static final int SRVDGN = 0x1153;
+
+	// Server List codepoint constant.
+	static final int SRVLST = 0x244E;
+
+	// Server Name codepoint constant.
+	static final int SRVNAM = 0x116D;
+
+	// Server Product Release Level codepoint constant.
+	static final int SRVRLSLV = 0x115A;
+
+	//Statement Decimal Delimiter
+	static final int STTDECDEL = 0x2121;
+
+	//Statement String Delimiter
+	static final int STTSTRDEL = 0x2120;
+
+	// Supervisor.
+	// Manages a collection of managers in a consistent manner.
+	static final int SUPERVISOR = 0x143C;
+
+	// Security Service Error Number codepoint constant.
+	static final int SVCERRNO = 0x11B4;
+
+	// Severity Code codepoint constant.
+	static final int SVRCOD = 0x1149;
+
+	// Sync Point Manager.  Min. level 4.
+	// It is a manager object of DDM that coordinates resource
+	// recovery of the units of work associated with recoverable
+	// resources in multiple DDM servers.
+	static final int SYNCPTMGR = 0x14C0;
+
+	// Syntax Error code
+	static final int SYNERRCD = 0x114A;
+
+	// Data Type Definition Name codepoint constant.
+	static final int TYPDEFNAM = 0x002F;
+
+	// TYPDEF Overrides codepoint constant.
+	static final int TYPDEFOVR = 0x0035;
+
+	// Unit of Word Disposition codepoint constant.
+	static final int UOWDSP = 0x2115;
+
+	// Usrid codepoint constant.
+	static final int USRID = 0x11A0;
+
+	// Version name
+	static final int VRSNAM = 0x1144;
+
+	// Rdb Package Name, Consistency Token, and Section
+	// Number codepoint constant.
+	static final int PKGNAMCSN = 0x2113;
+
+	//-----------------------DDM reply codepoints---------------------------------
+
+	// Invalid description
+	static final int DSCINVRM = 0x220A;
+
+	// Codepoint for Command Authorization for Agent Permanent Error
+	static final int CMDATHRM = 0x121C;
+
+	// Command Check codepoint constant.
+	static final int CMDCHKRM = 0x1254;
+
+	// Command Not Supported codepoint constant.
+	static final int CMDNSPRM = 0x1250;
+
+	// Codepoint for Agent Permanent Error Reply message
+	static final int AGNPRMRM = 0x1232;
+
+	static final int BGNBNDRM = 0x2208;
+
+	// Abnormal End of Unit of Work Condition codepoint constant.
+	static final int ABNUOWRM = 0x220D;
+
+	// Access to RDB Completed.
+	// Specifies that an instance of the SQL application manager
+	// has been created and is bound to the specified RDB.
+	static final int ACCRDBRM = 0x2201;
+
+	final static int CMDCMPRM = 0x124B;
+
+	final static int MGRLVLRM = 0x1210;
+
+	// Manager dependency Error
+	static final int MGRDEPRM = 0x1218;
+
+	// End Unit of Work Condition codepoint constant.
+	static final int ENDUOWRM = 0x220C;
+
+	// Object Not Supported codepoint constant.
+	static final int OBJNSPRM = 0x1253;
+
+	// Conversational Protocol Error
+	static final int PRCCNVRM = 0x1245;
+
+	// Parameter Not Supported codepoint constant.
+	static final int PRMNSPRM = 0x1251;
+
+	// RDB Package Binding Process Not active Codepoint
+	static final int PKGBNARM = 0x2206;
+
+	// RDB Package Binding Process Active codepoint constant.
+	static final int PKGBPARM = 0x2209;
+
+	// Query not open codepoint constant.
+	static final int QRYNOPRM = 0x2202;
+
+	// Query previously opened codepoint
+	static final int QRYPOPRM = 0x220F;
+
+	// RDB Currently Accessed Codepoint
+	static final int RDBACCRM = 0x2207;
+
+	// Security Check.
+	// Indicates the acceptability of the security information.
+	static final int SECCHKRM = 0x1219;
+
+	// RDB Access Failed Reply Message codepoint
+	static final int RDBAFLRM = 0x221A;
+
+	// Not Authorized To RDB reply message codepoint
+	static final int RDBATHRM = 0x22CB;
+
+	// RDB Not Accessed codepoint constant.
+	static final int RDBNACRM = 0x2204;
+
+	// RDB not found codepoint
+	static final int RDBNFNRM = 0x2211;
+
+	// RDB Update Reply Message codepoint constant.
+	static final int RDBUPDRM = 0x2218;
+
+	// Resources Limits Reached
+	static final int RSCLMTRM = 0x1233;
+
+	// Data Stream Syntax Error
+	static final int SYNTAXRM = 0x124C;
+
+	// Target Not Supported
+	static final int TRGNSPRM = 0x125F;
+
+	// Parameter Value Not Supported codepoint constant.
+	static final int VALNSPRM = 0x1252;
+
+	// SQL Error Condition codepoint constant.
+	static final int SQLERRRM = 0x2213;
+
+	final static int OPNQRYRM = 0x2205;
+	final static int ENDQRYRM = 0x220B;
+	final static int DTAMCHRM = 0x220E;
+	final static int OPNQFLRM = 0x2212;
+	final static int RSLSETRM = 0x2219;
+	final static int CMDVLTRM = 0x221D;
+	final static int CMMRQSRM = 0x2225;
+
+	//-----------------------ddm enumerated values-------------------------------
+
+	// TYPSQLDA - Standard Output SQLDA
+	static final int TYPSQLDA_STD_OUTPUT = 0;
+
+	// TYPSQLDA - Standard Input SQLDA
+	static final int TYPSQLDA_STD_INPUT = 1;
+
+	// TYPSQLDA - Light Output SQLDA
+	static final int TYPSQLDA_LIGHT_OUTPUT = 2;
+
+	// TYPSQLDA - Light Input SQLDA
+	static final int TYPSQLDA_LIGHT_INPUT = 3;
+
+	// TYPSQLDA - Extended Output SQLDA
+	static final int TYPSQLDA_X_OUTPUT = 4;
+
+	// TYPSQLDA - Extended Input SQLDA
+	static final int TYPSQLDA_X_INPUT = 5;
+
+
+
+	// QRYCLSIMP - Target Server determines whether to implicitly
+	// close the cursor or not upon SQLSTATE 02000 based on cursor type.
+	static final int QRYCLSIMP_SERVER_CHOICE = 0x00;
+	
+	// QRYCLSIMP - Target Server must implicitly close the cursor
+	// upon SQLSTATE 02000.
+	static final int QRYCLSIMP_YES = 0x01;
+	
+	// QRYCLSIMP - Target Server must not implicitly close the cursor
+	// upon SQLSTATE 02000.
+	static final int QRYCLSIMP_NO = 0x02;
+
+	// QRYCLSRLS - Do not release read locks when the query is closed
+	static final int QRYCLSRLS_NO = 0x00;
+	
+	// QRYCLSRLS - Release read locks when the query is closed
+	static final int QRYCLSRLS_YES = 0x01;
+
+	// QRYBLKFCT - No 'OPTIMIZE for N ROWS' clause associated with
+	// the select statement for the cursor.
+	static final int QRYBLKFCT_NONE = 0x00;
+	
+	// QRYBLKEXA - Every query block is exactly the size specified
+	// in the QRYBLKSZ parameter, except for possibly the last
+	// query block which may be shorter.
+	static final int QRYBLKEXA = 0x00;
+
+	// QRYBLKFLX - Every query block is at least the size specified
+	// in the QRYBLKSZ parameter, except for possibly the last
+	// query block which may be shorter.
+	static final int QRYBLKFLX = 0x01;
+	
+	//----------------------------fdoca code points-------------------------------
+
+	// Externalized FD:OCA Data codepoint constant.
+	static final int EXTDTA = 0x146C;
+
+	// FDOCA data descriptor
+	static final int FDODSC = 0x0010;
+
+	// FDOCA data
+	static final int FDODTA = 0x147A;
+
+	// FDOCA Descriptor offset
+	static final int FDODSCOFF = 0x2118;
+
+	// FDOCA Triplet Parameter offset
+	static final int FDOPRMOFF = 0x212B;
+
+	// FDOCA Triplet offset
+	static final int FDOTRPOFF = 0x212A;
+
+	//--------------------------ddm error code points---------------------------------
+	static final int SYNERRCD_DSS_LESS_THAN_6 = 0x01;
+	static final int SYNERRCD_DSS_LENGTH_BYTE_NUMBER_MISMATCH = 0x02;
+	static final int SYNERRCD_CBYTE_NOT_D0 = 0x03;
+	static final int SYNERRCD_FBYTE_NOT_SUPPORTED = 0x04;
+	static final int SYNERRCD_OBJ_LEN_LESS_THAN_4 = 0x07;
+	static final int SYNERRCD_TOO_BIG = 0x09;
+	static final int SYNERRCD_OBJ_LEN_NOT_ALLOWED = 0x0B;
+	static final int SYNERRCD_INCORRECT_EXTENDED_LEN = 0x0C;
+	static final int SYNERRCD_REQ_OBJ_NOT_FOUND = 0x0E;
+	static final int SYNERRCD_TOO_MANY = 0x0F;
+	static final int SYNERRCD_DUP_OBJ_PRESENT = 0x12;
+	static final int SYNERRCD_INVALID_CORRELATOR = 0x13;
+	static final int SYNERRCD_REQ_VAL_NOT_FOUND = 0x14;
+	static final int SYNERRCD_DSS_CONT_LESS_OR_EQUAL_2 = 0x16;
+	static final int SYNERRCD_CHAIN_OFF_SAME_NEXT_CORRELATOR = 0x18;
+	static final int SYNERRCD_CHAIN_OFF_ERROR_CONTINUE = 0x1A;
+	static final int SYNERRCD_INVALID_CP_FOR_CMD = 0x1D;
+
+	static final int PRCCNVCD_OBJDSS_SENT_NOT_ALLOWED = 0x03;
+	static final int PRCCNVCD_EXCSAT_FIRST_AFTER_CONN = 0x06;
+	static final int PRCCNVCD_ACCSEC_SECCHK_WRONG_STATE = 0x11;
+	static final int PRCCNVCD_RDBNAM_MISMATCH = 0x12;
+
+	static final int SVRCOD_INFO = 0;      // Information Only Severity Code
+	static final int SVRCOD_WARNING = 4;   // Warning Severity Code
+	static final int SVRCOD_ERROR = 8;     // Error Severity Code
+	static final int SVRCOD_SEVERE = 16;   // Severe Error Severity Code
+	static final int SVRCOD_ACCDMG = 32;   // Access Damage Severity Code
+	static final int SVRCOD_PRMDMG = 64;   // Permanent Damage Severity Code
+	static final int SVRCOD_SESDMG = 128;  // Session Damage Severity Code
+	
+	//---------------------- Security Mechanisms ---------------------------
+	static final int SECMEC_DCESEC = 1;		// Distributed Computing Environment Security
+	static final int SECMEC_USRIDPWD = 3;	// Userid and Password
+	static final int SECMEC_USRIDONL = 4;	// Userid only
+	static final int SECMEC_USRIDNWPWD = 5;  // Userid, Password, and new Password
+	static final int SECMEC_USRSBSPWD = 6;  // Userid with substitute password
+	static final int SECMEC_USRENCPWD = 7;  // Userid with encrypted password
+	static final int SECMEC_EUSRIDPWD = 9;  // Encrpyted userid and password
+	static final int SECMEC_EUSRIDNWPWD = 10;  // Encrpyted userid and password
+
+	//---------------------Security Check Codes ---------------------------
+	static final int SECCHKCD_OK = 0;		// Security info correct and acceptable
+	static final int SECCHKCD_NOTSUPPORTED = 0x01;	// SECMEC value not supported
+	static final int SECCHKCD_SECTKNMISSING = 0x0E;	// SECTKN missing or invalid 
+	static final int SECCHKCD_PASSWORDMISSING = 0x10;	// Password missing  
+	static final int SECCHKCD_USERIDMISSING = 0x12;	// User Id missing  
+	static final int SECCHKCD_USERIDINVALID = 0x13;	// Userid invalid
+
+	//----------------------Type Definition Names we care about -----------
+	static final String TYPDEFNAM_QTDSQLASC = "QTDSQLASC"; // ASCII
+	static final String TYPDEFNAM_QTDSQLJVM = "QTDSQLJVM"; // Java platform
+	static final String TYPDEFNAM_QTDSQLX86 = "QTDSQLX86"; //  Intel X86 platform
+
+	//----------------------Max sizes for strings in the protocol ---------
+	static final int MAX_NAME = 255;
+	static final int RDBNAM_LEN = 18; //dbname fixed length for SQLAM level 6, for level 7,
+									  //limit is MAX_NAME (255)
+	static final int PRDID_MAX = 8;
+	static final int RDBCOLID_LEN = 18;
+	static final int PKGID_LEN = 18;
+	static final int PKGCNSTKN_LEN = 8;
+	static final int PKGNAMCSN_LEN = RDBNAM_LEN + RDBCOLID_LEN + PKGID_LEN +
+		PKGCNSTKN_LEN + 2;
+
+	//---------------------QRYBLSZ min and maximum
+	static final int QRYBLKSZ_MIN = 512;
+	static final int QRYBLKSZ_MAX = 32767;
+	static final int QRYROWSET_MAX = 32767;
+	static final int QRYROWSET_DEFAULT = -1;
+
+	//--------------------Defaults for QRYBLKCTL and MAXBLKEXT
+	static final int QRYBLKCTL_DEFAULT = LMTBLKPRC;
+	static final int MAXBLKEXT_NONE = 0;
+	static final int MAXBLKEXT_DEFAULT = MAXBLKEXT_NONE;
+
+	//-------------------Default for QRYCLSIMP
+	static final int QRYCLSIMP_DEFAULT = QRYCLSIMP_SERVER_CHOICE;
+
+	//-------------- QRYSCRORN - query scroll orientation values
+	static final int QRYSCRREL = 1;		// relative fetch
+	static final int QRYSCRABS = 2;		// absolute fetch
+	static final int QRYSCRAFT = 3;		// after last row
+	static final int QRYSCRBEF = 4;		// before first row
+
+	//---------------OUTOVROPT - output override option values
+	static final int OUTOVRFRS = 1; 	// Output Override allowed on first CNTQRY
+	static final int OUTOVRANY = 2; 	// Output Override allowed on any CNTQRY
+
+	//-----------------------Manager code points --------------------------
+
+	protected static int [] MGR_CODEPOINTS = {
+											AGENT,
+											CCSIDMGR,	
+											CMNAPPC, 
+											CMNSYNCPT,	
+											CMNTCPIP,	
+											DICTIONARY,
+											RDB,
+											RSYNCMGR,	
+											SECMGR,	
+											SQLAM,
+											SUPERVISOR,	
+											SYNCPTMGR,
+											XAMGR
+											};
+	protected static final int UNKNOWN_MANAGER = -1;
+
+	// hide the default constructor
+	private CodePoint () {}
+
+	/**
+	 * Given a manager codepoint find it's location in the managers array
+	 *
+	 * @return index into manager array or UNKNOWN_MANAGER if not found
+	 */
+	protected static int getManagerIndex(int manager)
+	{
+		for (int i = 0; i < MGR_CODEPOINTS.length; i++)
+			if (MGR_CODEPOINTS[i] == manager)
+				return i;
+		return UNKNOWN_MANAGER;
+	}
+	/**
+	 * Check if a manager codepoint is a known manager
+	 * 
+	 * @return true if known, false otherwise
+	 */
+	protected static boolean isKnownManager(int manager)
+	{
+		for (int i = 0; i < CodePoint.MGR_CODEPOINTS.length; i++)
+			if (manager == CodePoint.MGR_CODEPOINTS[i])
+				return true;
+		return false;
+	}
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePointNameTable.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePointNameTable.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,156 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derby.impl.drda;
+
+/**
+  This class has a hashtable of CodePoint values.  It is used by the tracing
+  code and by the protocol testing code
+  It is arranged in alphabetical order.
+*/
+
+class CodePointNameTable extends java.util.Hashtable
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+  private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+  CodePointNameTable ()
+  {
+    put (new Integer (CodePoint.ABNUOWRM), "ABNUOWRM");
+    put (new Integer (CodePoint.ACCRDB), "ACCRDB");
+    put (new Integer (CodePoint.ACCRDBRM), "ACCRDBRM");
+    put (new Integer (CodePoint.ACCSEC), "ACCSEC");
+    put (new Integer (CodePoint.ACCSECRD), "ACCSECRD");
+    put (new Integer (CodePoint.AGENT), "AGENT");
+    put (new Integer (CodePoint.AGNPRMRM), "AGNPRMRM");
+    put (new Integer (CodePoint.BGNBND), "BGNBND");
+    put (new Integer (CodePoint.BGNBNDRM), "BGNBNDRM");
+    put (new Integer (CodePoint.BNDSQLSTT), "BNDSQLSTT");
+    put (new Integer (CodePoint.CCSIDSBC), "CCSIDSBC");
+    put (new Integer (CodePoint.CCSIDMBC), "CCSIDMBC");
+    put (new Integer (CodePoint.CCSIDDBC), "CCSIDDBC");
+    put (new Integer (CodePoint.CLSQRY), "CLSQRY");
+    put (new Integer (CodePoint.CMDATHRM), "CMDATHRM");
+    put (new Integer (CodePoint.CMDCHKRM), "CMDCHKRM");
+    put (new Integer (CodePoint.CMDCMPRM), "CMDCMPRM");
+    put (new Integer (CodePoint.CMDNSPRM), "CMDNSPRM");
+    put (new Integer (CodePoint.CMMRQSRM), "CMMRQSRM");
+    put (new Integer (CodePoint.CMDVLTRM), "CMDVLTRM");
+    put (new Integer (CodePoint.CNTQRY), "CNTQRY");
+    put (new Integer (CodePoint.CRRTKN), "CRRTKN");
+    put (new Integer (CodePoint.DRPPKG), "DRPPKG");
+    put (new Integer (CodePoint.DSCRDBTBL), "DSCRDBTBL");
+    put (new Integer (CodePoint.DSCINVRM), "DSCINVRM");
+    put (new Integer (CodePoint.DSCSQLSTT), "DSCSQLSTT");
+    put (new Integer (CodePoint.DTAMCHRM), "DTAMCHRM");
+    put (new Integer (CodePoint.ENDBND), "ENDBND");
+    put (new Integer (CodePoint.ENDQRYRM), "ENDQRYRM");
+    put (new Integer (CodePoint.ENDUOWRM), "ENDUOWRM");
+    put (new Integer (CodePoint.EXCSAT), "EXCSAT");
+    put (new Integer (CodePoint.EXCSATRD), "EXCSATRD");
+    put (new Integer (CodePoint.EXCSQLIMM), "EXCSQLIMM");
+    put (new Integer (CodePoint.EXCSQLSET), "EXCSQLSET");
+    put (new Integer (CodePoint.EXCSQLSTT), "EXCSQLSTT");
+    put (new Integer (CodePoint.EXTNAM), "EXTNAM");
+    put (new Integer (CodePoint.MAXBLKEXT), "MAXBLKEXT");
+    put (new Integer (CodePoint.MAXRSLCNT), "MAXRSLCNT");
+    put (new Integer (CodePoint.MGRDEPRM), "MGRDEPRM");
+    put (new Integer (CodePoint.MGRLVLLS), "MGRLVLLS");
+    put (new Integer (CodePoint.MGRLVLRM), "MGRLVLRM");
+    put (new Integer (CodePoint.NBRROW), "NBRROW");
+    put (new Integer (CodePoint.OBJNSPRM), "OBJNSPRM");
+    put (new Integer (CodePoint.OPNQFLRM), "OPNQFLRM");
+    put (new Integer (CodePoint.OPNQRY), "OPNQRY");
+    put (new Integer (CodePoint.OPNQRYRM), "OPNQRYRM");
+    put (new Integer (CodePoint.OUTEXP), "OUTEXP");
+    put (new Integer (CodePoint.OUTOVR), "OUTOVR");
+    put (new Integer (CodePoint.OUTOVROPT), "OUTOVROPT");
+    put (new Integer (CodePoint.PASSWORD), "PASSWORD");
+    put (new Integer (CodePoint.PKGID), "PKGID");
+    put (new Integer (CodePoint.PKGBNARM), "PKGBNARM");
+    put (new Integer (CodePoint.PKGBPARM), "PKGBPARM");
+    put (new Integer (CodePoint.PKGNAMCSN), "PKGNAMCSN");
+    put (new Integer (CodePoint.PRCCNVRM), "PRCCNVRM");
+    put (new Integer (CodePoint.PRDID), "PRDID");
+    put (new Integer (CodePoint.PRDDTA), "PRDDTA");
+    put (new Integer (CodePoint.PRMNSPRM), "PRMNSPRM");
+    put (new Integer (CodePoint.PRPSQLSTT), "PRPSQLSTT");
+    put (new Integer (CodePoint.QRYBLKCTL), "QRYBLKCTL");
+    put (new Integer (CodePoint.QRYBLKRST), "QRYBLKRST");
+    put (new Integer (CodePoint.QRYBLKSZ), "QRYBLKSZ");
+    put (new Integer (CodePoint.QRYDSC), "QRYDSC");
+    put (new Integer (CodePoint.QRYDTA), "QRYDTA");
+    put (new Integer (CodePoint.QRYINSID), "QRYINSID");
+    put (new Integer (CodePoint.QRYNOPRM), "QRYNOPRM");
+    put (new Integer (CodePoint.QRYPOPRM), "QRYPOPRM");
+    put (new Integer (CodePoint.QRYRELSCR), "QRYRELSCR");
+    put (new Integer (CodePoint.QRYRFRTBL), "QRYRFRTBL");
+    put (new Integer (CodePoint.QRYROWNBR), "QRYROWNBR");
+    put (new Integer (CodePoint.QRYROWSNS), "QRYROWSNS");
+    put (new Integer (CodePoint.QRYRTNDTA), "QRYRTNDTA");
+    put (new Integer (CodePoint.QRYSCRORN), "QRYSCRORN");
+    put (new Integer (CodePoint.QRYROWSET), "QRYROWSET");
+    put (new Integer (CodePoint.RDBAFLRM), "RDBAFLRM");
+    put (new Integer (CodePoint.RDBACCCL), "RDBACCCL");
+    put (new Integer (CodePoint.RDBACCRM), "RDBACCRM");
+    put (new Integer (CodePoint.RDBALWUPD), "RDBALWUPD");
+    put (new Integer (CodePoint.RDBATHRM), "RDBATHRM");
+    put (new Integer (CodePoint.RDBCMM), "RDBCMM");
+    put (new Integer (CodePoint.RDBCMTOK), "RDBCMTOK");
+    put (new Integer (CodePoint.RDBNACRM), "RDBNACRM");
+    put (new Integer (CodePoint.RDBNAM), "RDBNAM");
+    put (new Integer (CodePoint.RDBNFNRM), "RDBNFNRM");
+    put (new Integer (CodePoint.RDBRLLBCK), "RDBRLLBCK");
+    put (new Integer (CodePoint.RDBUPDRM), "RDBUPDRM");
+    put (new Integer (CodePoint.REBIND), "REBIND");
+    put (new Integer (CodePoint.RSCLMTRM), "RSCLMTRM");
+    put (new Integer (CodePoint.RSLSETRM), "RSLSETRM");
+    put (new Integer (CodePoint.RTNEXTDTA), "RTNEXTDTA");
+    put (new Integer (CodePoint.RTNSQLDA), "RTNSQLDA");
+    put (new Integer (CodePoint.SECCHK), "SECCHK");
+    put (new Integer (CodePoint.SECCHKCD), "SECCHKCD");
+    put (new Integer (CodePoint.SECCHKRM), "SECCHKRM");
+    put (new Integer (CodePoint.SECMEC), "SECMEC");
+    put (new Integer (CodePoint.SECMGRNM), "SECMGRNM");
+    put (new Integer (CodePoint.SECTKN), "SECTKN");
+    put (new Integer (CodePoint.SPVNAM), "SPVNAM");
+    put (new Integer (CodePoint.SQLAM), "SQLAM");
+    put (new Integer (CodePoint.SQLATTR), "SQLATTR");
+    put (new Integer (CodePoint.SQLCARD), "SQLCARD");
+    put (new Integer (CodePoint.SQLERRRM), "SQLERRRM");
+    put (new Integer (CodePoint.SQLDARD), "SQLDARD");
+    put (new Integer (CodePoint.SQLDTA), "SQLDTA");
+    put (new Integer (CodePoint.SQLDTARD), "SQLDTARD");
+    put (new Integer (CodePoint.SQLSTT), "SQLSTT");
+    put (new Integer (CodePoint.SQLSTTVRB), "SQLSTTVRB");
+    put (new Integer (CodePoint.SRVCLSNM), "SRVCLSNM");
+    put (new Integer (CodePoint.SRVRLSLV), "SRVRLSLV");
+    put (new Integer (CodePoint.SRVNAM), "SRVNAM");
+    put (new Integer (CodePoint.SVRCOD), "SVRCOD");
+    put (new Integer (CodePoint.SYNCCTL), "SYNCCTL");
+    put (new Integer (CodePoint.SYNCLOG), "SYNCLOG");
+    put (new Integer (CodePoint.SYNCRSY), "SYNCRSY");
+    put (new Integer (CodePoint.SYNTAXRM), "SYNTAXRM");
+    put (new Integer (CodePoint.TRGNSPRM), "TRGNSPRM");
+    put (new Integer (CodePoint.TYPDEFNAM), "TYPDEFNAM");
+    put (new Integer (CodePoint.TYPDEFOVR), "TYPDEFOVR");
+    put (new Integer (CodePoint.TYPSQLDA), "TYPSQLDA");
+    put (new Integer (CodePoint.UOWDSP), "UOWDSP");
+    put (new Integer (CodePoint.USRID), "USRID");
+    put (new Integer (CodePoint.VALNSPRM), "VALNSPRM");
+  }
+
+  String lookup (int codePoint)
+  {
+    return (String) get (new Integer (codePoint));
+  }
+
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DB2jServerImpl.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DB2jServerImpl.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,3419 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.apache.derby.iapi.reference.Attribute;
+import org.apache.derby.iapi.reference.Property;
+import org.apache.derby.iapi.services.info.ProductGenusNames;
+import org.apache.derby.iapi.services.info.ProductVersionHolder;
+import org.apache.derby.iapi.services.info.JVMInfo;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.impl.jdbc.EmbedSQLException;
+import org.apache.derby.iapi.jdbc.DRDAServerStarter;
+import org.apache.derby.iapi.tools.i18n.LocalizedResource;
+import org.apache.derby.iapi.tools.i18n.LocalizedOutput;
+import org.apache.derby.iapi.services.property.PropertyUtil;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.iapi.services.monitor.Monitor;
+import org.apache.derby.iapi.util.StringUtil;
+import org.apache.derby.drda.NetworkServerControl;
+
+/** 
+	
+	DB2jServerImpl does all the work for DB2jServer
+	@see NetworkServerControl for description
+
+*/
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+public class DB2jServerImpl { private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+	private final static int NO_USAGE_MSGS= 12;
+	private final static String [] COMMANDS = 
+	{"start","shutdown","trace","tracedirectory","ping", 
+	 "logconnections", "sysinfo", "runtimeinfo",  "maxthreads", "timeslice"};
+	// number of required arguments for each command
+	private final static int [] COMMAND_ARGS =
+	{0, 0, 1, 1, 0, 1, 0, 0, 1, 1};
+	private final static int COMMAND_START = 0;
+	private final static int COMMAND_SHUTDOWN = 1;
+	private final static int COMMAND_TRACE = 2;
+	private final static int COMMAND_TRACEDIRECTORY = 3;
+	private final static int COMMAND_TESTCONNECTION = 4;
+	private final static int COMMAND_LOGCONNECTIONS = 5;
+	private final static int COMMAND_SYSINFO = 6;
+	private final static int COMMAND_RUNTIME_INFO = 7;
+	private final static int COMMAND_MAXTHREADS = 8;
+	private final static int COMMAND_TIMESLICE = 9;
+	private final static int COMMAND_PROPERTIES = 10;
+	private final static int COMMAND_UNKNOWN = -1;
+	private final static String [] DASHARGS =
+	{"p","d","u","ld","ea","ep", "b", "h", "s"};
+	private final static int DASHARG_PORT = 0;
+	private final static int DASHARG_DATABASE = 1;
+	private final static int DASHARG_USER = 2;
+	private final static int DASHARG_LOADSYSIBM = 3;
+	private final static int DASHARG_ENCALG = 4;
+	private final static int DASHARG_ENCPRV = 5;
+	private final static int DASHARG_BOOTPASSWORD = 6;
+	private final static int DASHARG_HOST = 7;
+	private final static int DASHARG_SESSION = 8;
+
+	// command protocol version - you need to increase this number each time
+	// the command protocol changes 
+	private final static int PROTOCOL_VERSION = 1;
+	private final static String COMMAND_HEADER = "CMD:";
+	private final static String REPLY_HEADER = "RPY:";
+	private final static int REPLY_HEADER_LENGTH = REPLY_HEADER.length();
+	private final static int OK = 0;
+	private final static int WARNING = 1;
+	private final static int ERROR = 2;
+	private final static int SQLERROR = 3;
+	private final static int SQLWARNING = 4;
+
+	private final static String
+		DB2J_PROP_STREAM_ERROR_FIELD="derby.stream.error.field";
+
+	private final static String
+		DB2J_PROP_STREAM_ERROR_METHOD="derby.stream.error.method";
+	private final static String
+		DB2J_PROP_STREAM_ERROR_FILE="derby.stream.error.file";
+
+	private final static String DRDA_PROP_MESSAGES = "org.apache.derby.loc.drda.messages";
+	private final static String DRDA_PROP_DEBUG = "derby.drda.debug";
+	private final static String CLOUDSCAPE_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
+
+	protected final static String UNEXPECTED_ERR = "Unexpected exception";
+
+	private final static int MIN_MAXTHREADS = -1;
+	private final static int MIN_TIMESLICE = -1;
+	private final static int USE_DEFAULT = -1;
+	private final static int DEFAULT_MAXTHREADS = 0; //for now create whenever needed
+	private final static int DEFAULT_TIMESLICE = 0;	//for now never yield
+
+   private final static String DEFAULT_HOST = "localhost";
+	private final static String DRDA_MSG_PREFIX = "DRDA_";
+	private final static String DEFAULT_LOCALE= "en";
+	private final static String DEFAULT_LOCALE_COUNTRY="US";
+
+	// Check up to 10 seconds to see if shutdown occurred
+	private final static int SHUTDOWN_CHECK_ATTEMPTS = 20;
+	private final static int SHUTDOWN_CHECK_INTERVAL= 500;
+
+	// maximum reply size
+	private final static int MAXREPLY = 32767;
+
+	// Application Server Attributes.
+	protected static String att_srvclsnm;
+	protected final static String ATT_SRVNAM = "NetworkServerControl";
+
+	protected static String att_extnam;
+	protected static String att_srvrlslv; 
+	protected static String prdId;
+	private static int buildNumber;
+	// we will use single or mixed, not double byte to reduce traffic on the
+	// wire, this is in keeping with JCC
+	// Note we specify UTF8 for the single byte encoding even though it can
+	// be multi-byte.
+	protected final static int CCSIDSBC = 1208; //use UTF8
+	protected final static int CCSIDMBC = 1208; //use UTF8
+	protected final static String DEFAULT_ENCODING = "UTF8"; // use UTF8 for writing
+	protected final static int DEFAULT_CCSID = 1208;
+	protected final static byte SPACE_CHAR = 32;
+														
+	protected final static int DEFAULT_SECURITY_MECHANISM =  CodePoint.SECMEC_USRIDPWD;
+
+	// Application Server manager levels - this needs to be in sync
+	// with CodePoint.MGR_CODEPOINTS
+	protected final static int [] MGR_LEVELS = { 7, // AGENT
+												 4,	// CCSID Manager
+												 0, // CNMAPPC not implemented
+												 0, // CMNSYNCPT not implemented
+												 5, // CMNTCPIP
+												 0, // DICTIONARY
+												 7, // RDB
+												 0, // RSYNCMGR
+												 7, // SECMGR
+												 7, // SQLAM
+												 0, // SUPERVISOR
+												 0, // SYNCPTMGR
+												 0  // XAMGR
+												};
+											
+	
+	protected PrintWriter logWriter;                        // console
+	protected PrintWriter cloudscapeLogWriter;              // derby.log
+	protected Driver cloudscapeDriver;
+
+	// error types
+	private final static int ERRTYPE_SEVERE = 1;
+	private final static int ERRTYPE_USER = 2;
+	private final static int ERRTYPE_INFO = 3;
+	private final static int ERRTYPE_UNKNOWN = -1;
+
+	// command argument information
+	private Vector commandArgs = new Vector();
+	private String databaseArg;
+	private String userArg;
+	private String passwordArg;
+	private String bootPasswordArg;
+	private String encAlgArg;
+	private String encPrvArg;
+	private String hostArg = DEFAULT_HOST;	
+	private InetAddress hostAddress;
+	private int sessionArg;
+
+	// Used to debug memory in SanityManager.DEBUG mode
+	private memCheck mc;
+
+	// reply buffer
+	private byte [] replyBuffer;	
+	private int replyBufferCount;	//length of reply
+	private int replyBufferPos;		//current position in reply
+
+	//
+	// server configuration
+	//
+	// static values - set at start can't be changed once server has started
+	private int	portNumber = NetworkServerControl.DEFAULT_PORTNUMBER;	// port server listens to
+
+	// configurable values
+	private String traceDirectory;		// directory to place trace files in
+	private Object traceDirectorySync = new Object();// object to use for syncing
+	private boolean traceAll;			// trace all sessions
+	private Object traceAllSync = new Object();	// object to use for syncing reading
+										// and changing trace all
+	private Object serverStartSync = new Object();	// for syncing start of server.
+	private boolean logConnections;		// log connect and disconnects
+	private Object logConnectionsSync = new Object(); // object to use for syncing 
+										// logConnections value
+	private int minThreads;				// default minimum number of connection threads
+	private int maxThreads;				// default maximum number of connection threads
+	private Object threadsSync = new Object(); // object to use for syncing reading
+										// and changing default min and max threads
+	private int timeSlice;				// default time slice of a session to a thread
+	private Object timeSliceSync = new Object();// object to use for syncing reading
+										// and changing timeSlice
+
+	private int minPoolSize;			//minimum pool size for pooled connections
+	private int maxPoolSize;			//maximum pool size for pooled connections
+	private Object poolSync = new Object();	// object to use for syning reading
+
+	protected boolean debugOutput = false;
+	private boolean cleanupOnStart = false;	// Should we clean up when starting the server?
+	private boolean restartFlag = false;
+
+	private String errorLogLocation = null;
+
+	//
+	// variables for a client command session
+	//
+	private Socket clientSocket = null;
+	private InputStream clientIs = null;
+	private OutputStream clientOs = null;
+	private ByteArrayOutputStream byteArrayOs = new ByteArrayOutputStream();
+	private DataOutputStream commandOs = new DataOutputStream(byteArrayOs);
+	
+	private Object shutdownSync = new Object();
+	private boolean shutdown;
+	private int connNum;		// number of connections since server started
+	private ServerSocket serverSocket;
+	private DB2jServerImpl serverInstance;
+	private LocalizedResource langUtil;
+	public String clientLocale;
+	ArrayList  localAddresses; // list of local addresses for checking admin
+	                              // commands. 
+
+	// open sessions
+	private Hashtable sessionTable = new Hashtable();
+
+	// current session
+	private Session currentSession;
+	// DRDAConnThreads
+	private Vector threadList = new Vector();
+
+	// queue of sessions waiting for a free thread - the queue is managed
+	// in a simple first come, first serve manner - no priorities
+	private Vector runQueue = new Vector();
+
+	// number of DRDAConnThreads waiting for something to do
+	private int freeThreads;
+
+	// known application requesters
+	private Hashtable appRequesterTable = new Hashtable();
+
+	// accessed by inner classes for privileged action
+	private String propertyFileName;
+	private Runnable acceptClients;
+	
+
+	
+
+	// constructor
+	public DB2jServerImpl() throws Exception
+	{
+		getPropertyInfo();
+		init();
+    }
+
+
+	/**
+	 * Internal constructor for NetworkServerControl API. 
+	 * @ param address - InetAddress to listen on, May not be null. 
+	 * Throws NPE if null
+	 * @ portNumber - portNumber to listen on, -1 use propert or default.
+	 * @ throw Exception on error
+	 * @see NetworkServerControl
+	 */
+	public DB2jServerImpl(InetAddress address, int portNumber) throws Exception
+	{
+		getPropertyInfo();
+		this.hostAddress = address;
+		this.portNumber = (portNumber <= 0) ?
+			this.portNumber: portNumber;
+		this.hostArg = address.getHostAddress();
+		init();
+	}
+
+    private void init() throws Exception
+    {
+
+        // adjust the application in accordance with derby.ui.locale and derby.ui.codeset
+		langUtil = new LocalizedResource(null,null,DRDA_PROP_MESSAGES);
+
+		serverInstance = this;
+		
+		//set Server attributes to be used in EXCSAT
+		ProductVersionHolder myPVH = getNetProductVersionHolder();
+		att_extnam = ATT_SRVNAM + " " + java.lang.Thread.currentThread().getName();
+		
+		att_srvclsnm = myPVH.getProductName();
+
+		String majorStr = String.valueOf(myPVH.getMajorVersion());
+		String minorStr = String.valueOf(myPVH.getMinorVersion());
+		// Maintenance version. Server protocol version.
+		// Only changed if client needs to recognize a new server version.
+		String drdaMaintStr = String.valueOf(myPVH.getDrdaMaintVersion());
+
+		// PRDID format as JCC expects it: CSSMMmx
+		// MM = major version
+		// mm = minor version
+		// x = drda MaintenanceVersion
+
+		prdId = "CSS";
+		if (majorStr.length() == 1)
+			prdId += "0";
+		prdId += majorStr;
+
+		if (minorStr.length() == 1)
+			prdId += "0";
+
+		prdId += minorStr;
+		
+		prdId += drdaMaintStr;
+		att_srvrlslv = prdId + "/" + myPVH.getVersionBuildString(false);
+		
+		if (SanityManager.DEBUG)
+		{
+			if (majorStr.length() > 2  || 
+				minorStr.length() > 2 || 
+				drdaMaintStr.length() > 1)
+				SanityManager.THROWASSERT("version values out of expected range  for PRDID");
+		}
+
+		buildNumber = myPVH.getBuildNumber();
+	}
+
+    private PrintWriter makePrintWriter( OutputStream out)
+    {
+		if (out != null)
+			return new PrintWriter(out, true /* flush the buffer at the end of each line */);
+		else
+			return null;
+    }
+	/********************************************************************************
+	 * Implementation of NetworkServerControl API
+	 * The server commands throw exceptions for errors, so that users can handle
+	 * them themselves in addition to having the errors written to the console
+	 * and possibly DB2j.log.  To turn off logging the errors to the console,
+	 * set the output writer to null.
+	 ********************************************************************************/
+
+
+	/**
+	 * Set the output stream for console messages
+	 * If this is set to null, no messages will be written to the console
+	 *
+	 * @param outStream	output stream for console messages
+	 */
+	public void setLogWriter(PrintWriter outWriter)
+	{
+		logWriter = outWriter;
+    }
+
+
+	
+	/**
+	 * Write an error message to console output stream
+	 * and throw an exception for this error
+	 *
+	 * @param msg	error message
+	 * @exception Exception
+	 */
+	public void consoleError(String msg)
+		throws Exception
+	{
+		consoleMessage(msg);
+		throw new Exception(msg);
+	}
+
+	/**
+	 * Write an exception to console output stream,
+	 * but only if debugOutput is true.
+	 *
+	 * @param e	exception 
+	 */
+	public void consoleExceptionPrint(Exception e)
+	{
+		if (debugOutput == true)
+			consoleExceptionPrintTrace(e);
+
+		return;
+	}
+
+	/**
+	 * Write an exception (with trace) to console
+	 * output stream.
+	 *
+	 * @param e	exception 
+	 */
+	public void consoleExceptionPrintTrace(Throwable e)
+	{
+		consoleMessage(e.getMessage());
+		if (logWriter != null)
+		{
+			synchronized (logWriter) {
+				e.printStackTrace(logWriter);
+			}
+		}
+		else
+		{
+			e.printStackTrace();
+		}
+		
+		if (cloudscapeLogWriter != null)
+		{
+			synchronized(cloudscapeLogWriter) {
+				e.printStackTrace(cloudscapeLogWriter);
+			}
+		}
+	}
+
+
+
+
+	/**
+	 * Write a message to console output stream
+	 *
+	 * @param msg	message
+	 */
+	public void consoleMessage(String msg)
+	{
+		// print to console if we have one
+		if (logWriter != null)
+		{
+			synchronized(logWriter) {
+				logWriter.println(msg);
+			}
+		}
+		// always print to derby.log
+		if (cloudscapeLogWriter != null)
+			synchronized(cloudscapeLogWriter)
+			{
+				Monitor.logMessage(msg);
+			}
+	}
+
+
+
+	/**
+	 * Start a network server.  Launches a separate thread with 
+	 * DRDAServerStarter.  Want to use Monitor.startModule,
+	 * so it can all get shutdown when cloudscape shuts down, but 
+	 * can't get it working right now.
+	 *
+	 * @param consoleWriter   PrintWriter to which server console will be 
+	 *                        output. Null will disable console output.
+	 *
+	 *		   
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void start(PrintWriter consoleWriter)
+		throws Exception
+	{
+		DRDAServerStarter starter = new DRDAServerStarter();
+		starter.setStartInfo(hostAddress,portNumber,consoleWriter);
+		startDB2j();
+		starter.boot(false,null);
+	}
+
+
+	/**
+	 * Start a network server
+	 *
+	 * @param consoleWriter   PrintWriter to which server console will be 
+	 *                        output. Null will disable console output.
+	 *
+	 *		   
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void blockingStart(PrintWriter consoleWriter)
+		throws Exception
+	{
+		startDB2j();
+		setLogWriter(consoleWriter);
+		cloudscapeLogWriter = Monitor.getStream().getPrintWriter();
+		if (SanityManager.DEBUG && debugOutput)
+		{
+			memCheck.showmem();
+			mc = new memCheck(200000);
+			mc.start();
+		}
+        // Open a server socket listener      
+	    try{
+	    	serverSocket = (ServerSocket) AccessController.doPrivileged(
+								new PrivilegedExceptionAction() {
+										public Object run() throws IOException,UnknownHostException
+										{
+											if (hostAddress == null)
+												hostAddress = InetAddress.getByName(hostArg);
+											// Make a list of valid
+											// InetAddresses for NetworkServerControl
+											// admin commands.
+											buildLocalAddressList(hostAddress);
+											return new ServerSocket(portNumber
+																	,0,
+																	hostAddress);
+										}
+									}
+								);
+		} catch (PrivilegedActionException e) {
+			Exception e1 = e.getException();
+	    	if (e1 instanceof IOException)
+            	consolePropertyMessage("DRDA_ListenPort.S", 
+									   new String [] {
+										   Integer.toString(portNumber), 
+										   hostArg}); 
+			if (e1 instanceof UnknownHostException) {
+				consolePropertyMessage("DRDA_UnknownHost.S", hostArg);
+			}
+			else
+				throw e1;
+		} catch (Exception e) {
+		// If we find other (unexpected) errors, we ultimately exit--so make
+		// sure we print the error message before doing so (Beetle 5033).
+			throwUnexpectedException(e);
+		}
+
+		consolePropertyMessage("DRDA_Ready.I", Integer.toString(portNumber));
+
+		// We accept clients on a separate thread so we don't run into a problem
+		// blocking on the accept when trying to process a shutdown
+		acceptClients = (Runnable)new ClientThread(this, serverSocket);
+		Thread clientThread =  (Thread) AccessController.doPrivileged(
+								new PrivilegedExceptionAction() {
+									public Object run() throws Exception
+									{
+										return new Thread(acceptClients);
+									}
+								}
+							);
+		clientThread.start();
+			
+		// wait until we are told to shutdown or someone sends an InterruptedException
+        synchronized(shutdownSync) {
+            try {
+				shutdownSync.wait();
+            }
+            catch (InterruptedException e)
+            {
+                shutdown = true;
+            }
+        }
+
+		// Need to interrupt the memcheck thread if it is sleeping.
+		if (mc != null)
+			mc.interrupt();
+
+		//interrupt client thread
+		clientThread.interrupt();
+
+ 		// Close out the sessions
+ 		synchronized(sessionTable) {
+ 			for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
+ 			{	
+ 				Session session = (Session) e.nextElement();
+ 				session.close();
+ 			}
+ 		}
+
+		synchronized (threadList)
+		{
+ 			//interupt any connection threads still active
+ 			for (int i = 0; i < threadList.size(); i++)
+ 			{
+ 				((DRDAConnThread)threadList.get(i)).close();
+ 				((DRDAConnThread)threadList.get(i)).interrupt();
+ 			}
+ 			threadList.clear();
+		}
+	   
+ 
+
+	
+	    // close the listener socket
+	    try{
+	       serverSocket.close();
+	    }catch(IOException e){
+			consolePropertyMessage("DRDA_ListenerClose.S");
+	    }
+
+
+		// Wake up those waiting on sessions, so
+		// they can close down
+		synchronized (runQueue) {
+			runQueue.notifyAll();
+		}						
+
+		/*
+		// Shutdown Cloudscape
+		try {
+			if (cloudscapeDriver != null)
+				cloudscapeDriver.connect("jdbc:derby:;shutdown=true", 
+										 (Properties) null);
+		} catch (SQLException sqle) {
+			// If we can't shutdown cloudscape. Perhaps authentication is
+			// set to true or some other reason. We will just print a
+			// message to the console and proceed.
+			if (((EmbedSQLException)sqle).getMessageId() !=
+			  SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN)
+				consolePropertyMessage("DRDA_ShutdownWarning.I",
+									   sqle.getMessage());
+		}
+		*/
+
+
+		consolePropertyMessage("DRDA_ShutdownSuccess.I");
+		
+
+    }
+	
+	/** 
+	 * Load Cloudscape and save driver for future use.
+	 * We can't call Driver Manager when the client connects, 
+	 * because they might be holding the DriverManager lock.
+	 *
+	 * 
+	 */
+
+	
+
+
+	protected void startDB2j() throws Exception
+	{
+
+		// we start the cloudscape server here.
+		boolean restartCheck = this.restartFlag;
+		synchronized (serverStartSync) {
+
+			if (restartCheck == this.restartFlag) {
+			// then we can go ahead and restart the server (odds
+			// that some else has just done so are very slim (but not
+			// impossible--however, even if it does happen, things
+			// should still work correctly, just not as efficiently...))
+
+				try {
+	
+					if (cleanupOnStart) {
+					// we're restarting the server (probably after a shutdown
+					// exception), so we need to clean up first.
+
+						// Close and remove sessions on runQueue.
+						for (int i = 0; i < runQueue.size(); i++)
+							((Session)runQueue.get(i)).close();
+						runQueue.clear();
+
+						// Close and remove DRDAConnThreads on threadList.
+						for (int i = 0; i < threadList.size(); i++)
+							((DRDAConnThread)threadList.get(i)).close();
+						threadList.clear();
+						freeThreads = 0;
+
+						// Unload driver, then restart the server.
+						cloudscapeDriver = null;	// so it gets collected.
+						System.gc();
+					}
+
+					// start the server.
+					Class.forName(CLOUDSCAPE_DRIVER).newInstance();
+					cloudscapeDriver = DriverManager.getDriver(Attribute.PROTOCOL);
+
+				}
+				catch (Exception e) {
+					consolePropertyMessage("DRDA_LoadException.S", e.getMessage());
+				}
+				cleanupOnStart = true;
+				this.restartFlag = !this.restartFlag;
+			}
+			// else, multiple threads hit this synchronize block at the same
+			// time, but one of them already executed it--so all others just
+			// return and do nothing (no need to restart the server multiple
+			// times in a row).
+		}
+	}
+
+	/**
+	 * Shutdown a network server
+	 *
+	 * @param host		machine network server is running on, if null, localhost is used
+	 * @param portNumber	port number server is to use, if <= 0, default port number
+	 *			is used
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void shutdown()
+		throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_SHUTDOWN);
+		send();
+		readResult();
+		// Wait up to 10 seconds for things to really shut down
+		// need a quiet ping so temporarily disable the logwriter
+		PrintWriter savWriter = logWriter;
+		setLogWriter(null);
+		int ntry;
+		for (ntry = 0; ntry < SHUTDOWN_CHECK_ATTEMPTS; ntry++)
+		{
+			Thread.sleep(SHUTDOWN_CHECK_INTERVAL);
+			try {
+				ping();
+			} catch (Exception e) 
+			{
+				// as soon as we can't ping return
+				if (ntry == SHUTDOWN_CHECK_ATTEMPTS)
+					consolePropertyMessage("DRDA_ShutdownError.S", new String [] {
+						Integer.toString(portNumber), 
+						hostArg}); 
+				break;
+			}
+		}
+		logWriter= savWriter;
+		return;
+	}
+
+	/*
+	 Shutdown the server directly (If you have the original object)
+	 No Network communication needed.
+	*/
+	public void directShutdown() 	{
+		shutdown = true;
+		synchronized(shutdownSync) {						
+			// wake up the server thread
+			shutdownSync.notifyAll();
+		}
+		
+	}
+
+
+	/**
+	 */
+	public boolean isServerStarted() throws Exception
+	{
+		try {
+			ping();
+		}
+		catch (Exception e) {
+			return false;
+		}
+		return true;
+	}
+
+	public void ping() throws Exception
+	{
+		// database no longer used, but don't change the protocol 
+		// in case we add
+		// authorization  later.
+		String database = null; // no longer used but don't change the protocol
+		String user = null;
+		String password = null;
+
+			setUpSocket();
+			writeCommandHeader(COMMAND_TESTCONNECTION);
+			writeLDString(database);
+			writeLDString(user);
+			writeLDString(password);
+			send();
+			readResult();
+
+	}
+
+
+	/**
+	 * Turn tracing on or off for all sessions
+	 *
+	 * @param on			true to turn tracing on, false to turn tracing off
+	 * @param host		machine network server is running on, if null, localhost is used
+	 * @param portNumber	port number server is to use, if <= 0, default port number
+	 *			is used
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void trace(boolean on)
+		throws Exception
+	{
+		trace(0, on);
+	}
+
+	/**
+	 * Turn tracing on or off for one session or all sessions
+	 *
+	 * @param connNum	the connNum of the session, 0 if all sessions
+	 * @param on			true to turn tracing on, false to turn tracing off
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void trace(int connNum, boolean on)
+		throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_TRACE);
+		commandOs.writeInt(connNum);
+		writeByte(on ? 1 : 0);
+		send();
+		readResult();
+		consoleTraceMessage(connNum, on);
+	}
+
+	/**
+	 * Print trace change message to console
+	 *
+	 * @param on			true to print tracing on, false to print tracing off
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private void consoleTraceMessage(int connNum, boolean on)
+		throws Exception
+	{
+		if (connNum == 0)
+			consolePropertyMessage("DRDA_TraceChangeAll.I", on ? "DRDA_ON.I" : "DRDA_OFF.I");
+		else
+		{
+			String[] args = new String[2];
+			args[0] = on ? "DRDA_ON.I" : "DRDA_OFF.I";
+			args[1] = new Integer(connNum).toString();
+			consolePropertyMessage("DRDA_TraceChangeOne.I", args);
+		}
+	}
+
+	/**
+	 * Turn logging connections on or off. When logging is turned on a message is
+	 * written to DB2j.log each time a connection connects or disconnects.
+	 *
+	 * @param on			true to turn on, false to turn  off
+	 * @param host		machine network server is running on, if null, localhost is used
+	 * @param portNumber	port number server is to use, if <= 0, default port number
+	 *			is used
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void logConnections(boolean on)
+		throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_LOGCONNECTIONS);
+		writeByte(on ? 1 : 0);
+		send();
+		readResult();
+	}
+
+	/**
+	 *@see NetworkServerControl#setTraceDirectory
+	 */
+	public void sendSetTraceDirectory(String traceDirectory)
+		throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_TRACEDIRECTORY);
+		writeLDString(traceDirectory);
+		send();
+		readResult();
+	}
+
+	/**
+	 *@see NetworkServerControl#getSysinfo
+	 */
+	public String sysinfo()
+		throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_SYSINFO);
+		send();
+		return readStringReply("DRDA_SysInfoError.S");
+	}
+
+	/**
+	 *@see NetworkServerControl#runtimeinfo
+	 */
+	public String runtimeInfo()
+	throws Exception 
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_RUNTIME_INFO);
+		send();
+		return readStringReply("DRDA_RuntimeInfoError.S");
+	}
+
+	/**
+	 * Display usage information
+	 *
+	 */
+	public void usage()
+	{
+		try {
+		for (int i = 1; i <= NO_USAGE_MSGS; i++)
+			consolePropertyMessage("DRDA_Usage"+i+".I");
+		} catch (Exception e) {}	// ignore exceptions - there shouldn't be any
+	}
+
+	/**
+	 * Set connection pool parameters for a database
+	 *
+	 * @param database	database parameters applied to
+	 * @param min		minimum number of connections, if 0, pooled connections not used
+	 *						if -1, use default						
+	 * @param max		maximum number of connections, if 0, pooled connections 
+	 *						created when no free connection available, if -1, 
+	 *						use default
+	 * @param host		machine network server is running on, if null, localhost is used
+	 * @param portNumber	port number server is to use, if <= 0, default port number
+	 *			is used
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	protected void setConnectionPoolParameters(String database, int min, int max,
+		String host, int portNumber)
+		throws Exception
+	{
+		consolePropertyMessage("DRDA_NotImplemented.S", "conpool");
+	}
+
+	/**
+	 * Set default connection pool parameters 
+	 *
+	 * @param min		minimum number of connections, if 0, pooled connections not used
+	 *						if -1, use default
+	 * @param max		maximum number of connections, if 0, pooled connections 
+	 *						created when no free connection available
+	 *						if -1, use default
+	 * @param host		machine network server is running on, if null, localhost is used
+	 * @param portNumber	port number server is to use, if <= 0, default port number
+	 *			is used
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	protected void setConnectionPoolParameters(int min, int max, String host, 
+			int portNumber) throws Exception
+	{
+		consolePropertyMessage("DRDA_NotImplemented.S", "conpool");
+	}
+
+	/**
+	 * Connect to  network server and set connection maxthread parameter
+	 *
+	 * @param max		maximum number of connections, if 0, connections 
+	 *						created when no free connection available
+	 *						if -1, use default
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void netSetMaxThreads(int max) throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_MAXTHREADS);
+		commandOs.writeInt(max);
+		send();
+		readResult();
+		int newval = readInt();
+		consolePropertyMessage("DRDA_MaxThreadsChange.I", 
+ 					new Integer(newval).toString());
+	}
+
+	/**
+	 * Set network server connection timeslice parameter
+	 *
+	 * @param timeslice	amount of time given to each session before yielding to 
+	 *						another session, if 0, never yield. if -1, use default.
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public void netSetTimeSlice(int timeslice)
+		throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_TIMESLICE);
+		commandOs.writeInt(timeslice);
+		send();
+		readResult();
+		int newval = readInt();
+		consolePropertyMessage("DRDA_TimeSliceChange.I", 
+									   new Integer(newval).toString());
+	}
+
+	/**
+	 * Get current properties
+	 *
+	 * @return Properties object containing properties
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	public Properties getCurrentProperties() 
+		throws Exception
+	{
+		setUpSocket();
+		writeCommandHeader(COMMAND_PROPERTIES);
+		send();
+		byte [] val = readBytesReply("DRDA_PropertyError.S");
+		Properties p = new Properties();
+		try {
+			ByteArrayInputStream bs = new ByteArrayInputStream(val);
+			p.load(bs);
+		} catch (IOException io) {
+			consolePropertyMessage("DRDA_IOException.S", 
+						io.getMessage());
+		}
+		return p;
+	}
+
+	/**
+	 * Set a thread name to be something that is both meaningful and unique (primarily
+	 * for debugging purposes).
+	 *
+	 * @param thrd An instance of a Thread object that still has its default
+	 *  thread name (as generated by the jvm Thread constructor).  This should
+	 *  always be of the form "Thread-N", where N is a unique thread id
+	 *  generated by the jvm.  Ex. "Thread-0", "Thread-1", etc.
+	 *
+	 * @return The received thread's name has been set to a new string of the form
+	 *  [newName + "_n"], where 'n' is a unique thread id originally generated
+	 *  by the jvm Thread constructor.  If the default name of the thread has
+	 *  been changed before getting here, then nothing is done.
+	 *
+	 **/
+	public static void setUniqueThreadName(Thread thrd, String newName) {
+
+		// First, pull off the unique thread id already found in thrd's default name;
+		// we do so by searching for the '-' character, and then counting everything
+		// after it as a N.
+		if (thrd.getName().indexOf("Thread-") == -1) {
+		// default name has been changed; don't do anything.
+			return;
+		}
+		else {
+			String oldName = thrd.getName();
+			thrd.setName(newName + "_" +
+			  oldName.substring(oldName.indexOf("-")+1, oldName.length()));
+		} // end else.
+
+		return;
+
+	}
+
+	/*******************************************************************************/
+	/*        Protected methods                                                    */
+	/*******************************************************************************/
+	/**
+	 * Remove session from session table
+	 *
+	 * @param sessionid 	id of session to be removed
+	 */
+	protected void removeFromSessionTable(int sessionid)
+	{
+		sessionTable.remove(new Integer(sessionid));
+	}
+
+	/**
+	 * 	processCommands reads and processes DB2jServerImpl commands sent
+	 * 	to the network server over the socket.  The protocol used is
+	 * 		4 bytes 	- String CMD:
+	 * 		2 bytes		- Protocol version
+	 *		1 byte		- length of locale (0 for default)
+	 *			n bytes - locale
+	 *		1 byte		- length of codeset (0 for default)
+	 *			n bytes - codeset
+	 * 		1 byte		- command
+	 * 		n bytes		- parameters for the command
+	 * 	The server returns
+	 *		4 bytes		- String RPY:
+	 *	for most commands
+	 *		1 byte		- command result, 0 - OK, 1 - warning, 2 - error
+	 *	 if warning or error
+	 *		1 bytes		- length of message key
+	 *		n bytes		- message key
+	 *		1 byte		- number of parameters to message
+	 *		{2 bytes		- length of parameter
+	 *		n bytes		- parameter} for each parameter
+	 *  for sysinfo
+	 *		1 byte		- command result, 0 - OK, 1 - warning, 2 - error
+	 *   if OK 
+	 *		2 bytes		- length of sysinfo
+	 *		n bytes		- sysinfo
+	 *		
+	 * 		
+	 * 	Note, the 3rd byte of the command must not be 'D0' to distinquish it 
+	 *	from DSS structures.
+	 * 	The protocol for the parameters for each command follows:
+	 *
+	 * 	Command: trace <connection id> {on | off}
+	 * 	Protocol:
+	 * 		4 bytes		- connection id - connection id of 0 means all sessions
+	 * 		1 byte		- 0 off, 1 on
+	 * 
+	 * 	Command: logConnections {on | off}
+	 * 	Protocol:
+	 * 		1 byte		- 0 off, 1 on
+	 * 
+	 * 	Command: shutdown
+	 * 	No parameters
+	 * 
+	 * 	Command: sysinfo
+	 * 	No parameters
+	 * 
+	 * 	Command: dbstart
+	 * 	Protocol:
+	 * 		2 bytes		- length of database name
+	 * 		n bytes		- database name
+	 * 		2 bytes		- length of boot password
+	 * 		n bytes		- boot password 
+	 * 		2 bytes		- length of encryption algorithm
+	 * 		n bytes		- encryption algorithm
+	 * 		2 bytes		- length of encryption provider
+	 * 		n bytes		- encryption provider
+	 * 		2 bytes		- length of user name
+	 * 		n bytes		- user name
+	 * 		2 bytes		- length of password
+	 * 		n bytes		- password
+	 *
+	 * 	Command: dbshutdown
+	 * 	Protocol:
+	 * 		2 bytes		- length of database name
+	 * 		n bytes		- database name
+	 * 		2 bytes		- length of user name
+	 * 		n bytes		- user name
+	 * 		2 bytes		- length of password
+	 * 		n bytes		- password
+	 *
+	 * 	Command: connpool
+	 * 	Protocol:
+	 * 		2 bytes		- length of database name, if 0, default for all databases
+	 *						is set
+	 * 		n bytes		- database name
+	 *		2 bytes		- minimum number of connections, if 0, connection pool not used
+	 *						if value is -1 use default
+	 *		2 bytes		- maximum number of connections, if 0, connections are created
+	 *						as needed, if value is -1 use default
+	 *
+	 * 	Command: maxthreads
+	 * 	Protocol:
+	 *		2 bytes		- maximum number of threads
+	 *
+	 * 	Command: timeslice 
+	 * 	Protocol:
+	 *		4 bytes		- timeslice value
+	 *
+	 * 	Command: tracedirectory
+	 * 	Protocol:
+	 * 		2 bytes		- length of directory name
+	 * 		n bytes		- directory name
+	 *
+	 *	Command: test connection
+	 * 	Protocol:
+	 * 		2 bytes		- length of database name if 0, just the connection
+	 *						to the network server is tested and user name and 
+	 *						password aren't sent
+	 * 		n bytes		- database name
+	 * 		2 bytes		- length of user name (optional)
+	 * 		n bytes		- user name
+	 * 		2 bytes		- length of password  (optional)
+	 * 		n bytes		- password
+	 *
+	 *	The calling routine is synchronized so that multiple threads don't clobber each
+	 * 	other. This means that configuration commands will be serialized.
+	 * 	This shouldn't be a problem since they should be fairly rare.
+	 * 		
+	 * @param reader	input reader for command
+	 * @param writer output writer for command
+	 * @param session	session information
+	 *
+	 * @exception Throwable	throws an exception if an error occurs
+	 */
+	protected synchronized void processCommands(DDMReader reader, DDMWriter writer, 
+		Session session) throws Throwable
+	{
+		try {
+			String protocolStr = reader.readCmdString(4);
+			String locale = DEFAULT_LOCALE;
+			String codeset = null;
+			// get the version
+			int version = reader.readNetworkShort();
+			if (version <= 0 || version > PROTOCOL_VERSION)
+				throw new Throwable(langUtil.getTextMessage("DRDA_UnknownProtocol.S",  new Integer(version).toString()));
+			int localeLen = reader.readByte();
+			if (localeLen > 0)
+			{
+				currentSession = session;
+				locale = reader.readCmdString(localeLen);
+				session.langUtil = new LocalizedResource(codeset,locale,DRDA_PROP_MESSAGES);
+			}
+			String notLocalMessage = null;
+			// for now codesetLen is always 0
+			int codesetLen = reader.readByte();
+			int command = reader.readByte();
+			if (command !=  COMMAND_TESTCONNECTION)
+			{
+				try {
+					checkAddressIsLocal(session.clientSocket.getInetAddress());
+				}catch (Exception e)
+				{
+					notLocalMessage = e.getMessage();
+				}
+			}
+			if (notLocalMessage != null)
+			{
+				sendMessage(writer, ERROR,notLocalMessage);
+				session.langUtil = null;
+				currentSession = null;
+				return;
+			}
+
+			switch(command)
+			{
+				case COMMAND_SHUTDOWN:
+					sendOK(writer);
+					directShutdown();
+					break;
+				case COMMAND_TRACE:
+					sessionArg = reader.readNetworkInt();
+					boolean on = (reader.readByte() == 1);
+					if (setTrace(on))
+					{
+						sendOK(writer);
+					}
+					else
+					{
+						sendMessage(writer, ERROR,  
+							localizeMessage("DRDA_SessionNotFound.U", 
+							(session.langUtil == null) ? langUtil : session.langUtil,
+							new String [] {new Integer(sessionArg).toString()}));
+					}
+					break;
+				case COMMAND_TRACEDIRECTORY:
+					setTraceDirectory(reader.readCmdString());
+					sendOK(writer);
+					consolePropertyMessage("DRDA_TraceDirectoryChange.I", traceDirectory);
+					break;
+				case COMMAND_TESTCONNECTION:
+					databaseArg = reader.readCmdString();
+					userArg = reader.readCmdString();
+					passwordArg = reader.readCmdString();
+					if (databaseArg != null)
+						connectToDatabase(writer, databaseArg, userArg, passwordArg);
+					else
+						sendOK(writer);
+					break;
+				case COMMAND_LOGCONNECTIONS:
+					boolean log = (reader.readByte() == 1);
+					setLogConnections(log);
+					sendOK(writer);
+					consolePropertyMessage("DRDA_LogConnectionsChange.I",
+						(log ? "DRDA_ON.I" : "DRDA_OFF.I"));
+					break;
+				case COMMAND_SYSINFO:
+					sendSysInfo(writer);
+					break;
+				case COMMAND_PROPERTIES:
+					sendPropInfo(writer);
+					break;
+				case COMMAND_RUNTIME_INFO:
+					sendRuntimeInfo(writer);
+					break;
+				case COMMAND_MAXTHREADS:
+					int max = reader.readNetworkInt();
+					try {
+						setMaxThreads(max);
+					}catch (Exception e) {
+						sendMessage(writer, ERROR, e.getMessage());
+						return;
+					}
+					int newval = getMaxThreads();
+					sendOKInt(writer, newval);
+					consolePropertyMessage("DRDA_MaxThreadsChange.I", 
+						new Integer(newval).toString());
+					break;
+				case COMMAND_TIMESLICE:
+					int timeslice = reader.readNetworkInt();
+					try {
+						setTimeSlice(timeslice);
+					}catch (Exception e) {
+						sendMessage(writer, ERROR, e.getMessage());
+						return;
+					}
+					newval = getTimeSlice();
+					sendOKInt(writer, newval);
+					consolePropertyMessage("DRDA_TimeSliceChange.I", 
+						new Integer(newval).toString());
+					break;
+			}
+		} catch (DRDAProtocolException e) {
+			//we need to handle this since we aren't in DRDA land here
+			consoleExceptionPrintTrace(e);
+
+		} catch (Exception e) {
+			consoleExceptionPrintTrace(e);
+		}
+		finally {
+			session.langUtil = null;
+			currentSession = null;
+		}
+	}
+	/**
+	 * Get the next session for the thread to work on
+	 * Called from DRDAConnThread after session completes or timeslice
+	 * exceeded.   
+	 *
+	 * If there is a waiting session, pick it up and put currentSession 
+	 * at the back of the queue if there is one.
+	 * @param currentSession	session thread is currently working on
+	 *
+	 * @return  next session to work on, could be same as current session
+	 */
+	protected Session getNextSession(Session currentSession)
+	{
+		Session retval = null;
+		if (shutdown == true)
+			return retval;
+		try {
+			synchronized (runQueue)
+			{
+				// nobody waiting - go on with current session
+				if (runQueue.size() == 0)
+				{
+					// no current session - wait for some work
+					if (currentSession == null)
+					{
+						while (runQueue.size() == 0)
+						{
+							// This thread has nothing to do now so 
+							// we will add it to freeThreads
+							freeThreads++;
+							runQueue.wait();
+							if (shutdown == true)
+								return null;
+							freeThreads--;
+						}
+					}
+					else
+						return currentSession;
+				}
+				retval = (Session) runQueue.elementAt(0);
+				runQueue.removeElementAt(0);
+				if (currentSession != null)
+					runQueueAdd(currentSession);
+			}
+		}catch (InterruptedException e) {}
+		return retval;
+	}
+	/**
+	 * Get the stored application requester or store if we haven't seen it yet
+	 *
+	 * @param appRequester Application Requester to look for
+	 *
+	 * @return  stored application requester
+	 */
+	protected AppRequester getAppRequester(AppRequester appRequester)
+	{
+		AppRequester s = null;
+
+		if (SanityManager.DEBUG) {
+			if (appRequester == null)
+				SanityManager.THROWASSERT("null appRequester in getAppRequester");
+		}
+
+		if (!appRequesterTable.isEmpty())
+			s = (AppRequester)appRequesterTable.get(appRequester.prdid);
+
+		if (s == null)
+		{
+			appRequesterTable.put(appRequester.prdid, appRequester);
+			return appRequester;
+		}
+		else
+		{
+			//compare just in case there are some differences
+			//if they are different use the one we just read in
+			if (s.equals(appRequester))
+				return s;
+			else
+				return appRequester;
+		}
+	}
+	/**
+	 * Get the server manager level for a given manager
+	 *
+	 * @param manger codepoint for manager
+	 * @return manager level
+	 */
+	protected int getManagerLevel(int manager)
+	{
+		int mindex = CodePoint.getManagerIndex(manager);
+		if (SanityManager.DEBUG) {
+			if (mindex == CodePoint.UNKNOWN_MANAGER)
+			SanityManager.THROWASSERT("manager out of bounds");
+		}
+		return MGR_LEVELS[mindex];
+	}
+	/**
+	 * Check whether a CCSID code page is supported
+	 *
+	 * @param CCSID to check
+	 * @return true if supported; false otherwise
+	 */
+	protected boolean supportsCCSID(int ccsid)
+	{
+		try {
+			CharacterEncodings.getJavaEncoding(ccsid);
+			}
+		catch (Exception e) {
+			return false;
+		}
+		return true;
+	}
+	/**
+	 * Put property message on console
+	 *
+	 * @param msgProp		message property key
+	 *
+	 * @exception throws an Exception if an error occurs
+	 */
+	protected void consolePropertyMessage(String msgProp)
+		throws Exception
+	{
+		consolePropertyMessageWork(msgProp, null);
+	}
+	/**
+	 * Put property message on console
+	 *
+	 * @param msgProp		message property key
+	 * @param arg			argument for message
+	 *
+	 * @exception throws an Exception if an error occurs
+	 */
+	protected void consolePropertyMessage(String msgProp, String arg)
+		throws Exception
+	{
+		consolePropertyMessageWork(msgProp, new String [] {arg});
+	}
+	/**
+	 * Put property message on console
+	 *
+	 * @param msgProp		message property key
+	 * @param args			argument array for message
+	 *
+	 * @exception throws an Exception if an error occurs
+	 */
+	protected void consolePropertyMessage(String msgProp, String [] args)
+		throws Exception
+	{
+		consolePropertyMessageWork(msgProp, args);
+	}
+	/**
+	 * Is this the command protocol
+	 * 
+	 * @param  val
+	 */
+	protected static boolean isCmd(String val)
+	{
+		if (val.equals(COMMAND_HEADER))
+			return true;
+		else
+			return false;
+	}
+
+	/*******************************************************************************/
+	/*        Private methods                                                      */
+	/*******************************************************************************/
+	/**
+	 * Write Command reply
+	 *
+	 * @param writer	writer to use 
+	 *
+	 * @exception	throws Exception if a problem occurs sending OK
+	 */
+	private void writeCommandReplyHeader(DDMWriter writer) throws Exception
+	{
+		writer.setCMDProtocol();
+		writer.writeString(REPLY_HEADER);
+	}
+	 
+	/**
+	 * Send OK from server to client after processing a command
+	 *
+	 * @param writer	writer to use for sending OK
+	 *
+	 * @exception	throws Exception if a problem occurs sending OK
+	 */
+	private void sendOK(DDMWriter writer) throws Exception
+	{
+		writeCommandReplyHeader(writer);
+		writer.writeByte(OK);
+		writer.flush();
+	}
+	/**
+	 * Send OK and int value
+	 *
+	 * @param writer writer to use for sending
+	 * @param val 	int val to send
+	 * 
+	 * @exception throws Exception if a problem occurs
+	 */
+	private void sendOKInt(DDMWriter writer, int val) throws Exception
+	{
+		writeCommandReplyHeader(writer);
+		writer.writeByte(OK);
+		writer.writeNetworkInt(val);
+		writer.flush();
+	}
+	/**
+	 * Send Error or Warning from server to client after processing a command
+	 *
+	 * @param writer	writer to use for sending message
+	 * @param messageType	1 for Warning, 2 for Error 3 for SQLError
+	 * @param message 	message 
+	 *
+	 * @exception	throws Exception if a problem occurs sending message
+	 */
+	private void sendMessage(DDMWriter writer, int messageType, String message) 
+		throws Exception
+	{
+		writeCommandReplyHeader(writer);
+		writer.writeByte(messageType);
+		writer.writeLDString(message);
+		writer.flush();
+	}
+	/**
+	 * Send SQL Exception from server to client after processing a command
+	 *
+	 * @param writer	writer to use for sending message
+	 * @param se		Cloudscape exception
+	 * @param type		type of exception, SQLERROR or SQLWARNING
+	 *
+	 * @exception	throws Exception if a problem occurs sending message
+	 */
+	private void sendSQLMessage(DDMWriter writer, SQLException se, int type)
+		throws Exception
+	{
+		StringBuffer locMsg = new StringBuffer();
+		//localize message if necessary
+		while (se != null)
+		{
+			if (currentSession != null && currentSession.langUtil != null)
+			{
+				locMsg.append(se.getSQLState()+":"+ 
+					MessageService.getLocalizedMessage(
+					currentSession.langUtil.getLocale(), ((EmbedSQLException)se).getMessageId(), 
+					((EmbedSQLException)se).getArguments()));
+			}
+			else
+				locMsg.append(se.getSQLState()+":"+se.getMessage());
+			se = se.getNextException();
+			if (se != null)
+				locMsg.append("\n");
+		}
+		sendMessage(writer, type, locMsg.toString());
+	}
+	/**
+	 * Send SysInfo information from server to client
+	 *
+	 * @param writer 	writer to use for sending sysinfo
+	 *
+	 * @exception throws Exception if a problem occurs sending value
+	 */
+	private void sendSysInfo(DDMWriter writer) throws Exception
+	{
+		StringBuffer sysinfo = new StringBuffer();
+		sysinfo.append(getNetSysInfo());
+		sysinfo.append(getCLSSysInfo());
+		try {
+			writeCommandReplyHeader(writer);
+			writer.writeByte(0);	//O.K.
+			writer.writeLDString(sysinfo.toString());
+		} catch (DRDAProtocolException e) {
+			consolePropertyMessage("DRDA_SysInfoWriteError.S", e.getMessage());
+		}
+		writer.flush();
+	}
+	
+	/**
+	 * Send RuntimeInfo information from server to client
+	 *
+	 * @param writer 	writer to use for sending sysinfo
+	 *
+	 * @exception throws Exception if a problem occurs sending value
+	 */
+	private void sendRuntimeInfo(DDMWriter writer) throws Exception
+	{
+		try {
+			writeCommandReplyHeader(writer);
+			writer.writeByte(0);	//O.K.
+			writer.writeLDString(getRuntimeInfo());
+				} catch (DRDAProtocolException e) {
+			consolePropertyMessage("DRDA_SysInfoWriteError.S", e.getMessage());
+		}
+		writer.flush();
+	}
+
+	
+
+	/**
+	 * Send property information from server to client
+	 *
+	 * @param writer 	writer to use for sending sysinfo
+	 *
+	 * @exception throws Exception if a problem occurs sending value
+	 */
+	private void sendPropInfo(DDMWriter writer) throws Exception
+	{
+		try {
+			ByteArrayOutputStream out = new ByteArrayOutputStream();
+			Properties p = getPropertyValues();
+			p.store(out, "NetworkServerControl properties");
+			try {
+				writeCommandReplyHeader(writer);
+				writer.writeByte(0);		//O.K.
+				writer.writeLDBytes(out.toByteArray());
+			} catch (DRDAProtocolException e) {
+				consolePropertyMessage("DRDA_PropInfoWriteError.S", e.getMessage());
+			}
+			writer.flush();
+		} 
+		catch (Exception e) {
+			consoleExceptionPrintTrace(e);
+		}
+	}
+
+	/**
+	 * Get Net Server information
+	 *
+	 * @return system information for the Network Server
+	 */
+	private String getNetSysInfo() 
+	{
+		StringBuffer sysinfo = new StringBuffer();
+		LocalizedResource localLangUtil = langUtil;
+		if (currentSession != null && currentSession.langUtil != null)
+		localLangUtil = currentSession.langUtil;
+		sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBanner.I")+ "\n");
+		sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoVersion.I")+ " " + att_srvrlslv);
+		sysinfo.append("  ");
+		sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBuild.I")+ " " + buildNumber);
+		sysinfo.append("  ");
+		sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoDrdaPRDID.I")+ " " + prdId);
+		if (SanityManager.DEBUG)
+		{
+			sysinfo.append("  ** SANE BUILD **");
+		}
+		sysinfo.append("\n");
+		// add property information
+		Properties p = getPropertyValues();
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		PrintStream ps =  new PrintStream(bos);
+		p.list(ps);
+		sysinfo.append(bos.toString());
+		return sysinfo.toString();
+	}
+
+	/**
+	 * @see NetworkServerControl#getRuntimeInfo
+	 */
+	private String getRuntimeInfo() 
+	{
+		return buildRuntimeInfo(langUtil);
+	}
+
+	/**
+	 * Get Cloudscape information
+	 *
+	 * @return system information for Cloudscape
+	 *
+	 * @exception throws IOException if a problem occurs encoding string
+	 */
+	private String getCLSSysInfo() throws IOException
+	{
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		LocalizedResource localLangUtil = langUtil;
+		if (currentSession != null && currentSession.langUtil != null)
+		localLangUtil = currentSession.langUtil;
+		LocalizedOutput aw = localLangUtil.getNewOutput(bos);
+		org.apache.derby.impl.tools.sysinfo.Main.getMainInfo(aw, false);
+		return bos.toString();
+	}
+
+	/**
+	 * Execute the command given on the command line
+	 *
+	 * @param args	array of arguments indicating command to be executed
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 * see class comments for more information
+	 */
+	public static void execute(String args[]) 
+	{
+		DB2jServerImpl server = null;
+		try {
+			server = new DB2jServerImpl();
+			server.executeWork(args);
+		} catch (Exception e){
+			//if there was an error, exit(1)
+			if ((e.getMessage() == null) ||
+				!e.getMessage().equals(DB2jServerImpl.UNEXPECTED_ERR))
+			{
+				if (server != null)
+					server.consoleExceptionPrint(e);
+				else
+					e.printStackTrace();  // default output stream is System.out
+			}
+			// else, we've already printed a trace, so just exit.
+			System.exit(1);
+		}
+		System.exit(0);
+	}
+
+
+	/**
+	 * Execute the command given on the command line
+	 *
+	 * @param args	array of arguments indicating command to be executed
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 * see class comments for more information
+	 */
+	protected void executeWork(String args[]) throws Exception
+	{
+		// For convenience just use DB2jServerImpls log writer for user messages
+		logWriter = makePrintWriter(System.out);
+		
+		int command = 0; 
+		if (args.length > 0)
+			command = findCommand(args);
+		else
+		{
+			consolePropertyMessage("DRDA_NoArgs.U");
+		}
+
+		// if we didn't have a valid command just return - error already generated
+		if (command == COMMAND_UNKNOWN)
+			return;
+
+		// check that we have the right number of required arguments
+		if (commandArgs.size() != COMMAND_ARGS[command])
+			consolePropertyMessage("DRDA_InvalidNoArgs.U", COMMANDS[command]);
+		int min;
+		int max;
+
+
+		switch (command)
+		{
+			case COMMAND_START:
+				blockingStart(makePrintWriter(System.out));
+				break;
+			case COMMAND_SHUTDOWN:
+				shutdown();
+				consolePropertyMessage("DRDA_ShutdownSuccess.I");
+				break;
+			case COMMAND_TRACE:
+				{
+					boolean on = isOn((String)commandArgs.elementAt(0));
+					trace(sessionArg, on);
+					consoleTraceMessage(sessionArg, on);
+					break;
+				}
+			case COMMAND_TRACEDIRECTORY:
+				setTraceDirectory((String) commandArgs.elementAt(0));
+				consolePropertyMessage("DRDA_TraceDirectoryChange.I", traceDirectory);
+				break;
+			case COMMAND_TESTCONNECTION:
+				ping();
+				consolePropertyMessage("DRDA_ConnectionTested.I", new String [] 
+					{hostArg, (new Integer(portNumber)).toString()});
+				break;
+			case COMMAND_LOGCONNECTIONS:
+				{
+					boolean on = isOn((String)commandArgs.elementAt(0));
+					logConnections(on);
+					consolePropertyMessage("DRDA_LogConnectionsChange.I", on ? "DRDA_ON.I" : "DRDA_OFF.I");
+					break;
+				}
+			case COMMAND_SYSINFO:
+				{
+					String info = sysinfo();
+					consoleMessage(info);
+					break;
+				}
+			case COMMAND_MAXTHREADS:
+				max = 0;
+				try{
+					max = Integer.parseInt((String)commandArgs.elementAt(0));
+				}catch(NumberFormatException e){
+					consolePropertyMessage("DRDA_InvalidValue.U", new String [] 
+						{(String)commandArgs.elementAt(0), "maxthreads"});
+				}
+				if (max < MIN_MAXTHREADS)
+					consolePropertyMessage("DRDA_InvalidValue.U", new String [] 
+						{new Integer(max).toString(), "maxthreads"});
+				netSetMaxThreads(max);
+
+				break;
+			case COMMAND_RUNTIME_INFO:
+				String reply = runtimeInfo();
+				consoleMessage(reply);
+				break;
+			case COMMAND_TIMESLICE:
+				int timeslice = 0;
+				String timeSliceArg = (String)commandArgs.elementAt(0);
+            	try{
+                	timeslice = Integer.parseInt(timeSliceArg);
+            	}catch(NumberFormatException e){
+					consolePropertyMessage("DRDA_InvalidValue.U", new String [] 
+						{(String)commandArgs.elementAt(0), "timeslice"});
+            	}
+				if (timeslice < MIN_TIMESLICE)
+					consolePropertyMessage("DRDA_InvalidValue.U", new String [] 
+						{new Integer(timeslice).toString(), "timeslice"});
+				netSetTimeSlice(timeslice);
+				
+				break;
+			default:
+				//shouldn't get here
+				if (SanityManager.DEBUG)
+					SanityManager.THROWASSERT("Invalid command in switch:"+ command);
+		}
+	}
+
+  
+	/**
+	 * Add session to the run queue
+	 *
+	 * @param clientSession	session needing work
+	 */
+	protected void runQueueAdd(Session clientSession)
+	{
+		synchronized(runQueue)
+		{
+			runQueue.addElement(clientSession);
+			runQueue.notify();
+		}
+	}
+	/**
+	 * Go through the arguments and find the command and save the dash arguments
+	 *	and arguments to the command.  Only one command is allowed in the argument
+	 *	list.
+	 *
+	 * @param args	arguments to search
+	 *
+	 * @return  command
+	 */
+	private int findCommand(String [] args) throws Exception
+	{
+		try {
+			// process the dashArgs and pull out the command args 
+			int i = 0;
+			int newpos = 0;
+			while (i < args.length)
+			{
+				if (args[i].startsWith("-"))
+				{
+					newpos = processDashArg(i, args);
+					if (newpos == i)
+						commandArgs.addElement(args[i++]);
+					else
+						i = newpos;
+				}
+				else
+					commandArgs.addElement(args[i++]);
+			}
+					
+			// look up command
+			if (commandArgs.size() > 0)
+			{
+				for (i = 0; i < COMMANDS.length; i++)
+				{
+					if (StringUtil.SQLEqualsIgnoreCase(COMMANDS[i], 
+													   (String)commandArgs.firstElement()))
+					{
+						commandArgs.removeElementAt(0);
+						return i;
+					}
+				}
+			}
+			// didn't find command
+			consolePropertyMessage("DRDA_UnknownCommand.U", 
+				(String) commandArgs.firstElement());
+		} catch (Exception e) {
+			if (e.getMessage().equals(DB2jServerImpl.UNEXPECTED_ERR))
+				throw e;
+			//Ignore expected exceptions, they will have been
+									//handled by the consolePropertyMessage routine
+		}
+		return COMMAND_UNKNOWN;
+	}
+	/**
+	 * Get the dash argument. Optional arguments are formated as -x value.
+	 *
+	 * @param pos	starting point
+	 * @param args	arguments to search
+	 *
+	 * @return  command
+	 *
+	 * @exception Exception	thrown if an error occurs
+	 */
+	private int processDashArg(int pos, String[] args)
+		throws Exception
+	{
+		//check for a negative number
+		char c = args[pos].charAt(1);
+		if (c >= '0' && c <= '9')
+			return pos;
+		int dashArg = -1;
+		for (int i = 0; i < DASHARGS.length; i++)
+		{
+			if (DASHARGS[i].equals(args[pos].substring(1)))
+			{
+				dashArg = i;
+				pos++;
+				break;
+			}
+		}
+		if (dashArg == -1)
+			consolePropertyMessage("DRDA_UnknownArgument.U", args[pos]);
+		switch (dashArg)
+		{
+			case DASHARG_PORT:
+				if (pos < args.length)
+				{
+            		try{
+                		portNumber = Integer.parseInt(args[pos]);
+            		}catch(NumberFormatException e){
+						consolePropertyMessage("DRDA_InvalidValue.U", 
+							new String [] {args[pos], "DRDA_PortNumber.I"});
+            		}
+				}
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", "DRDA_PortNumber.I");
+				break;
+			case DASHARG_HOST:
+				if (pos < args.length)
+				{
+					hostArg = args[pos];
+				}
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", "DRDA_Host.I");
+				break;
+			case DASHARG_DATABASE:
+				if (pos < args.length)
+					databaseArg = args[pos];
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", 
+						"DRDA_DatabaseDirectory.I");
+				break;
+			case DASHARG_USER:
+				if (pos < args.length)
+				{
+					userArg = args[pos++];
+					if (pos < args.length)
+						passwordArg = args[pos];
+					else
+						consolePropertyMessage("DRDA_MissingValue.U", 
+							"DRDA_Password.I");
+				}
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", "DRDA_User.I");
+				break;
+			case DASHARG_ENCALG:
+				if (pos < args.length)
+					encAlgArg = args[pos];
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", 
+						"DRDA_EncryptionAlgorithm.I");
+				break;
+			case DASHARG_ENCPRV:
+				if (pos < args.length)
+					encPrvArg = args[pos];
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", 
+						"DRDA_EncryptionProvider.I");
+				break;
+			case DASHARG_LOADSYSIBM:
+				break;
+			case DASHARG_SESSION:
+				if (pos < args.length)
+            		try{
+                		sessionArg = Integer.parseInt(args[pos]);
+            		}catch(NumberFormatException e){
+						consolePropertyMessage("DRDA_InvalidValue.U", 
+							new String [] {args[pos], "DRDA_Session.I"});
+            		}
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", "DRDA_Session.I");
+				break;
+			default:
+				//shouldn't get here
+		}
+		return pos+1;
+	}
+
+	/**
+	 * Is string "on" or "off"
+	 *
+	 * @param string	string to check
+	 *
+	 * @return  true if string is "on", false if string is "off"
+	 *
+	 * @exception Exception	thrown if string is not one of "on" or "off"
+	 */
+	private boolean isOn(String arg)
+		throws Exception
+	{
+		if (StringUtil.SQLEqualsIgnoreCase(arg, "on"))
+			return true;
+		else if (!StringUtil.SQLEqualsIgnoreCase(arg, "off"))
+			consolePropertyMessage("DRDA_OnOffValue.U", arg);
+		return false;
+	}
+
+	/**
+	 * Set up client socket to send a command to the network server
+	 *
+   	 * @exception Exception	thrown if exception encountered
+	 */
+	private void setUpSocket() throws Exception
+	{
+		
+		try {
+            clientSocket = (Socket) AccessController.doPrivileged(
+								new PrivilegedExceptionAction() {
+										
+									public Object run() throws UnknownHostException,IOException
+									{
+										if (hostAddress == null)
+											hostAddress = InetAddress.getByName(hostArg);
+
+										// JDK131 can't connect with a client
+										// socket with 0.0.0.0 (all addresses) so we will
+										// getLocalHost() which will suffice.
+										InetAddress connectAddress;
+										if (JVMInfo.JDK_ID < 4 &&
+											hostAddress.getHostAddress().equals("0.0.0.0"))
+											connectAddress = InetAddress.getLocalHost();
+										else
+											connectAddress = hostAddress;
+
+										return new Socket(connectAddress, portNumber);
+									}
+								}
+							);
+		} catch (PrivilegedActionException pae) {
+			Exception e1 = pae.getException();
+        	if (e1 instanceof UnknownHostException) {
+					consolePropertyMessage("DRDA_UnknownHost.S", hostArg);
+			}
+        	else if (e1 instanceof IOException) {
+					consolePropertyMessage("DRDA_NoIO.S",
+						new String [] {hostArg, (new Integer(portNumber)).toString()});
+			}
+		} catch (Exception e) {
+		// If we find other (unexpected) errors, we ultimately exit--so make
+		// sure we print the error message before doing so (Beetle 5033).
+			throwUnexpectedException(e);
+		}
+
+        try
+        {
+	       clientIs = clientSocket.getInputStream();
+	       clientOs = clientSocket.getOutputStream();
+		} catch (IOException e) {
+			consolePropertyMessage("DRDA_NoInputStream.I");
+			throw e;
+        }
+	}
+
+	
+	private void checkAddressIsLocal(InetAddress inetAddr) throws UnknownHostException,Exception
+	{
+		for(int i = 0; i < localAddresses.size(); i++)
+		{
+			if (inetAddr.equals((InetAddress)localAddresses.get(i)))
+			{
+				return;
+			}
+		}
+		consolePropertyMessage("DRDA_NeedLocalHost.S", new String[] {inetAddr.getHostName(),serverSocket.getInetAddress().getHostName()});
+
+	}
+
+
+	/**
+	 * Build local address list to allow admin commands.
+	 *
+	 * @param bindAddr Address on which server was started
+	 * 
+	 * Note: Some systems may not support localhost.
+	 * In that case a console message will print for the localhost entries,
+	 * but the server will continue to start.
+	 **/
+	private void buildLocalAddressList(InetAddress bindAddr) 
+	{
+			localAddresses = new ArrayList(3);
+			localAddresses.add(bindAddr);
+			try {
+				localAddresses.add(InetAddress.getLocalHost());
+				localAddresses.add(InetAddress.getByName("localhost"));
+			}catch(UnknownHostException uhe)
+			{
+				try {
+					consolePropertyMessage("DRDA_UnknownHostWarning.I",uhe.getMessage());
+				} catch (Exception e)
+				{ // just a warning shouldn't actually throw an exception
+				}
+			}			
+	}
+	
+	/**
+	 * Routines for writing commands for DB2jServerImpl being used as a client
+	 * to a server
+	 */
+
+	/**
+	 * Write command header consisting of command header string and protocol
+	 * version and command
+	 *
+	 * @param command	command to be written
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private void writeCommandHeader(int command) throws Exception
+	{
+		try {
+			writeString(COMMAND_HEADER);
+			commandOs.writeByte((byte)((PROTOCOL_VERSION & 0xf0) >> 8 ));
+			commandOs.writeByte((byte)(PROTOCOL_VERSION & 0x0f));
+
+			if (clientLocale != null && clientLocale != DEFAULT_LOCALE)
+			{
+				commandOs.writeByte(clientLocale.length());
+				commandOs.writeBytes(clientLocale);
+			}
+			else
+				commandOs.writeByte((byte) 0);
+			commandOs.writeByte((byte) 0);
+			commandOs.writeByte((byte) command);
+		}
+		catch (IOException e)
+		{
+			clientSocketError(e);
+		}
+	}
+	/**
+	 * Write length delimited string string
+	 *
+	 * @param msg	string to be written
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private void writeLDString(String msg) throws Exception
+	{
+		try {
+			if (msg == null)
+			{
+				commandOs.writeShort(0);
+			}
+			else
+			{
+				commandOs.writeShort(msg.length());
+				writeString(msg);
+			}
+		}
+		catch (IOException e)
+		{
+			clientSocketError(e);
+		}
+	}
+
+	/** Write string
+	 *
+	 * @param msg String to write
+	 */
+
+	protected void writeString(String msg) throws Exception
+	{
+		byte[] msgBytes = msg.getBytes(DEFAULT_ENCODING);
+		commandOs.write(msgBytes,0,msgBytes.length);
+	}
+
+	/**
+	 * Write short
+	 *
+	 * @param value	value to be written
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private void writeShort(int value) throws Exception
+	{
+		try {
+			commandOs.writeByte((byte)((value & 0xf0) >> 8 ));
+			commandOs.writeByte((byte)(value & 0x0f));
+		}
+		catch (IOException e)
+		{
+			clientSocketError(e);
+		}
+	}
+	/**
+	 * Write byte
+	 *
+	 * @param value	value to be written
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private void writeByte(int value) throws Exception
+	{
+		try {
+			commandOs.writeByte((byte)(value & 0x0f));
+		}
+		catch (IOException e)
+		{
+			clientSocketError(e);
+		}
+	}
+	/**
+	 * Send client message to server
+	 *
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private void send() throws Exception
+	{
+		try {
+			byteArrayOs.writeTo(clientOs);
+			commandOs.flush();
+			byteArrayOs.reset();	//discard anything currently in the byte array
+		}
+		catch (IOException e)
+		{
+			clientSocketError(e);
+		}
+	}
+	/**
+	 * Stream error writing to client socket
+ 	 */
+	private void clientSocketError(IOException e) throws IOException
+	{
+		try {
+			consolePropertyMessage("DRDA_ClientSocketError.S", e.getMessage());
+		} catch (Exception ce) {} // catch the exception consolePropertyMessage will
+								 // throw since we also want to print a stack trace
+		consoleExceptionPrintTrace(e);
+			throw e;
+	}
+	/**
+	 * Read result from sending client message to server
+	 *
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private void readResult() throws Exception
+	{
+		fillReplyBuffer();
+		readCommandReplyHeader();
+		if (replyBufferPos >= replyBufferCount)
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+		int messageType = replyBuffer[replyBufferPos++] & 0xFF;
+		if (messageType == OK)		// O.K.
+			return;
+		// get error and display and throw exception
+		String message =  readLDString();
+		if (messageType == SQLERROR)
+			wrapSQLError(message);
+		else if (messageType == SQLWARNING)
+			wrapSQLWarning(message);
+		else
+			consolePropertyMessage(message);
+	}
+
+	
+
+	/**
+	 * Ensure the reply buffer is at large enought to hold all the data;
+	 * don't just rely on OS level defaults
+	 *
+	 *
+	 * @param minimumBytesNeeded	size of buffer required	
+	 * @exception Exception throws an exception if a problem reading the reply
+	 */
+	private void ensureDataInBuffer(int minimumBytesNeeded) throws Exception
+	{
+		// make sure the buffer is large enough
+		while ((replyBufferCount - replyBufferPos) < minimumBytesNeeded)
+		{
+			try {
+				int bytesRead = clientIs.read(replyBuffer, replyBufferCount, replyBuffer.length - replyBufferCount);
+				replyBufferCount += bytesRead;
+		
+			} catch (IOException e)
+			{
+				clientSocketError(e);
+			}
+		}
+	}
+
+
+	/**
+	 * Fill the reply buffer with the reply allocates a reply buffer if one doesn't
+	 * exist
+	 *
+	 *
+	 * @exception Exception throws an exception if a problem reading the reply
+	 */
+	private void fillReplyBuffer() throws Exception
+	{
+		if (replyBuffer == null)
+			replyBuffer = new byte[MAXREPLY];
+		try {
+			replyBufferCount = clientIs.read(replyBuffer);
+		}
+		catch (IOException e)
+		{
+			clientSocketError(e);
+		}
+		if (replyBufferCount == -1)
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+		replyBufferPos = 0;
+	}
+	/**
+	 * Read the command reply header from the server
+	 *
+	 * @exception Exception throws an exception if an error occurs
+	 */
+	private void readCommandReplyHeader() throws Exception
+	{
+		ensureDataInBuffer(REPLY_HEADER_LENGTH);
+		if (replyBufferCount < REPLY_HEADER_LENGTH)
+		{
+			consolePropertyMessage("DRDA_InvalidReplyHeader1.S", Integer.toString(replyBufferCount));
+		}
+		String header =  new String(replyBuffer, 0, REPLY_HEADER_LENGTH, DEFAULT_ENCODING);
+		if (!header.equals(REPLY_HEADER))
+		{
+			consolePropertyMessage("DRDA_InvalidReplyHeader2.S", header);
+		}
+		replyBufferPos += REPLY_HEADER_LENGTH;
+	}
+	/**
+	 * Read short from buffer
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private int readShort() throws Exception
+	{
+		ensureDataInBuffer(2);
+		if (replyBufferPos + 2 > replyBufferCount)
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+	 	return ((replyBuffer[replyBufferPos++] & 0xff) << 8) + 
+			    (replyBuffer[replyBufferPos++] & 0xff);
+	}
+	/**
+	 * Read int from buffer
+	 * @exception Exception	throws an exception if an error occurs
+	 */
+	private int readInt() throws Exception
+	{
+		ensureDataInBuffer(4);
+		if (replyBufferPos + 4 > replyBufferCount)
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+	 	return ((replyBuffer[replyBufferPos++] & 0xff) << 24) + 
+	 	 	((replyBuffer[replyBufferPos++] & 0xff) << 16) + 
+	 		((replyBuffer[replyBufferPos++] & 0xff) << 8) + 
+			    (replyBuffer[replyBufferPos++] & 0xff);
+	}
+	/**
+	 * Read String reply
+	 *
+	 * @param msgKey	error message key
+	 * @return string value or null 
+	 * @exception Exception throws an error if problems reading reply
+	 */
+	private String readStringReply(String msgKey) throws Exception
+	{
+		fillReplyBuffer();
+		readCommandReplyHeader();
+		if (replyBuffer[replyBufferPos++] == 0)		// O.K.
+			return readLDString();
+		else
+			consolePropertyMessage(msgKey);
+		return null;
+			
+	}
+
+
+
+	
+	/**
+	 * Read length delimited string from a buffer
+	 *
+	 * @return string value from buffer
+	 * @exception Exception throws an error if problems reading reply
+	 */
+	private String readLDString() throws Exception
+	{
+		int strlen = readShort();
+		ensureDataInBuffer(strlen);
+		if (replyBufferPos + strlen > replyBufferCount)
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+		String retval= new String(replyBuffer, replyBufferPos, strlen, DEFAULT_ENCODING);
+		replyBufferPos += strlen;
+		return retval;
+	}
+	/**
+	 * Read Bytes reply
+	 *
+	 * @param msgKey	error message key
+	 * @return string value or null 
+	 * @exception Exception throws an error if problems reading reply
+	 */
+	private byte [] readBytesReply(String msgKey) throws Exception
+	{
+		fillReplyBuffer();
+		readCommandReplyHeader();
+		if (replyBuffer[replyBufferPos++] == 0)		// O.K.
+			return readLDBytes();
+		else
+			consolePropertyMessage(msgKey);
+		return null;
+			
+	}
+	/**
+	 * Read length delimited bytes from a buffer
+	 *
+	 * @return byte array from buffer
+	 * @exception Exception throws an error if problems reading reply
+	 */
+	private byte[] readLDBytes() throws Exception
+	{
+		int len = readShort();
+		ensureDataInBuffer(len);
+		if (replyBufferPos + len > replyBufferCount)
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+		byte [] retval =  new byte[len];
+		for (int i = 0; i < len; i++)
+			retval[i] = replyBuffer[replyBufferPos++];
+		return retval;
+	}
+
+	/**
+	 * Get property info
+	 *
+	 * @return system properties
+	 */
+	private void  getPropertyInfo() throws Exception
+	{
+		//set values according to properties
+		
+		String directory = PropertyUtil.getSystemProperty(Property.SYSTEM_HOME_PROPERTY);
+		String propval = PropertyUtil.getSystemProperty(
+			Property.DRDA_PROP_LOGCONNECTIONS);
+		if (propval != null && StringUtil.SQLEqualsIgnoreCase(propval,"true"))  
+			setLogConnections(true);
+		propval = PropertyUtil.getSystemProperty(Property.DRDA_PROP_TRACEALL);
+		if (propval != null && StringUtil.SQLEqualsIgnoreCase(propval, 
+															  "true"))  
+			setTraceAll(true);
+
+		setTraceDirectory(PropertyUtil.getSystemProperty( 
+			Property.DRDA_PROP_TRACEDIRECTORY));
+
+		propval = PropertyUtil.getSystemProperty( 
+			Property.DRDA_PROP_MINTHREADS);
+		if (propval != null)
+			setMinThreads(getIntPropVal(Property.DRDA_PROP_MINTHREADS, propval));
+
+		propval = PropertyUtil.getSystemProperty( 
+			Property.DRDA_PROP_MAXTHREADS);
+		if (propval != null)
+			setMaxThreads(getIntPropVal(Property.DRDA_PROP_MAXTHREADS, propval));
+
+
+		propval = PropertyUtil.getSystemProperty( 
+			Property.DRDA_PROP_TIMESLICE);
+		if (propval != null)
+			setTimeSlice(getIntPropVal(Property.DRDA_PROP_TIMESLICE, propval));
+
+		propval = PropertyUtil.getSystemProperty( 
+			Property.DRDA_PROP_PORTNUMBER);
+		if (propval != null)
+			portNumber = getIntPropVal(Property.DRDA_PROP_PORTNUMBER, propval);
+
+		propval = PropertyUtil.getSystemProperty( 
+			Property.DRDA_PROP_HOSTNAME);
+		if (propval != null)
+			hostArg = propval;
+
+		propval = PropertyUtil.getSystemProperty(
+						 DB2jServerImpl.DRDA_PROP_DEBUG);
+		if (propval != null  && StringUtil.SQLEqualsIgnoreCase(propval, "true"))
+			debugOutput = true;
+
+		//RESOLVE: Need to clean this up. There should be just a
+		// server API call to get the log location
+		// Determine errror log location
+		propval = PropertyUtil.getSystemProperty(
+								   DB2jServerImpl.DB2J_PROP_STREAM_ERROR_FIELD);
+		if (propval == null)
+			propval = PropertyUtil.getSystemProperty( 
+									   DB2jServerImpl.DB2J_PROP_STREAM_ERROR_METHOD);
+		if (propval == null)
+		{
+			propval = PropertyUtil.getSystemProperty( 
+									   DB2jServerImpl.DB2J_PROP_STREAM_ERROR_FILE);
+			if (propval == null)
+				propval = "derby.log";
+		}
+		File errorFile = new File(propval);
+		if (errorFile.isAbsolute())
+			errorLogLocation = errorFile.getPath();
+		else
+			errorLogLocation = (new File
+				(directory,propval)).getPath();
+		
+	}
+
+	/**
+	 * Get integer property values
+	 *
+	 * @param propName 	property name
+	 * @param propVal	string property value
+	 * @return integer value
+	 *
+	 * @exception Exception if not a valid integer
+	 */
+	private int getIntPropVal(String propName, String propVal)
+		throws Exception
+	{
+		int val = 0;
+		try {
+			 val = (new Integer(propVal)).intValue();
+		} catch (Exception e)
+		{
+			consolePropertyMessage("DRDA_InvalidPropVal.S", new String [] 
+				{propName, propVal});
+		}
+		return val;
+	}
+	/**
+	 * Handle console error message
+	 * 	- display on console and if it is a user error, display usage
+	 *  - if user error or severe error, throw exception with message key and message
+	 *
+	 * @param messageKey	message key
+	 * @param args			arguments to message
+	 *
+	 * @exception throws an Exception if an error occurs
+	 */
+	private void consolePropertyMessageWork(String messageKey, String [] args)
+		throws Exception
+	{
+		String locMsg = null;
+
+		int type = getMessageType(messageKey);
+
+		if (type == ERRTYPE_UNKNOWN)
+			locMsg = messageKey;
+		else
+			locMsg = localizeMessage(messageKey, langUtil, args);
+
+		//display on the console
+		consoleMessage(locMsg);
+
+		//if it is a user error display usage
+		if (type == ERRTYPE_USER)
+			usage();
+
+		//we may want to use a different locale for throwing the exception
+		//since this can be sent to a browser with a different locale
+		if (currentSession != null && 
+				currentSession.langUtil != null &&
+				type != ERRTYPE_UNKNOWN)
+			locMsg = localizeMessage(messageKey, currentSession.langUtil, args);
+
+		// throw an exception for severe and user errors
+		if (type == ERRTYPE_SEVERE || type == ERRTYPE_USER)
+		{
+			if (messageKey.equals("DRDA_SQLException.S"))
+				throwSQLException(args[0]);
+			else if (messageKey.equals("DRDA_SQLWarning.I"))
+				throwSQLWarning(args[0]);
+			else 
+				throw new Exception(messageKey+":"+locMsg);
+		}
+
+		// throw an exception with just the message if the error type is
+		// unknown
+		if (type == ERRTYPE_UNKNOWN)
+			throw new Exception(locMsg);
+
+		return;
+
+	}
+	/**
+	 * Throw a SQL Exception which was sent over by a server
+	 * Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message
+	 *
+	 * @param msg		msg containing SQL Exception
+	 *
+	 * @exception throws a SQLException 
+	 */
+	private void throwSQLException(String msg) throws SQLException
+	{
+		SQLException se = null;
+		SQLException ne;
+		SQLException ce = null;
+		StringBuffer strbuf = new StringBuffer();
+		StringTokenizer tokenizer = new StringTokenizer(msg, "\n");
+		String sqlstate = null;
+		String str;
+		while (tokenizer.hasMoreTokens())
+		{
+			str = tokenizer.nextToken();
+			//start of the next message
+			if (str.charAt(5) == ':')
+			{
+				if (strbuf.length() > 0)
+				{
+					if (se == null)
+					{
+						se = new SQLException(strbuf.toString(), sqlstate);
+						ce = se;
+					}
+					else
+					{
+						ne = new SQLException(strbuf.toString(), sqlstate);
+						ce.setNextException(ne);
+						ce = ne;
+					}
+					strbuf = new StringBuffer();
+				}
+				strbuf.append(str.substring(6));
+				sqlstate = str.substring(0,5);
+			}
+			else
+				strbuf.append(str);
+		}
+		if (strbuf.length() > 0)
+		{
+			if (se == null)
+			{
+				se = new SQLException(strbuf.toString(), sqlstate);
+				ce = se;
+			}
+			else
+			{
+				ne = new SQLException(strbuf.toString(), sqlstate);
+				ce.setNextException(ne);
+				ce = ne;
+			}
+		}
+		throw se;
+	}
+	/**
+	 * Throw a SQL Warning which was sent over by a server
+	 * Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message
+	 *
+	 * @param msg		msg containing SQL Warning
+	 *
+	 * @exception throws a SQLWarning
+	 */
+	private void throwSQLWarning(String msg) throws SQLWarning
+	{
+		SQLWarning se = null;
+		SQLWarning ne;
+		SQLWarning ce = null;
+		StringBuffer strbuf = new StringBuffer();
+		StringTokenizer tokenizer = new StringTokenizer(msg, "\n");
+		String sqlstate = null;
+		String str;
+		while (tokenizer.hasMoreTokens())
+		{
+			str = tokenizer.nextToken();
+			//start of the next message
+			if (str.charAt(5) == ':')
+			{
+				if (strbuf.length() > 0)
+				{
+					if (se == null)
+					{
+						se = new SQLWarning(strbuf.toString(), sqlstate);
+						ce = se;
+					}
+					else
+					{
+						ne = new SQLWarning(strbuf.toString(), sqlstate);
+						ce.setNextException(ne);
+						ce = ne;
+					}
+					strbuf = new StringBuffer();
+				}
+				strbuf.append(str.substring(6));
+				sqlstate = str.substring(0,5);
+			}
+			else
+				strbuf.append(str);
+		}
+		if (strbuf.length() > 0)
+		{
+			if (se == null)
+			{
+				se = new SQLWarning(strbuf.toString(), sqlstate);
+				ce = se;
+			}
+			else
+			{
+				ne = new SQLWarning(strbuf.toString(), sqlstate);
+				ce.setNextException(ne);
+				ce = ne;
+			}
+		}
+		throw se;
+	}
+
+	/**
+	 * Print a trace for the (unexpected) exception received, then
+	 * throw a generic exception indicating that 1) an unexpected
+	 * exception was thrown, and 2) we've already printed the trace
+	 * (so don't do it again).
+	 * 
+	 * @param e An unexpected exception.
+	 * @exception throws an Exception with message UNEXPECTED_ERR.
+	 */
+	private void throwUnexpectedException(Exception e)
+	 throws Exception {
+
+		consoleExceptionPrintTrace(e);
+		throw new Exception(UNEXPECTED_ERR);
+
+	}
+
+	/**
+	 * Localize a message given a particular AppUI 
+	 *
+	 * @param msgProp	message key
+	 * @param localAppUI	AppUI to use to localize message
+	 * @param args		arguments to message
+	 *
+	 */
+	private String localizeMessage(String msgProp, LocalizedResource localLangUtil, String [] args)
+	{
+		String locMsg = null;
+		//check if the argument is a property
+		if (args != null)
+		{
+			String [] argMsg = new String[args.length];
+			for (int i = 0; i < args.length; i++)
+			{
+				if (isMsgProperty(args[i]))
+					argMsg[i] = localLangUtil.getTextMessage(args[i]);
+				else
+					argMsg[i] = args[i];
+			}
+			switch (args.length)
+			{
+				case 1:
+				 	locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0]);
+					break;
+				case 2:
+					locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0], argMsg[1]);
+					break;
+				case 3:
+					locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0], argMsg[1], argMsg[2]);
+					break;
+				case 4:
+					locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0], argMsg[1], argMsg[2], argMsg[3]);
+					break;
+				default:
+					//shouldn't get here
+			}
+		}
+		else
+		 	locMsg = localLangUtil.getTextMessage(msgProp);
+		return locMsg;
+	}
+	/**
+	 * Determine type of message
+	 *
+	 * @param msg		message 
+	 *
+	 * @return message type
+	 */
+	private int getMessageType(String msg)
+	{
+		//all property messages should start with DRDA_
+		if (!msg.startsWith(DRDA_MSG_PREFIX))
+			return ERRTYPE_UNKNOWN;
+		int startpos = msg.indexOf('.')+1;
+		if (startpos >= msg.length())
+			return ERRTYPE_UNKNOWN;
+		if (msg.length() > (startpos + 1))
+			return ERRTYPE_UNKNOWN;
+		char type = msg.charAt(startpos);
+		if (type == 'S')
+			return ERRTYPE_SEVERE;
+		if (type == 'U')
+			return ERRTYPE_USER;
+		if (type == 'I')
+			return ERRTYPE_INFO;
+		return ERRTYPE_UNKNOWN;
+	}
+	/**
+	 * Determine whether string is a property key or not
+	 * 	property keys start with DRDA_MSG_PREFIX
+	 *
+	 * @param msg		message 
+	 *
+	 * @return true if it is a property key; false otherwise
+	 */
+	private boolean isMsgProperty(String msg)
+	{
+		if (msg.startsWith(DRDA_MSG_PREFIX))
+			return true;
+		else
+			return false;
+	}
+	/**
+	 * Get the current value of logging connections
+	 *
+	 * @return true if logging connections is on; false otherwise
+	 */
+	public boolean getLogConnections()
+	{
+		synchronized(logConnectionsSync) {
+			return logConnections;
+		}
+	}
+	/**
+	 * Set the current value of logging connections
+	 *
+	 * @param value	true to turn logging connections on; false to turn it off
+	 */
+	private void setLogConnections(boolean value)
+	{
+		synchronized(logConnectionsSync) {
+			logConnections = value;
+		}
+		// update the value in all the threads
+		synchronized(threadList) {
+			for (Enumeration e = threadList.elements(); e.hasMoreElements(); )
+			{
+				DRDAConnThread thread = (DRDAConnThread)e.nextElement();
+				thread.setLogConnections(value);
+			}
+		}
+	}
+
+	/**
+	 * Set the trace on/off for all sessions, or one session, depending on
+	 * whether we got -s argument.
+	 *
+	 * @param on	true to turn trace on; false to turn it off
+	 * @return true if set false if an error occurred
+	 */
+	private boolean setTrace(boolean on)
+	{
+		if (sessionArg == 0)
+		{
+			setTraceAll(on);
+			synchronized(sessionTable) {
+				for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
+				{	
+					Session session = (Session) e.nextElement();
+					if (on)
+						session.setTraceOn(traceDirectory);
+					else
+						session.setTraceOff();
+				}
+			}
+		}
+		else
+		{
+			Session session = (Session) sessionTable.get(new Integer(sessionArg));
+			if (session != null)
+			{	
+				if (on)
+					session.setTraceOn(traceDirectory);
+				else
+					session.setTraceOff();
+			}
+			else
+				return false;
+		}
+		return true;
+	}
+
+
+	/**
+	 * Get the current value of the time slice
+	 *
+	 * @return time slice value
+	 */
+	protected int getTimeSlice()
+	{
+			return timeSlice;
+	}
+	/**
+	 * Set the current value of  time slice
+	 *
+	 * @param value time slice value
+	 * @exception Exception if value is < 0
+	 */
+	private void setTimeSlice(int value)
+		throws Exception
+	{
+		if (value < MIN_TIMESLICE)
+			consolePropertyMessage("DRDA_InvalidValue.U", new String [] 
+				{new Integer(value).toString(), "timeslice"});
+		if (value == USE_DEFAULT)
+			value = DEFAULT_TIMESLICE;
+		synchronized(timeSliceSync) {
+			timeSlice = value;
+		}
+	}
+
+	/**
+	 * Get the current value of minimum number of threads to create at start
+	 *
+	 * @return value of minimum number of threads
+	 */
+	private int getMinThreads()
+	{
+		synchronized(threadsSync) {
+			return minThreads;
+		}
+	}
+	/**
+	 * Set the current value of minimum number of threads to create at start
+	 *
+	 * @param value	 value of minimum number of threads
+	 */
+	private void setMinThreads(int value)
+	{
+		synchronized(threadsSync) {
+			minThreads = value;
+		}
+	}
+	/**
+	 * Get the current value of maximum number of threads to create 
+	 *
+	 * @return value of maximum number of threads
+	 */
+	protected int getMaxThreads()
+	{
+		synchronized(threadsSync) {
+			return maxThreads;
+		}
+	}
+	/**
+	 * Set the current value of maximum number of threads to create 
+	 *
+	 * @param value	value of maximum number of threads
+	 * @exception Exception if value is less than 0
+	 */
+	private void setMaxThreads(int value) throws Exception
+	{
+		if (value < MIN_MAXTHREADS)
+			consolePropertyMessage("DRDA_InvalidValue.U", new String [] 
+				{new Integer(value).toString(), "maxthreads"});
+		if (value == USE_DEFAULT)
+			value = DEFAULT_MAXTHREADS;
+		synchronized(threadsSync) {
+			maxThreads = value;
+		}
+	}
+	/**
+	 * Get the current value of minimum number of pooled connections to create at start
+	 *
+	 * @return value of minimum number of pooled connections
+	 */
+	private int getMinPoolSize()
+	{
+		synchronized(threadsSync) {
+			return minPoolSize;
+		}
+	}
+	/**
+	 * Set the current value of minimum number of pooled connections to create at start
+	 *
+	 * @param value	 value of minimum number of pooled connections
+	 */
+	private void setMinPoolSize(int value)
+	{
+		synchronized(poolSync) {
+			minPoolSize = value;
+		}
+	}
+	/**
+	 * Get the current value of maximum number of pooled connections to create 
+	 *
+	 * @return value of maximum number of pooled connections
+	 */
+	private int getMaxPoolSize()
+	{
+		synchronized(poolSync) {
+			return maxPoolSize;
+		}
+	}
+	/**
+	 * Set the current value of maximum number of pooled connections to create 
+	 *
+	 * @param value	value of maximum number of pooled connections
+	 */
+	private void setMaxPoolSize(int value)
+	{
+		synchronized(poolSync) {
+			maxPoolSize = value;
+		}
+	}
+	/**
+	 * Get the current value of whether to trace all the sessions
+	 *
+	 * @return true if tracing is on for all sessions; false otherwise
+	 */
+	protected boolean getTraceAll()
+	{
+		synchronized(traceAllSync) {
+			return traceAll;
+		}
+	}
+	/**
+	 * Set the current value of whether to trace all the sessions
+	 *
+	 * @param value	true if tracing is on for all sessions; false otherwise
+	 */
+	private void setTraceAll(boolean value)
+	{
+		synchronized(traceAllSync) {
+			traceAll = value;
+		}
+	}
+	/**
+	 * Get the current value of trace directory
+	 *
+	 * @return trace directory
+	 */
+	protected String getTraceDirectory()
+	{
+		synchronized(traceDirectorySync) {
+			return traceDirectory;
+		}
+	}
+	/**
+	 * Set the current value of trace directory
+	 *
+	 * @param value	trace directory
+	 */
+	private void setTraceDirectory(String value)
+	{
+		synchronized(traceDirectorySync) {
+			traceDirectory = value;
+		}
+	}
+
+	/**
+	 * Connect to a database to test whether a connection can be made
+	 *
+	 * @param writer	connection to send message to
+	 * @param database 	database directory to connect to
+	 * @param user		user to use
+	 * @param password	password to use
+	 */
+	private void connectToDatabase(DDMWriter writer, String database, String user, 
+		String password) throws Exception
+	{
+		Properties p = new Properties();
+		if (user != null)
+			p.put("user", user);
+		if (password != null)
+			p.put("password", password);
+	 	try {
+     		Class.forName(CLOUDSCAPE_DRIVER);
+		}
+		catch (Exception e) {
+			sendMessage(writer, ERROR, e.getMessage());
+			return;
+	  	}
+	 	try {
+			//Note, we add database to the url so that we can allow additional
+			//url attributes
+			Connection conn = DriverManager.getConnection(Attribute.PROTOCOL+database, p);
+			// send warnings
+			SQLWarning warn = conn.getWarnings();
+			if (warn != null)
+				sendSQLMessage(writer, warn, SQLWARNING);
+			else
+				sendOK(writer);
+			conn.close();
+			return;
+	  	} catch (SQLException se) {
+			sendSQLMessage(writer, se, SQLERROR);
+	  	}
+	}
+	/**
+	 * Boot database 
+	 *
+	 * @param writer	connection to send message to
+	 * @param database 	database directory to connect to
+	 * @param bootPassword	boot password
+	 * @param encPrv	encryption provider
+	 * @param encAlg	encryption algorithm
+	 * @param user		user to use
+	 * @param password	password to use
+	 */
+	private void startDatabase(DDMWriter writer, String database,
+		String bootPassword, String encPrv, String encAlg, String user, 
+			String password) throws Exception
+	{
+		Properties p = new Properties();
+		if (bootPassword != null)
+			p.put(Attribute.BOOT_PASSWORD, bootPassword);
+		if (encPrv != null)
+			p.put(Attribute.CRYPTO_PROVIDER, encPrv);
+		if (encAlg != null)
+			p.put(Attribute.CRYPTO_ALGORITHM, encAlg);
+		if (user != null)
+			p.put(Attribute.USERNAME_ATTR, user);
+		if (password != null)
+			p.put(Attribute.PASSWORD_ATTR, password);
+	 	try {
+     		Class.forName(CLOUDSCAPE_DRIVER);
+		}
+		catch (Exception e) {
+			sendMessage(writer, ERROR, e.getMessage());
+			return;
+	  	}
+	 	try {
+			//Note, we add database to the url so that we can allow additional
+			//url attributes
+			Connection conn = DriverManager.getConnection(Attribute.PROTOCOL+database, p);
+			SQLWarning warn = conn.getWarnings();
+			if (warn != null)
+				sendSQLMessage(writer, warn, SQLWARNING);
+			else
+				sendOK(writer);
+			conn.close();
+	  	} catch (SQLException se) {
+			sendSQLMessage(writer, se, SQLERROR);
+	  	} catch (Exception e) {
+			sendMessage(writer, ERROR, e.getMessage());
+		}
+	}
+	/**
+	 * Shutdown a database 
+	 *
+	 * @param writer	connection to send message to
+	 * @param database 	database directory to shutdown to
+	 * @param user		user to use
+	 * @param password	password to use
+	 */
+	private void shutdownDatabase(DDMWriter writer, String database, String user, 
+		String password) throws Exception
+	{
+
+		StringBuffer url = new StringBuffer(Attribute.PROTOCOL + database);
+		if (user != null)
+			url.append(";user="+user);
+		if (password != null)
+			url.append(";password="+password);
+		url.append(";shutdown=true");
+	 	try {
+     		Class.forName(CLOUDSCAPE_DRIVER);
+		}
+		catch (Exception e) {
+			sendMessage(writer, ERROR, e.getMessage());
+			return;
+	  	}
+	 	try {
+			Connection conn = DriverManager.getConnection(url.toString());
+			SQLWarning warn = conn.getWarnings();
+			if (warn != null)
+				sendSQLMessage(writer, warn, SQLWARNING);
+			else
+				sendOK(writer);
+			conn.close();
+	  	} catch (SQLException se) {
+			//ignore shutdown error
+			if (!(((EmbedSQLException)se).getMessageId() == SQLState.SHUTDOWN_DATABASE))
+			{
+				sendSQLMessage(writer, se, SQLERROR);
+				return;
+			}
+			sendOK(writer);
+	  	}
+	}
+	/**
+	 * Wrap SQL Error - display to console and raise exception
+	 *
+	 * @param messageKey	Cloudscape SQL Exception message id
+	 *
+	 * @exception Exception raises exception for message
+	 */
+	private void wrapSQLError(String messageKey)
+		throws Exception
+	{
+		consolePropertyMessage("DRDA_SQLException.S", messageKey);
+	}
+
+	/**
+	 * Wrap SQL Warning - display to console and raise exception
+	 *
+	 * @param messageKey	Cloudscape SQL Exception message id
+	 *
+	 * @exception Exception raises exception for message
+	 */
+	private void wrapSQLWarning(String messageKey)
+		throws Exception
+	{
+		consolePropertyMessage("DRDA_SQLWarning.I", messageKey);
+	}
+	private Properties getPropertyValues()
+	{
+		Properties retval = new Properties();
+		retval.put(Property.DRDA_PROP_PORTNUMBER, new Integer(portNumber).toString());
+		retval.put(Property.DRDA_PROP_HOSTNAME, hostArg);
+		String tracedir = getTraceDirectory();
+		if (tracedir != null)
+			retval.put(Property.DRDA_PROP_TRACEDIRECTORY, tracedir);
+		retval.put(Property.DRDA_PROP_TRACEALL, new Boolean(getTraceAll()).toString());
+		retval.put(Property.DRDA_PROP_MINTHREADS, new Integer(getMinThreads()).toString());
+		retval.put(Property.DRDA_PROP_MAXTHREADS, new Integer(getMaxThreads()).toString());
+		retval.put(Property.DRDA_PROP_TIMESLICE, new Integer(getTimeSlice()).toString());
+
+		retval.put(Property.DRDA_PROP_TIMESLICE, new  Integer(getTimeSlice()).toString());
+		retval.put(Property.DRDA_PROP_LOGCONNECTIONS, new Boolean(getLogConnections()).toString());
+		String startDRDA = PropertyUtil.getSystemProperty(Property.START_DRDA);
+		retval.put(Property.START_DRDA, (startDRDA == null)? "false" : startDRDA);
+
+		//get the trace value for each session if tracing for all is not set
+		if (!getTraceAll())
+		{
+			synchronized(sessionTable) {
+				for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
+				{	
+					Session session = (Session) e.nextElement();
+					if (session.isTraceOn())
+						retval.put(Property.DRDA_PROP_TRACE+"."+session.getConnNum(), "true");
+				}
+			}
+		}
+		return retval;
+	}
+
+	public String getErrorLogLocation ()
+	{
+		return errorLogLocation;
+	}
+
+
+	/**
+	 * Add To Session Table - for use by ClientThread, add a new Session to the sessionTable.
+	 *
+	 * @param num	Connection number to register
+	 * @param s	Session to add to the sessionTable
+	 */
+	protected void addToSessionTable(Integer i, Session s)
+	{
+		sessionTable.put(i, s);
+	}
+
+	/**
+	 * Get New Conn Num - for use by ClientThread, generate a new connection number for the attempted Session.
+	 *
+	 * @return	a new connection number
+	 */
+	protected int getNewConnNum()
+	{
+		return ++connNum;
+	}
+
+
+	/**
+	 * Get Free Threads - for use by ClientThread, get the number of 
+	 * free threads in order to determine if
+	 * a new thread can be run.
+	 *
+	 * @return	the number of free threads
+	 */
+	protected int getFreeThreads()
+	{
+		synchronized(runQueue)
+		{
+			return freeThreads;
+		}
+	}
+
+	/**
+	 * Get Thread List - for use by ClientThread, get the thread list 
+	 * Vector so that a newly spawned thread
+	 * can be run and added to the ThreadList from the ClientThread 
+	 *
+	 * @return	the threadList Vector
+	 */
+	protected Vector getThreadList()
+	{
+		return threadList;
+	}
+	
+	protected Object getShutdownSync() { return shutdownSync; } 
+	protected boolean getShutdown() { return shutdown; } 
+
+
+	public String buildRuntimeInfo(LocalizedResource locallangUtil)
+	{
+		
+		String s = locallangUtil.getTextMessage("DRDA_RuntimeInfoBanner.I")+ "\n";
+		int sessionCount = 0;
+		s += locallangUtil.getTextMessage("DRDA_RuntimeInfoSessionBanner.I") + "\n";
+		for (int i = 0; i < threadList.size(); i++)
+		{
+			String sessionInfo  = ((DRDAConnThread)
+								   threadList.get(i)).buildRuntimeInfo("",locallangUtil) ;
+			if (!sessionInfo.equals(""))
+			{
+				sessionCount ++;
+				s += sessionInfo + "\n";
+			}
+		}
+		int waitingSessions = 0;
+		for (int i = 0; i < runQueue.size(); i++)
+		{
+				s += ((Session)runQueue.get(i)).buildRuntimeInfo("", locallangUtil);
+				waitingSessions ++;
+		}
+		s+= "-------------------------------------------------------------\n";
+		s += locallangUtil.getTextMessage("DRDA_RuntimeInfoNumThreads.I") +
+			threadList.size() + "\n";
+		s += locallangUtil.getTextMessage("DRDA_RuntimeInfoNumActiveSessions.I") +
+			sessionCount  +"\n";
+		s +=locallangUtil.getTextMessage("DRDA_RuntimeInfoNumWaitingSessions.I") +
+			+ waitingSessions + "\n\n";
+
+		Runtime rt = Runtime.getRuntime();
+		rt.gc();
+		long totalmem = rt.totalMemory();
+		long freemem = rt.freeMemory();
+		s += locallangUtil.getTextMessage("DRDA_RuntimeInfoTotalMemory.I") +
+			+ totalmem + "\t";
+		s += locallangUtil.getTextMessage("DRDA_RuntimeInfoFreeMemory.I") +
+			+ freemem + "\n\n";
+		
+		return s;
+	}
+
+
+	protected void setClientLocale(String locale)
+	{
+		clientLocale = locale;
+	}
+
+	/**
+	 * Retrieve product version information
+	 * We need to make sure that this method gets the stream and passes it to 
+	 * ProductVersionHolder, because it lives in the Network Server jar
+	 * and won't be readily available to ProductVersionHolder when running
+	 * under security manager.
+	 */
+	private ProductVersionHolder getNetProductVersionHolder() throws Exception
+	{
+		ProductVersionHolder myPVH= null;
+		try {
+			myPVH = (ProductVersionHolder) AccessController.doPrivileged(
+								new PrivilegedExceptionAction() {
+										
+									public Object run() throws UnknownHostException,IOException
+									{
+										InputStream versionStream = getClass().getResourceAsStream(ProductGenusNames.NET_INFO);
+
+										return ProductVersionHolder.getProductVersionHolderFromMyEnv(versionStream);
+									}
+									});
+		
+}
+		catch(PrivilegedActionException e) {
+			Exception e1 = e.getException();
+			consolePropertyMessage("DRDA_ProductVersionReadError.S", e1.getMessage());			
+		}
+		return myPVH;
+	}
+
+}
+
+
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,1754 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+import java.math.BigDecimal;
+
+/**
+	The DDMReader is used to read DRDA protocol.   DRDA Protocol is divided into
+	three layers corresponding to the DDM three-tier architecture. For each layer,
+	their is a DSS (Data Stream Structure) defined.
+		Layer A 	Communications management services
+		Layer B		Agent services
+		Layer C 	Data management services
+	<P>
+	At layer A are request, reply and data correlation, structure chaining,
+	continuation or termination of chains when errors are detected, interleaving
+	and multi-leaving request, reply, and data DSSs for multitasking environments.
+	For TCP/IP, the format of the DDM envelope is
+		2 bytes		Length of the data
+		1 byte		'D0' - indicates DDM data
+		1 byte		DDM format byte(DSSFMT) - type of DSS(RQSDSS,RPYDSS), whether it is
+					chained, information about the next chained DSS
+		2 bytes		request correlation identifier
+	<P>
+	The correlation identifier ties together a request, the request data and the
+	reply.  In a chained DSS, each request has a correlation identifier which
+	is higher than the previous request (all correlation identifiers must
+	be greater than 0).
+	<P>
+	At layer B are object mapping, object validation and command routing.
+	Layer B objects with data 5 bytes less than 32K bytes consist of
+		2 bytes		Length
+		2 bytes		Type of the object (code point)
+		Object data
+	Object data is either SCALAR or COLLECTION data.  Scalar data consists of
+	a string of bytes formatted as the class description of the object required.
+	Collections consist of a set of objects in which the entries in the collection
+	are nested within the length/ code point of the collection.
+	<P>
+	Layer B objects with data >=32763 bytes long format is 
+		2 bytes		Length - length of class, length, and extended total length fields
+					(high order bit set, indicating >=32763)
+		2 bytes		Type of the object (code point)
+		n bytes		Extended total length - length of the object
+					(n = Length - 4)
+		Object data
+	<P>
+	At layer C are services each class of DDM object provides.
+
+		    |-------------------------------------------|
+	Layer C | Specific	|	Specific	|	Specific	|
+		    | Commands	|	Replies		| Scalars and	|
+			| and their |  and their    | Collections   |
+			|-------------------------------------------|----------------|
+	Layer B | Commands  |    Reply		| Scalars and   | Communications |
+			|			|   Messages	| Collections	|                |
+			|-----------|---------------|---------------|----------------|
+	Layer A |  RQSDSS   |   RPYDSS		| OBJDSS		| CMNDSS         |
+			|           |               |               | Mapped Data    |
+			|-----------|---------------|---------------|----------------|
+			|                DDM Data Stream Structures                  |
+			|------------------------------------------------------------|
+			
+	DSS's may be chained so that more than one can be transmitted at a time
+	to improve performance.
+	For more details, see DRDA Volume 3 (Distributed Data Management(DDM)
+		Architecture (DDS definition)
+*/
+class DDMReader
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+	private final static int DEFAULT_BUFFER_SIZE = 32767;
+	private final static int MAX_MARKS_NESTING = 10;
+	private final static int NO_CODEPOINT = -1;
+	private final static int EMPTY_STACK = -1;
+	private final static boolean ADJUST_LENGTHS = true;
+	private final static boolean NO_ADJUST_LENGTHS = false;
+	private final static long MAX_EXTDTA_SIZE= Long.MAX_VALUE;
+	private static boolean internalTrace = true;
+
+	// magnitude represented in an int array, used in BigDecimal conversion
+    private static final int[][] tenRadixMagnitude = {
+      { 0x3b9aca00 }, // 10^9
+      { 0x0de0b6b3, 0xa7640000 }, // 10^18
+      { 0x033b2e3c, 0x9fd0803c, 0xe8000000 }, // 10^27
+    };
+
+	private DRDAConnThread agent;
+	private CcsidManager ccsidManager;
+
+	// data buffer
+	private byte[] buffer;
+	private int pos;
+	private int count;
+
+	// DDM object collection
+	// top of stack
+	private int topDdmCollectionStack;
+	// length of each object in the stack
+	private long[] ddmCollectionLenStack;
+
+	// DDM object length
+	private long ddmScalarLen;
+
+	// DSS Length
+	private int dssLength;
+
+	// DSS is larger than 32762 (continuation bit is set) so DSS is continued
+	private boolean dssIsContinued;
+
+	private boolean terminateChainOnErr;
+
+	// next DSS in the chain has the same correlator
+	private boolean dssIsChainedWithSameID;
+
+	// next DSS in the chain has a different correlator
+	private boolean dssIsChainedWithDiffID;
+	
+	// correlation id for the current DSS
+	private int dssCorrelationID;
+
+	// previous corelation id
+	private int prevCorrelationID;
+
+	// current server codepoint
+	private int svrcod;
+
+	// trace object of the associated session
+	private DssTrace dssTrace;
+
+	// input stream
+	private InputStream inputStream;
+
+	// constructor
+	protected DDMReader (DRDAConnThread agent, DssTrace dssTrace)
+	{
+		buffer = new byte[DEFAULT_BUFFER_SIZE];
+		ddmCollectionLenStack = new long[MAX_MARKS_NESTING];
+		initialize(agent, dssTrace);
+	}
+	/**
+	 * This constructor is used for testing the protocol
+	 * It is used by TestProto to read the protocol returned by the
+	 * server 
+	 */
+	protected DDMReader(CcsidManager ccsidManager, InputStream inputStream)
+	{
+		buffer = new byte[DEFAULT_BUFFER_SIZE];
+		ddmCollectionLenStack = new long[MAX_MARKS_NESTING];
+		this.ccsidManager = ccsidManager;
+		this.inputStream = inputStream;
+		initialize(null, null);
+		// turn off tracing
+		internalTrace = false;
+	}
+	/**
+	 * This initializer is used for testing the protocol
+	 * It is used by TestProto for the reader it uses
+	 */
+	protected void initialize(InputStream inputStream)
+	{
+		this.inputStream = inputStream;
+		initialize(null, null);
+	}
+
+	/**
+	 * Initialize values for this session, the reader is reused so we need to
+	 * set null and 0 values
+	 */
+	protected void initialize(DRDAConnThread agent, DssTrace dssTrace)
+  	{
+		this.agent = agent;
+		if (agent != null)
+		{
+			ccsidManager = agent.ccsidManager;
+			inputStream = agent.getInputStream();
+		}
+		topDdmCollectionStack = EMPTY_STACK;
+    	svrcod = 0;
+		pos = 0;
+		count = 0;
+		ddmScalarLen = 0;
+		dssLength = 0;
+		prevCorrelationID = DssConstants.CORRELATION_ID_UNKNOWN;
+		dssCorrelationID = DssConstants.CORRELATION_ID_UNKNOWN;
+		this.dssTrace = dssTrace;
+	}
+
+	protected boolean terminateChainOnErr()
+	{
+		return terminateChainOnErr;
+	}
+
+	/**
+	 * Next DSS has same correlator as current DSS
+	 *
+	 * @return true if next DSS has the same correlator as current DSS
+	 */
+  	protected boolean isChainedWithSameID()
+  	{
+    	return dssIsChainedWithSameID;
+  	}
+
+	/**
+	 * Next DSS has different correlator than current DSS
+	 *
+	 * @return true if next DSS has a different correlator than current DSS
+	 */
+  	protected boolean isChainedWithDiffID()
+  	{
+    	return dssIsChainedWithDiffID;
+  	}
+
+	/**
+	 * Length of current DDM object
+	 *
+	 * @return length of DDM object
+	 */
+	protected long getDdmLength()
+	{
+		return ddmScalarLen;
+	}
+
+	/**
+	 * Is there more in this DDM object
+	 *
+	 * @return true if DDM length is > 0
+	 */
+	protected boolean moreDdmData()
+	{
+		return ddmScalarLen > 0;
+	}
+
+	/**
+	 * Is there more in this DDS object
+	 *
+	 * @return true if DDS length is > 0
+	 */
+	protected boolean moreDssData()
+	{
+		return dssLength > 0;
+	}
+
+	/** 
+	 * Is there more data in the buffer
+	 *
+	 * @return true if there is more data in the buffer
+	 */
+	protected boolean moreData()
+	{
+		return (pos - count) > 0;
+	}
+
+	/**
+	 * Check for the command protocol
+	 *
+	 * @return true if this is a command; false otherwise
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected boolean isCmd() throws DRDAProtocolException, java.io.UnsupportedEncodingException
+	{
+		ensureALayerDataInBuffer(4);
+		String val = new String(buffer, 0, 4, DB2jServerImpl.DEFAULT_ENCODING);
+		return DB2jServerImpl.isCmd(val);
+	}
+
+	/**
+	 * Return buffer 
+	 *
+	 *
+	 * @return buffer
+	 */
+	protected byte [] getBuffer()
+	{
+		return buffer;
+	}
+
+	/**
+	 * Read DSS header
+	 * DSS Header format is 
+	 * 	2 bytes	- length
+	 *	1 byte	- 'D0'	- indicates DDM data
+	 * 	1 byte	- DSS format 
+	 *		|---|---------|----------|
+	 *		| 0	|  flags  |  type    |
+	 *		|---|---------|----------|
+	 *		| 0 | 1  2  3 | 4 5 6 7  |
+	 *		|---|---------|----------|
+	 *		bit 0 - '0'
+	 *		bit 1 - '0' - unchained, '1' - chained
+	 *		bit 2 - '0'	- do not continue on error, '1' - continue on error
+	 *		bit 3 - '0' - next DSS has different correlator, '1' - next DSS has
+	 *						same correlator
+	 *		type - 1 - Request DSS
+	 *			 - 2 - Reply DSS
+	 *			 - 3 - Object DSS
+	 *			 - 4 - Communications DSS
+	 *			 - 5 - Request DSS where no reply is expected
+	 *	2 bytes - request correlation id
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int readDssHeader () throws DRDAProtocolException
+	{
+		ensureALayerDataInBuffer (6);
+
+		// read out the DSS length
+		dssLength = ((buffer[pos] & 0xff) << 8) +
+					((buffer[pos + 1] & 0xff) << 0);
+		pos += 2;
+		// check for the continuation bit and update length as needed.
+		if ((dssLength & DssConstants.CONTINUATION_BIT) == 
+				DssConstants.CONTINUATION_BIT) 
+		{
+			dssLength = DssConstants.MAX_DSS_LENGTH;
+			dssIsContinued = true;
+		}
+		else 
+		{
+			dssIsContinued = false;
+		}
+
+		if (dssLength < 6)
+			agent.throwSyntaxrm(CodePoint.SYNERRCD_DSS_LESS_THAN_6,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+
+		// If the GDS id is not valid, or
+		// if the reply is not an RQSDSS nor
+		// a OBJDSS, then throw an exception.
+
+		if ((buffer[pos++] & 0xff) != DssConstants.DSS_ID)
+			agent.throwSyntaxrm(CodePoint.SYNERRCD_CBYTE_NOT_D0,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+
+		int gdsFormatter = buffer[pos++] & 0xff;
+		
+		if (((gdsFormatter & 0x0F) != DssConstants.DSSFMT_RQSDSS)
+			&&((gdsFormatter & 0x0F) != DssConstants.DSSFMT_OBJDSS)) 
+		{
+			agent.throwSyntaxrm(CodePoint.SYNERRCD_FBYTE_NOT_SUPPORTED,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+		}
+
+		// Determine if the current DSS is chained with the
+		// next DSS, with the same or different request ID.
+		if ((gdsFormatter & DssConstants.DSSCHAIN) == DssConstants.DSSCHAIN) 
+		{	// on indicates structure chained to next structure
+			if ((gdsFormatter & DssConstants.DSSCHAIN_SAME_ID) 
+					== DssConstants.DSSCHAIN_SAME_ID) 
+			{
+				dssIsChainedWithSameID = true;
+				dssIsChainedWithDiffID = false;
+			}
+			else 
+			{
+				dssIsChainedWithSameID = false;
+				dssIsChainedWithDiffID = true;
+			}
+			if ((gdsFormatter & DssConstants.DSSCHAIN_ERROR_CONTINUE) 
+				== DssConstants.DSSCHAIN_ERROR_CONTINUE)
+				terminateChainOnErr = false;
+			else
+				terminateChainOnErr = true;
+		}
+		else 
+		{
+			// chaining bit not b'1', make sure DSSFMT same id not b'1'
+			if ((gdsFormatter & DssConstants.DSSCHAIN_SAME_ID) 
+					== DssConstants.DSSCHAIN_SAME_ID)	
+			{  // Next DSS can not have same correlator
+				agent.throwSyntaxrm(CodePoint.SYNERRCD_CHAIN_OFF_SAME_NEXT_CORRELATOR,
+								   DRDAProtocolException.NO_CODPNT_ARG);
+			}
+			// chaining bit not b'1', make sure no error continuation
+			if ((gdsFormatter & DssConstants.DSSCHAIN_ERROR_CONTINUE) 
+				== DssConstants.DSSCHAIN_ERROR_CONTINUE) 
+			{ // must be 'do not continue on error'
+				agent.throwSyntaxrm(CodePoint.SYNERRCD_CHAIN_OFF_ERROR_CONTINUE,
+								   DRDAProtocolException.NO_CODPNT_ARG);
+			}
+
+			dssIsChainedWithSameID = false;
+			dssIsChainedWithDiffID = false;
+		}
+
+		dssCorrelationID =
+			((buffer[pos] & 0xff) << 8) +
+			((buffer[pos + 1] & 0xff) << 0);
+		pos += 2;
+		if (SanityManager.DEBUG)
+			trace("dssLength = " + dssLength + " correlationID = " + dssCorrelationID);
+
+		//check that correlationID is the same as previous
+		if (prevCorrelationID != DssConstants.CORRELATION_ID_UNKNOWN && 
+			dssCorrelationID != prevCorrelationID)
+		{
+			agent.throwSyntaxrm(CodePoint.SYNERRCD_CHAIN_OFF_ERROR_CONTINUE,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+		}
+		
+		// set up previous correlation id to check that next DSS is correctly
+		// formatted
+		if (dssIsChainedWithSameID)
+			prevCorrelationID = dssCorrelationID;
+		else
+			prevCorrelationID = DssConstants.CORRELATION_ID_UNKNOWN;
+
+		dssLength -= 6;
+
+		return dssCorrelationID;
+	}
+	/**
+	 * Read Reply DSS
+	 * This is used in testing the protocol.  We shouldn't see a reply
+	 * DSS when we are servicing DRDA commands
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected void readReplyDss() throws DRDAProtocolException
+	{
+		ensureALayerDataInBuffer (6);
+
+		// read out the DSS length
+		dssLength = ((buffer[pos++] & 0xff) << 8) +
+					((buffer[pos++] & 0xff) << 0);
+
+		// check for the continuation bit and update length as needed.
+		if ((dssLength & DssConstants.CONTINUATION_BIT) == 
+				DssConstants.CONTINUATION_BIT) 
+		{
+			dssLength = DssConstants.MAX_DSS_LENGTH;
+			dssIsContinued = true;
+		}
+		else 
+		{
+			dssIsContinued = false;
+		}
+
+		if (dssLength < 6)
+			agent.throwSyntaxrm(CodePoint.SYNERRCD_DSS_LESS_THAN_6,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+
+		// If the GDS id is not valid, throw exception
+
+		if ((buffer[pos++] & 0xff) != DssConstants.DSS_ID)
+			agent.throwSyntaxrm(CodePoint.SYNERRCD_CBYTE_NOT_D0,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+
+		int gdsFormatter = buffer[pos++] & 0xff;
+		
+		// Determine if the current DSS is chained with the
+		// next DSS, with the same or different request ID.
+		if ((gdsFormatter & DssConstants.DSSCHAIN) == DssConstants.DSSCHAIN) 
+		{	// on indicates structure chained to next structure
+			if ((gdsFormatter & DssConstants.DSSCHAIN_SAME_ID) 
+					== DssConstants.DSSCHAIN_SAME_ID) 
+			{
+				dssIsChainedWithSameID = true;
+				dssIsChainedWithDiffID = false;
+			}
+			else 
+			{
+				dssIsChainedWithSameID = false;
+				dssIsChainedWithDiffID = true;
+			}
+		}
+		else 
+		{
+			dssIsChainedWithSameID = false;
+			dssIsChainedWithDiffID = false;
+		}
+
+		dssCorrelationID =
+			((buffer[pos++] & 0xff) << 8) +
+			((buffer[pos++] & 0xff) << 0);
+
+		if (SanityManager.DEBUG)					
+			trace("dssLength = " + dssLength + " correlationID = " + dssCorrelationID);
+
+		dssLength -= 6;
+
+	}
+
+	/**
+	 * Read the DDM Length and CodePoint
+	 *
+	 * @return - returns codepoint
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int readLengthAndCodePoint() throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (4, NO_ADJUST_LENGTHS);
+
+		ddmScalarLen =
+			((buffer[pos++] & 0xff) << 8) +
+			((buffer[pos++] & 0xff) << 0);
+
+		int codePoint =
+			((buffer[pos++] & 0xff) << 8) +
+			((buffer[pos++] & 0xff) << 0);
+		if (SanityManager.DEBUG)
+			trace("length = "+ ddmScalarLen + " codepoint = " + java.lang.Integer.toHexString(codePoint));
+		// SYNERRCD 0x0D - Object code point index not supported.
+		// the object codepoint index will not be checked here since
+		// the parse methods will catch any incorrect/unexpected codepoint values
+		// and report them as unsupported objects or parameters.
+
+		// Check if this DDM has extended length field
+		if ((ddmScalarLen & DssConstants.CONTINUATION_BIT) == DssConstants.CONTINUATION_BIT) 
+		{
+			int numberOfExtendedLenBytes = ((int)ddmScalarLen - 
+					DssConstants.CONTINUATION_BIT) - 4;
+			int adjustSize = 0;
+			ensureBLayerDataInBuffer (numberOfExtendedLenBytes, NO_ADJUST_LENGTHS);
+			switch (numberOfExtendedLenBytes) {
+			case 8:
+				 ddmScalarLen =
+					((buffer[pos++] & 0xff) << 64) +
+					((buffer[pos++] & 0xff) << 56) +
+					((buffer[pos++] & 0xff) << 48) +
+					((buffer[pos++] & 0xff) << 40) +
+					((buffer[pos++] & 0xff) << 32) +
+					((buffer[pos++] & 0xff) << 16) +
+					((buffer[pos++] & 0xff) << 8) +
+					((buffer[pos++] & 0xff) << 0);
+				adjustSize = 12;
+				break;
+			case 6:
+				ddmScalarLen =
+					((buffer[pos++] & 0xff) << 48) +
+					((buffer[pos++] & 0xff) << 40) +
+					((buffer[pos++] & 0xff) << 32) +
+					((buffer[pos++] & 0xff) << 16) +
+					((buffer[pos++] & 0xff) << 8) +
+					((buffer[pos++] & 0xff) << 0);
+				adjustSize = 10;
+				break;
+			case 4:
+				ddmScalarLen =
+					((buffer[pos++] & 0xff) << 32) +
+					((buffer[pos++] & 0xff) << 16) +
+					((buffer[pos++] & 0xff) << 8) +
+					((buffer[pos++] & 0xff) << 0);
+				adjustSize = 8;
+				break;
+			default:
+				agent.throwSyntaxrm(CodePoint.SYNERRCD_INCORRECT_EXTENDED_LEN,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+		}
+
+			// adjust the lengths here.	this is a special case since the
+			// extended length bytes do not include their own length.
+			for (int i = 0; i <= topDdmCollectionStack; i++) {
+				ddmCollectionLenStack[i] -= adjustSize;
+			}
+			dssLength -= adjustSize;
+		}
+		else {
+			if (ddmScalarLen < 4)
+				agent.throwSyntaxrm(CodePoint.SYNERRCD_OBJ_LEN_LESS_THAN_4,
+								   DRDAProtocolException.NO_CODPNT_ARG);
+			adjustLengths (4);
+		}
+		return codePoint;
+	}
+
+	/**
+	 * Read the CodePoint
+	 *
+	 * @return - returns codepoint
+	 */
+	protected int readCodePoint()
+	{
+		return( ((buffer[pos++] & 0xff) << 8) +
+		  ((buffer[pos++] & 0xff) << 0));
+	}
+
+	/**
+	 * Push DDM Length on to collection stack
+	 */
+	protected void markCollection()
+	{
+		ddmCollectionLenStack[++topDdmCollectionStack] = ddmScalarLen;
+		ddmScalarLen = 0;
+	}
+
+	/**
+	 * 	Get the next CodePoint from a collection
+	 * 	@return	NO_CODEPOINT if collection stack is empty or remaining length is
+	 *		0; otherwise,  read length and code point
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int getCodePoint() throws DRDAProtocolException
+	{
+		if (topDdmCollectionStack == EMPTY_STACK) 
+		{
+			return NO_CODEPOINT;
+		}
+		else 
+		{
+			// if the collecion is exhausted then return NO_CODEPOINT
+			if (ddmCollectionLenStack[topDdmCollectionStack] == 0) 
+			{
+				// done with this collection so remove it's length from the stack
+				ddmCollectionLenStack[topDdmCollectionStack--] = 0;
+				return NO_CODEPOINT;
+			}
+			else {
+				return readLengthAndCodePoint();
+			}
+		}
+	}
+	/**
+	 * Get the next CodePoint from a collection and check that it matches the specified
+	 * 	CodePoint
+	 * @param	codePointCheck	- codePoint to check against
+	 * @return	codePoint
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int getCodePoint(int codePointCheck) throws DRDAProtocolException
+	{
+		int codePoint = getCodePoint();
+		if (codePoint != codePointCheck)
+			agent.missingCodePoint(codePoint);
+		return codePoint;
+	}
+	/**
+	 * The following routines read different types from the input stream
+	 * Data can be in network order or platform order depending on whether the
+	 * data is part of the protocol or data being received
+	 * The platform is determined by EXCSAT protocol
+	 */
+
+	/**
+	 * Read byte value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected byte readByte () throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (1, ADJUST_LENGTHS);
+		return (byte) (buffer[pos++] & 0xff);
+	}
+
+	/**
+	 * Read byte value and mask out high order bytes before returning
+	 * @return value
+	 */
+	protected int readUnsignedByte () throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (1, ADJUST_LENGTHS);
+		return (int ) (buffer[pos++] & 0xff);
+	}
+
+	/**
+	 * Read network short value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int readNetworkShort () throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (2, ADJUST_LENGTHS);
+		return ((buffer[pos++] & 0xff) << 8) +
+		  ((buffer[pos++] & 0xff) << 0);
+	}
+
+	/**
+	 * Read signed network short value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int readSignedNetworkShort () throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (2, ADJUST_LENGTHS);
+		return (short)(((buffer[pos++] & 0xff) << 8) +
+		  ((buffer[pos++] & 0xff) << 0));
+	}
+	/**
+	 * Read platform short value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected short readShort (int byteOrder) throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (2, ADJUST_LENGTHS);
+		short s = SignedBinary.getShort (buffer, pos, byteOrder);
+
+		pos += 2;
+
+		return s;
+	}
+
+	/**
+	 * Read network int value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int readNetworkInt () throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (4, ADJUST_LENGTHS);
+		return ((buffer[pos++] & 0xff) << 24) +
+		       ((buffer[pos++] & 0xff) << 16) +
+		       ((buffer[pos++] & 0xff) << 8) +
+		       ((buffer[pos++] & 0xff) << 0);
+	}
+
+	/**
+	 * Read platform int value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected int readInt (int byteOrder) throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (4, ADJUST_LENGTHS);
+		int i = SignedBinary.getInt (buffer, pos, byteOrder);
+
+		pos += 4;
+
+		return i;
+	}
+
+	/**
+	 * Read network long value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected long readNetworkLong () throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (8, ADJUST_LENGTHS);
+
+		return ((buffer[pos++] & 0xffL) << 56) +
+		       ((buffer[pos++] & 0xffL) << 48) +
+		       ((buffer[pos++] & 0xffL) << 40) +
+		       ((buffer[pos++] & 0xffL) << 32) +
+		       ((buffer[pos++] & 0xffL) << 24) +
+		       ((buffer[pos++] & 0xffL) << 16) +
+		       ((buffer[pos++] & 0xffL) << 8) +
+		       ((buffer[pos++] & 0xffL) << 0);
+	}
+
+	
+	/**
+	 * Read network six byte value and put it in a long v
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected long readNetworkSixByteLong() throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (6, ADJUST_LENGTHS);
+
+		return (
+				((buffer[pos++] & 0xffL) << 40) +
+		       ((buffer[pos++] & 0xffL) << 32) +
+		       ((buffer[pos++] & 0xffL) << 24) +
+		       ((buffer[pos++] & 0xffL) << 16) +
+		       ((buffer[pos++] & 0xffL) << 8) +
+		       ((buffer[pos++] & 0xffL) << 0));
+	}
+
+	/**
+	 * Read platform long value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected long readLong (int byteOrder) throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (8, ADJUST_LENGTHS);
+		long l = SignedBinary.getLong (buffer, pos, byteOrder);
+
+		pos += 8;
+
+		return l;
+	}
+
+	/**
+	 * Read platform float value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected float readFloat(int byteOrder) throws DRDAProtocolException
+	{
+		return Float.intBitsToFloat(readInt(byteOrder));
+	}
+
+	/**
+	 * Read platform double value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected double readDouble(int byteOrder) throws DRDAProtocolException
+	{
+		return Double.longBitsToDouble(readLong(byteOrder));
+	}
+
+	/**
+	 * Read a BigDecimal value
+	 * @param	precision of the BigDecimal
+	 * @param	scale of the BigDecimal
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected BigDecimal readBigDecimal(int precision, int scale) throws DRDAProtocolException
+    {
+      // The byte-length of a packed decimal with precision p is always p/2 + 1
+      int length = precision / 2 + 1;
+
+	  ensureBLayerDataInBuffer (length, ADJUST_LENGTHS);
+
+      // check for sign.
+      int signum;
+      if ((buffer[pos+length-1] & 0x0F) == 0x0D)
+        signum = -1;
+      else
+        signum =  1;
+
+      if (precision <= 9) {
+        // can be handled by int without overflow.
+        int value = packedNybblesToInt(buffer, pos, 0, length*2-1);
+
+        // convert value to a byte array of magnitude.
+        byte[] magnitude = new byte[4];
+        magnitude[0] = (byte)(value >>> 24);
+        magnitude[1] = (byte)(value >>> 16);
+        magnitude[2] = (byte)(value >>> 8);
+        magnitude[3] = (byte)(value);
+
+		pos += length;
+        return new java.math.BigDecimal (new java.math.BigInteger(signum, magnitude), scale);
+      }
+      else if (precision <= 18) {
+        // can be handled by long without overflow.
+        long value = packedNybblesToLong(buffer, pos, 0, length*2-1);
+
+        // convert value to a byte array of magnitude.
+        byte[] magnitude = new byte[8];
+        magnitude[0] = (byte)(value >>> 56);
+        magnitude[1] = (byte)(value >>> 48);
+        magnitude[2] = (byte)(value >>> 40);
+        magnitude[3] = (byte)(value >>> 32);
+        magnitude[4] = (byte)(value >>> 24);
+        magnitude[5] = (byte)(value >>> 16);
+        magnitude[6] = (byte)(value >>>  8);
+        magnitude[7] = (byte)(value);
+
+		pos += length;
+        return new java.math.BigDecimal (new java.math.BigInteger(signum, magnitude), scale);
+      }
+      else if (precision <= 27) {
+        // get the value of last 9 digits (5 bytes).
+        int lo = packedNybblesToInt(buffer, pos, (length-5)*2, 9);
+        // get the value of another 9 digits (5 bytes).
+        int me = packedNybblesToInt(buffer, pos, (length-10)*2+1, 9);
+        // get the value of the rest digits.
+        int hi = packedNybblesToInt(buffer, pos, 0, (length-10)*2+1);
+
+        // compute the int array of magnitude.
+        int[] value = computeMagnitude(new int[] {hi, me, lo});
+
+        // convert value to a byte array of magnitude.
+        byte[] magnitude = new byte[12];
+        magnitude[0]  = (byte)(value[0] >>> 24);
+        magnitude[1]  = (byte)(value[0] >>> 16);
+        magnitude[2]  = (byte)(value[0] >>> 8);
+        magnitude[3]  = (byte)(value[0]);
+        magnitude[4]  = (byte)(value[1] >>> 24);
+        magnitude[5]  = (byte)(value[1] >>> 16);
+        magnitude[6]  = (byte)(value[1] >>> 8);
+        magnitude[7]  = (byte)(value[1]);
+        magnitude[8]  = (byte)(value[2] >>> 24);
+        magnitude[9]  = (byte)(value[2] >>> 16);
+        magnitude[10] = (byte)(value[2] >>> 8);
+        magnitude[11] = (byte)(value[2]);
+
+		pos += length;
+        return new java.math.BigDecimal (new java.math.BigInteger(signum, magnitude), scale);
+      }
+      else if (precision <= 31) {
+        // get the value of last 9 digits (5 bytes).
+        int lo   = packedNybblesToInt(buffer, pos, (length-5)*2, 9);
+        // get the value of another 9 digits (5 bytes).
+        int meLo = packedNybblesToInt(buffer, pos, (length-10)*2+1, 9);
+        // get the value of another 9 digits (5 bytes).
+        int meHi = packedNybblesToInt(buffer, pos, (length-14)*2, 9);
+        // get the value of the rest digits.
+        int hi   = packedNybblesToInt(buffer, pos, 0, (length-14)*2);
+
+        // compute the int array of magnitude.
+        int[] value = computeMagnitude(new int[] {hi, meHi, meLo, lo});
+
+        // convert value to a byte array of magnitude.
+        byte[] magnitude = new byte[16];
+        magnitude[0]  = (byte)(value[0] >>> 24);
+        magnitude[1]  = (byte)(value[0] >>> 16);
+        magnitude[2]  = (byte)(value[0] >>> 8);
+        magnitude[3]  = (byte)(value[0]);
+        magnitude[4]  = (byte)(value[1] >>> 24);
+        magnitude[5]  = (byte)(value[1] >>> 16);
+        magnitude[6]  = (byte)(value[1] >>> 8);
+        magnitude[7]  = (byte)(value[1]);
+        magnitude[8]  = (byte)(value[2] >>> 24);
+        magnitude[9]  = (byte)(value[2] >>> 16);
+        magnitude[10] = (byte)(value[2] >>> 8);
+        magnitude[11] = (byte)(value[2]);
+        magnitude[12] = (byte)(value[3] >>> 24);
+        magnitude[13] = (byte)(value[3] >>> 16);
+        magnitude[14] = (byte)(value[3] >>> 8);
+        magnitude[15] = (byte)(value[3]);
+
+		pos += length;
+        return new java.math.BigDecimal (new java.math.BigInteger(signum, magnitude), scale);
+      }
+      else {
+		pos += length;
+        // throw an exception here if nibbles is greater than 31
+        throw new java.lang.IllegalArgumentException("Decimal may only be up to 31 digits!");
+      }
+    }
+
+	
+
+	byte[] getExtData (boolean checkNullability) throws DRDAProtocolException
+	{
+		return  getExtData(ddmScalarLen, checkNullability);
+	}
+
+
+	byte[] getExtData (long desiredLength, boolean checkNullability) throws DRDAProtocolException
+  {
+    boolean readHeader;
+    int copySize;
+    ByteArrayOutputStream baos;
+    boolean isLengthAndNullabilityUnknown = false;
+
+	
+	if (desiredLength != -1) {
+        // allocate a stream based on a known amount of data
+        baos = new ByteArrayOutputStream ((int) desiredLength);
+	}
+	else {
+        // allocate a stream to hold an unknown amount of data
+        baos = new ByteArrayOutputStream ();
+        //isLengthAndNullabilityUnknown = true;
+		// If we aren't given a  length get the whole thing.
+		desiredLength = MAX_EXTDTA_SIZE;
+	}
+	
+
+    // check for a null EXTDTA value, if it is nullable and if streaming
+    if (checkNullability)
+      if (isEXTDTANull())
+        return null;
+
+    // set the amount to read for the first segment
+	copySize = (int) Math.min(dssLength,desiredLength); //note: has already been adjusted for headers
+
+
+    //if (checkNullability)  // don't count the null byte we've already read
+	//copySize--;
+
+    do {
+      // determine if a continuation header needs to be read after the data
+      if (dssIsContinued)
+        readHeader = true;
+      else
+        readHeader = false;
+
+      // read the segment
+      ensureALayerDataInBuffer (copySize);
+      adjustLengths (copySize);
+      baos.write (buffer, pos, copySize);
+      pos += copySize;
+	  desiredLength -= copySize;
+
+      // read the continuation header, if necessary
+      if (readHeader)
+        readDSSContinuationHeader ();
+
+	  copySize = (int) Math.min(dssLength,desiredLength); //note: has already been adjusted for headers
+
+    }
+    while (readHeader == true && desiredLength > 0);
+
+    return baos.toByteArray();
+  }
+
+
+  // reads a DSS continuation header
+  // prereq: pos is positioned on the first byte of the two-byte header
+  // post:   dssIsContinued is set to true if the continuation bit is on, false otherwise
+  //         dssLength is set to DssConstants.MAXDSS_LEN - 2 (don't count the header for the next read)
+  // helper method for getEXTDTAData
+	private void readDSSContinuationHeader () throws DRDAProtocolException
+  {
+    ensureALayerDataInBuffer(2);
+
+    dssLength =
+      ((buffer[pos++]&0xFF) << 8) +
+      ((buffer[pos++]&0xFF) << 0);
+
+    if ((dssLength & 0x8000) == 0x8000) {
+      dssLength = DssConstants.MAX_DSS_LENGTH;
+      dssIsContinued = true;
+    }
+    else {
+      dssIsContinued = false;
+    }
+    // it is a syntax error if the dss continuation header length
+    // is less than or equal to two
+    if (dssLength <= 2) {
+		agent.throwSyntaxrm(CodePoint.SYNERRCD_DSS_CONT_LESS_OR_EQUAL_2,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+    }
+
+    dssLength -= 2;  // avoid consuming the DSS cont header
+  }
+
+// checks the null EXTDTA byte
+  // returns true if null, false otherwise
+  // helper method for getEXTDTAData
+  private boolean isEXTDTANull () throws DRDAProtocolException
+  {
+    // make sure that the null byte is in the buffer
+    ensureALayerDataInBuffer (1);
+    adjustLengths (1);
+
+    // examine the null byte
+    byte nullByte = buffer[pos++];
+    if (nullByte == (byte)0x00)
+      return false;
+
+    return true;
+  }
+
+
+   /**
+    * Convert a range of packed nybbles (up to 9 digits without overflow) to an int.
+    * Note that for performance purpose, it does not do array-out-of-bound checking.
+	* @param	buffer to read from
+	* @param	offset in the buffer
+	* @param	start nybble
+	* @param	number of nybbles
+	* @return	an int value
+    */
+    private int packedNybblesToInt (byte[] buffer,
+                                         int offset,
+                                         int startNybble,
+                                         int numberOfNybbles)
+    {
+      int value = 0;
+
+      int i = startNybble / 2;
+      if ((startNybble % 2) != 0) {
+        // process low nybble of the first byte if necessary.
+        value += buffer[offset+i] & 0x0F;
+        i++;
+      }
+
+      int endNybble = startNybble + numberOfNybbles -1;
+      for (; i<(endNybble+1)/2; i++) {
+        value = value*10 + ((buffer[offset+i] & 0xF0) >>> 4); // high nybble.
+        value = value*10 +  (buffer[offset+i] & 0x0F);        // low nybble.
+      }
+
+      if ((endNybble % 2) == 0) {
+        // process high nybble of the last byte if necessary.
+        value = value*10 + ((buffer[offset+i] & 0xF0) >>> 4);
+      }
+
+      return value;
+    }
+
+    /**
+     * Convert a range of packed nybbles (up to 18 digits without overflow) to a long.
+     * Note that for performance purpose, it does not do array-out-of-bound checking.
+	 * @param	buffer to read from
+	 * @param	offset in the buffer
+	 * @param	start nybble
+	 * @param	number of nybbles
+	 * @return	an long value
+     */
+    private long packedNybblesToLong (byte[] buffer,
+                                           int offset,
+                                           int startNybble,
+                                           int numberOfNybbles)
+    {
+      long value = 0;
+
+      int i = startNybble / 2;
+      if ((startNybble % 2) != 0) {
+        // process low nybble of the first byte if necessary.
+        value += buffer[offset+i] & 0x0F;
+        i++;
+      }
+
+      int endNybble = startNybble + numberOfNybbles -1;
+      for (; i<(endNybble+1)/2; i++) {
+        value = value*10 + ((buffer[offset+i] & 0xF0) >>> 4); // high nybble.
+        value = value*10 +  (buffer[offset+i] & 0x0F);        // low nybble.
+      }
+
+      if ((endNybble % 2) == 0) {
+        // process high nybble of the last byte if necessary.
+        value = value*10 + ((buffer[offset+i] & 0xF0) >>> 4);
+      }
+
+ 	  return value;
+	}
+
+    /**
+     * Compute the int array of magnitude from input value segments.
+	 * @param	input value segments
+	 * @return	array of int magnitudes
+     */
+    private int[] computeMagnitude(int[] input)
+    {
+        int length = input.length;
+        int[] mag = new int[length];
+
+        mag[length-1] = input[length-1];
+        for (int i=0; i<length-1; i++) {
+          int carry = 0;
+          int j = tenRadixMagnitude[i].length-1;
+          int k = length-1;
+          for (; j>=0; j--, k--) {
+            long product = (input[length-2-i] & 0xFFFFFFFFL) * (tenRadixMagnitude[i][j] & 0xFFFFFFFFL)
+                         + (mag[k] & 0xFFFFFFFFL) // add previous value
+                         + (carry & 0xFFFFFFFFL); // add carry
+            carry  = (int) (product >>> 32);
+            mag[k] = (int) (product & 0xFFFFFFFFL);
+          }
+          mag[k] = (int) carry;
+        }
+        return mag;
+    }
+
+	/**
+	 * Read boolean value
+	 * @return	value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected boolean readBoolean () throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (1, ADJUST_LENGTHS);
+		return buffer[pos++] != 0;
+	}
+
+	/**
+	 * Read encrypted string
+	 * @param   decryptM  decryption manager
+	 * @param   security mechanism
+	 * @param   initVector   initialization vector for cipher
+	 * @param   sourcePublicKey  public key (as in Deffie-Hellman algorithm)
+	 *                           from source (encryptor)
+	 * @return  decrypted string
+	 *
+	 * @exception DRDProtocolException, SQLException(wrapping any exception in decryption)
+	 */
+	protected String readEncryptedString (DecryptionManager decryptM, int securityMechanism,
+										 byte[] initVector, byte[] sourcePublicKey)
+			throws DRDAProtocolException, java.sql.SQLException
+	{
+		byte[] cipherText = readBytes();
+		byte[] plainText = null;
+		plainText = decryptM.decryptData(cipherText, securityMechanism, initVector,
+											 sourcePublicKey);
+		if (plainText == null)
+			return null;
+		else
+			return ccsidManager.convertToUCS2(plainText);
+	}
+
+	/**
+	 * Read string value
+	 * Strings in DRDA protocol are encoded in EBCDIC by default so we
+	 * need to convert to UCS2
+	 * @param length  - length of string to read
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readString (int length) throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (length, ADJUST_LENGTHS);
+
+		String result = ccsidManager.convertToUCS2 (buffer, pos, length);
+		pos += length;
+		return result;
+	}
+
+	/**
+	 * Read encoded string value
+	 * @param length  - length of string to read
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readString (int length, String encoding) 
+		throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (length, ADJUST_LENGTHS);
+		String s = null;
+
+		try {
+		  s = new String (buffer, pos, length, encoding);
+		}
+		catch (java.io.UnsupportedEncodingException e) {
+			agent.agentError("UnsupportedEncodingException in readString, encoding = " 
+					+ encoding);
+			e.printStackTrace(agent.getServer().logWriter);
+		}
+		
+		pos += length;
+		return s;
+	}
+
+	/**
+	 * Read string value in DDM data with default encoding
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readStringData()
+		throws DRDAProtocolException
+	{
+		return readString((int)ddmScalarLen, DB2jServerImpl.DEFAULT_ENCODING);
+	}
+
+	/**
+	 * Read specified length of string value in DDM data with default encoding
+	 * @param length  - length of string to read
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readStringData(int length)
+		throws DRDAProtocolException
+	{
+		return readString(length, DB2jServerImpl.DEFAULT_ENCODING);
+	}
+
+	/**
+	 * Read length delimited string value in DDM data with default encoding
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readLDStringData(String encoding)
+		throws DRDAProtocolException
+	{
+		int length = readNetworkShort();
+		return readString(length, encoding);
+	}
+
+	/**
+	 * Read string value
+	 * @param length  - length of string to read
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readString () throws DRDAProtocolException
+	{
+		return readString((int)ddmScalarLen);
+	}
+
+	/**
+	 * Read byte string value
+	 * @param length  - length of string to read
+	 * @return byte array
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected byte[] readBytes (int length) throws DRDAProtocolException
+	{
+		byte[] b;
+
+		if (length < dssLength)
+		{
+			ensureBLayerDataInBuffer (length, ADJUST_LENGTHS);
+		    b = new byte[length];
+			System.arraycopy(buffer,pos,b,0,length);
+			pos +=length;
+		}
+		else
+			b = getExtData(length,false);
+		return b;
+	}
+	
+	/**
+	 * Read byte string value
+	 * @return byte array
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected byte[] readBytes () throws DRDAProtocolException
+	{
+		return readBytes((int)ddmScalarLen);
+	}
+
+	/**
+	 * Skip byte string value
+	 * @param length  - length of string to skip
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected void skipBytes (int length) throws DRDAProtocolException
+	{
+		ensureBLayerDataInBuffer (length, ADJUST_LENGTHS);
+		pos += length;
+	}
+
+	/**
+	 * Skip byte string value
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	protected void skipBytes () throws DRDAProtocolException
+	{
+		skipBytes((int)ddmScalarLen);
+	}
+
+	/**
+	 * Skip remaining DSS
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	protected void skipDss() throws DRDAProtocolException
+	{
+		skipBytes((int)dssLength);
+		topDdmCollectionStack = EMPTY_STACK;
+		ddmScalarLen = 0;
+		dssLength = 0;
+
+	}
+
+	protected void clearBuffer() throws DRDAProtocolException
+	{
+		skipBytes(java.lang.Math.min(dssLength, count - pos));
+	}
+
+	/**
+	 * Convert EBCDIC byte array to unicode string
+	 *
+	 * @param 	buf	- byte array
+	 * @return string
+	 */
+	protected String convertBytes(byte[] buf)
+	{
+		return ccsidManager.convertToUCS2 (buf, 0, buf.length);
+	}
+
+	// Private methods
+	/**
+	 * Adjust remaining length
+	 *
+	 * @param length - adjustment length
+	 */
+	private void adjustLengths(int length)
+	{
+		ddmScalarLen -= length;
+		for (int i = 0; i <= topDdmCollectionStack; i++) {
+		  ddmCollectionLenStack[i] -= length;
+		}
+		dssLength -= length;
+	}
+
+	/********************************************************************/
+	/*   NetworkServerControl  command protocol reading routines        
+	 */
+	/********************************************************************/
+	/**
+	 * Read string value
+	 * @param length  - length of string to read
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readCmdString (int length) throws DRDAProtocolException, java.io.UnsupportedEncodingException
+	{
+		if (length == 0)
+			return null;
+
+		ensureBLayerDataInBuffer (length, ADJUST_LENGTHS);
+		String result = new String (buffer, pos, length,
+										DB2jServerImpl.DEFAULT_ENCODING);
+		pos += length;
+		return result;
+	}
+	/**
+	 * Read string value
+	 * @return value
+	 *
+	 * @exception DRDProtocolException
+	 */
+	protected String readCmdString () throws DRDAProtocolException, java.io.UnsupportedEncodingException
+	{
+		int length = readNetworkShort();
+		return readCmdString(length);
+		
+	}
+
+	/**************************************************************************/
+	/*   Private methods
+	/**************************************************************************/
+	/**
+	 * Make sure a certain amount of Layer A data is in the buffer.
+	 * The data will be in the buffer after this method is called.
+	 *
+	 * @param desiredDataSize - amount of data we need
+	 *
+	 * @exception	DRDAProtocolException
+	 */
+	private void ensureALayerDataInBuffer (int desiredDataSize) 
+		throws DRDAProtocolException
+	{
+		// calulate the the number of bytes in the buffer.
+		int avail = count - pos;
+
+		// read more bytes off the network if the data is not in the buffer already.
+		if (avail < desiredDataSize) 
+		{
+		  fill (desiredDataSize - avail);
+		}
+	}
+	/**
+	 * Make sure a certain amount of Layer B data is in the buffer.
+	 * The data will be in the buffer after this method is called.
+	 *
+	 * @param desiredDataSize - amount of data we need
+	 * @param adjustLen	- whether to adjust the remaining lengths
+	 *
+	 * @exception DRDProtocolException
+	 */
+	private void ensureBLayerDataInBuffer (int desiredDataSize, boolean adjustLen) 
+		throws DRDAProtocolException
+	{
+		if (dssIsContinued) 
+		{
+			if (desiredDataSize > dssLength) 
+			{
+				int continueDssHeaderCount =
+					(((desiredDataSize - dssLength) / DssConstants.MAX_DSS_LENGTH) + 1);
+				compressBLayerData (continueDssHeaderCount);
+			}
+		}
+		else 
+		{
+			ensureALayerDataInBuffer (desiredDataSize);
+		}
+		if (adjustLen)
+			adjustLengths(desiredDataSize);
+	}
+
+	/**
+	 * Compress B Layer data if extended total length is used
+	 * by removing the continuation headers
+	 *
+	 * @param continueDssHeaderCount - amount of data we need
+	 *
+	 * @exception	throws DRDAProtocolException
+	 */
+	private void compressBLayerData (int continueDssHeaderCount) 
+		throws DRDAProtocolException
+	{
+
+		
+		// jump to the last continuation header.
+		int tempPos = 0;
+		for (int i = 0; i < continueDssHeaderCount; i++) 
+		{
+			// the first may be less than the size of a full DSS
+			if (i == 0) 
+			{
+				// only jump by the number of bytes remaining in the current DSS
+				tempPos = pos + dssLength;
+			}
+			else 
+			{
+				// all other jumps are for a full continued DSS
+				tempPos += DssConstants.MAX_DSS_LENGTH;
+			}
+		}
+
+
+		// for each of the DSS headers to remove,
+		// read out the continuation header and increment the DSS length by the
+		// size of the continuation bytes,	then shift the continuation data as needed.
+		int shiftSize = 0;
+		int bytesToShift = 0;
+		int continueHeaderLength = 0;
+		int newdssLength = 0;
+
+
+		for (int i = 0; i < continueDssHeaderCount; i++) 
+		{
+			continueHeaderLength = ((buffer[tempPos] & 0xff) << 8) +
+				((buffer[tempPos + 1] & 0xff) << 0);
+
+			if (i == 0) 
+			{
+				// if this is the last one (farthest down stream and first to strip out)
+
+				if ((continueHeaderLength & DssConstants.CONTINUATION_BIT) 
+						== DssConstants.CONTINUATION_BIT)
+				{
+				  // the last DSS header is again continued
+				  continueHeaderLength = DssConstants.MAX_DSS_LENGTH;
+				  dssIsContinued = true;
+				}
+				else 
+				{
+				  // the last DSS header was not contiued so update continue state flag
+				  dssIsContinued = false;
+				}
+				// the very first shift size is 2
+				shiftSize = 2;
+			}
+			else 
+			{
+				// already removed the last header so make sure the chaining flag is on
+				if ((continueHeaderLength & DssConstants.CONTINUATION_BIT) == 
+						DssConstants.CONTINUATION_BIT)
+				{
+				  continueHeaderLength = DssConstants.MAX_DSS_LENGTH;
+				}
+				else 
+				{
+				  // this is a syntax error but not really certain which one.
+				  // for now pick 0x02 which is DSS header Length does not 
+				  // match the number
+				    // of bytes of data found.
+					agent.throwSyntaxrm(CodePoint.SYNERRCD_DSS_LENGTH_BYTE_NUMBER_MISMATCH,
+									   DRDAProtocolException.NO_CODPNT_ARG);
+				}
+				// increase the shift size by 2
+				shiftSize += 2;
+			}
+
+			// it is a syntax error if the DSS continuation is less 
+			// than or equal to two
+			if (continueHeaderLength <= 2) 
+			{
+				agent.throwSyntaxrm(CodePoint.SYNERRCD_DSS_CONT_LESS_OR_EQUAL_2,
+							   DRDAProtocolException.NO_CODPNT_ARG);
+			}
+
+			newdssLength += continueHeaderLength;
+
+			// calculate the number of bytes to shift
+			if (i == (continueDssHeaderCount - 1))
+				bytesToShift = DssConstants.MAX_DSS_LENGTH;
+			else
+				bytesToShift = dssLength;
+
+			tempPos -= (shiftSize - 1);
+			System.arraycopy(buffer, tempPos, buffer, tempPos - bytesToShift +
+							 shiftSize , bytesToShift);
+			tempPos -= bytesToShift;
+			tempPos += (shiftSize + 1);
+		}
+		// reposition the start of the data after the final DSS shift.
+		pos = tempPos;
+	}
+
+	/**
+	 * Methods to manage the data buffer.
+	 * Methods orginally from JCC
+	 * RESOLVE: need to check if this is the best performing way of doing this
+	 */
+
+	/**
+	 * This is a helper method which shifts the buffered bytes from
+	 * wherever they are in the current buffer to the beginning of
+	 * different buffer (note these buffers could be the same).
+	 * State information is updated as needed after the shift.
+	 * @param destinationBuffer - buffer to shift data to
+	 */
+	private void shiftBuffer (byte[] destinationBuffer)
+	{
+		// calculate the size of the data in the current buffer.
+		int sz = count - pos;
+		if (SanityManager.DEBUG) {
+			if ((sz < 0 || pos < 0) )
+			{
+				SanityManager.THROWASSERT(
+					      "Unexpected data size or position. sz=" + sz + 
+						  " count=" + count +" pos=" + pos);
+			}
+		}
+		
+		// copy this data to the new buffer startsing at position 0.
+		System.arraycopy (buffer, pos, destinationBuffer, 0, sz);
+
+		// update the state information for data in the new buffer.
+		pos = 0;
+		count = sz;
+
+		// replace the old buffer with the new buffer.
+		buffer = destinationBuffer;
+	}
+	/**
+	 * This method makes sure there is enough room in the buffer
+	 * for a certain number of bytes.  This method will allocate
+	 * a new buffer if needed and shift the bytes in the current buffer
+	 * to make ensure space is available for a fill.  Right now
+	 * this method will shift bytes as needed to make sure there is
+	 * as much room as possible in the buffer before trying to
+	 * do the read.  The idea is to try to have space to get as much data as possible
+	 * if we need to do a read on the socket's stream.
+	 *
+	 * @param desiredSpace - amount of data we need
+	 */
+	private void ensureSpaceInBufferForFill (int desiredSpace)
+	{
+		// calculate the total unused space in the buffer.
+		// this includes any space at the end of the buffer and any free
+		// space at the beginning resulting from bytes already read.
+		int currentAvailableSpace = (buffer.length - count) + pos;
+
+		// check to see if there is enough free space.
+		if (currentAvailableSpace < desiredSpace) {
+
+			// there is not enough free space so we need more storage.
+			// we are going to double the buffer unless that happens to still be 
+			// too small. If more than double the buffer is needed, 
+			// use the smallest amount over this as possible.
+			int doubleBufferSize = (2 * buffer.length);
+			int minumNewBufferSize = (desiredSpace - currentAvailableSpace) + 
+				buffer.length;
+			int newsz = minumNewBufferSize <= doubleBufferSize ? 
+				doubleBufferSize : minumNewBufferSize;
+
+			byte[] newBuffer = new byte[newsz];
+
+			// shift everything from the old buffer to the new buffer
+			shiftBuffer (newBuffer);
+		}
+		else {
+
+			// there is enough free space in the buffer but let's make sure
+			// it is all at the end.
+			// this is also important because if we are going to do a read, 
+			// it would be nice
+			// to get as much data as possible and making room at the end 
+			// if the buffer helps to ensure this.
+			if (pos != 0) {
+				shiftBuffer (buffer);
+			}
+		}
+	}
+
+	/**
+	 * This method will attempt to read a minimum number of bytes
+	 * from the underlying stream.	This method will keep trying to
+	 * read bytes until it has obtained at least the minimum number.
+	 * @param minimumBytesNeeded - minimum required bytes
+	 *
+	 * @exception DRDProtocolException
+	 */
+	private void fill (int minimumBytesNeeded) throws DRDAProtocolException
+	{
+		// make sure that there is enough space in the buffer to hold
+		// the minimum number of bytes needed.
+		ensureSpaceInBufferForFill (minimumBytesNeeded);
+
+		// read until the minimum number of bytes needed is now in the buffer.
+		// hopefully the read method will return as many bytes as it can.
+		int totalBytesRead = 0;
+		int actualBytesRead = 0;
+		do {
+			try {
+				actualBytesRead = inputStream.read (
+				  buffer, count, buffer.length - count);
+			}
+			catch (java.io.IOException ioe) {
+				agent.markCommunicationsFailure ("DDMReader.fill()",
+				  "InputStream.read()", ioe.getMessage(), "*");
+			}
+			finally {
+				if ((dssTrace != null) && dssTrace.isComBufferTraceOn())
+				  dssTrace.writeComBufferData (buffer,
+				                               count,
+				                               actualBytesRead,
+				                               DssTrace.TYPE_TRACE_RECEIVE,
+				                               "Request",
+				                               "fill",
+				                               5);
+			}
+			count += actualBytesRead;
+			totalBytesRead += actualBytesRead;
+
+		}
+		while ((totalBytesRead < minimumBytesNeeded) && (actualBytesRead != -1));
+		if (actualBytesRead == -1) 
+		{
+			if (totalBytesRead < minimumBytesNeeded) 
+			{
+				agent.markCommunicationsFailure ("DDMReader.fill()",
+				  "InputStream.read()", "insufficient data", "*");
+			}
+		}
+	}
+
+	/**
+	 * Print a internal trace message
+	 */
+	private void trace(String msg)
+	{
+		if (agent != null)
+			agent.trace(msg);
+	}
+
+	protected String toDebugString(String indent)
+	{
+		String s = indent + "***** DDMReader toDebugString ******\n";
+		int buflen = 0;
+		if (buffer != null)
+			buflen = buffer.length;
+	   s += indent + "Reader buffer length = " + buffer.length + "\n";
+	   return s;
+	}
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,1694 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.io.OutputStream;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import java.sql.SQLException;
+import java.sql.DataTruncation;
+import java.math.BigDecimal;
+import org.apache.derby.iapi.error.ExceptionSeverity;
+import java.util.Arrays;
+
+/**
+	The DDMWriter is used to write DRDA protocol.   The DRDA Protocol is
+	described in the DDMReader class.
+	For more details, see DRDA Volume 3 (Distributed Data Management(DDM)
+		Architecture (DDS definition)
+*/
+class DDMWriter
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+
+	// number of nesting levels for collections.  We need to mark the length
+	// location of the collection so that we can update it as we add more stuff
+	// to the collection
+	private final static int MAX_MARKS_NESTING = 10;
+
+	// Default buffer size
+	private final static int DEFAULT_BUFFER_SIZE = 32767;
+
+
+	static final BigDecimal ZERO = BigDecimal.valueOf(0L);
+
+	// output buffer
+	private byte[] bytes;
+
+	// offset into output buffer
+	private int offset;
+
+	// A saved mark in the stream is saved temporarily to revisit the location.
+	private int[] markStack = new int[MAX_MARKS_NESTING];
+
+	// top of the stack
+	private int top;
+
+	private boolean simpleDssFinalize = false;
+
+	// CCSID manager for translation of strings in the protocol to EBCDIC
+	private CcsidManager ccsidManager;
+
+	// DRDA connection thread for this writer
+	private DRDAConnThread agent;
+
+	//	This Object tracks the location of the current
+	//	Dss header length bytes.	This is done so
+	//	the length bytes can be automatically
+	//	updated as information is added to this stream.
+	private int dssLengthLocation;
+
+	// Current correlation ID
+	private	int correlationID;
+
+	// Next correlation ID
+	private int nextCorrelationID;
+
+	// is this DRDA protocol or CMD protocol
+	private boolean isDRDAProtocol;
+	// trace object of the associated session
+	private DssTrace dssTrace;
+
+
+
+	// Constructors
+	DDMWriter (int minSize, CcsidManager ccsidManager, DRDAConnThread agent, DssTrace dssTrace)
+	{
+		this.bytes = new byte[minSize];
+		this.ccsidManager = ccsidManager;
+		this.agent = agent;
+		reset(dssTrace);
+	}
+
+	DDMWriter (CcsidManager ccsidManager, DRDAConnThread agent, DssTrace dssTrace)
+	{
+		this.bytes = new byte[DEFAULT_BUFFER_SIZE];
+		this.ccsidManager = ccsidManager;
+		this.agent = agent;
+		reset(dssTrace);
+	}
+
+	/**
+	 * reset values for sending next message
+	 *
+	 */
+	protected void reset(DssTrace dssTrace)
+	{
+		offset = 0;
+		top = 0;
+		dssLengthLocation = 0;
+		nextCorrelationID = 1;
+		correlationID = DssConstants.CORRELATION_ID_UNKNOWN;
+		isDRDAProtocol = true;
+		this.dssTrace = dssTrace;
+	}
+
+	/**
+	 * set protocol to CMD protocol
+	 */
+	protected void setCMDProtocol()
+	{
+		isDRDAProtocol = false;
+	}
+
+	/**
+	 * Create DSS reply object
+	 */
+	protected void createDssReply()
+	{
+		// finish off previous DSS
+    	if (offset != 0)
+    		finalizePreviousChainedDss(false);
+		beginDss(DssConstants.DSSFMT_RPYDSS, nextCorrelationID++);
+		simpleDssFinalize = false;
+	}
+
+	/**
+	 * Create DSS request object
+	 */
+	protected void createDssRequest(int corrID)
+	{
+		// finish off previous DSS
+    	if (offset != 0)
+    		finalizePreviousChainedDss((correlationID == corrID));
+		beginDss(DssConstants.DSSFMT_RQSDSS, corrID);
+		simpleDssFinalize = false;
+	}
+	/**
+	 * Create DSS data object
+	 */
+	protected void createDssObject(boolean reuseCorrID)
+	{
+		// finish off previous DSS - objects are always part of a previous
+		// DSS reply - so correlation id should be the same
+    	if (offset != 0)
+    		finalizePreviousChainedDss (reuseCorrID);
+		beginDss(DssConstants.DSSFMT_OBJDSS, (reuseCorrID ? correlationID : nextCorrelationID++));
+		simpleDssFinalize = false;
+	}
+	/**
+	 * Create DSS data object
+	 */
+	protected void createDssObject()
+	{
+		createDssObject(true);
+	}
+
+	/**
+	 * End DSS header by writing the length in the length location
+	 *
+	 */
+	protected void endDss ()
+	{
+		int val = offset - dssLengthLocation;
+		bytes[dssLengthLocation] = (byte) ((val >>> 8) & 0xff);
+		bytes[dssLengthLocation + 1] = (byte) (val & 0xff);
+	}
+
+	/**
+	 * End final DDM and DSS header by writing the length in the length location
+	 *
+	 */
+	protected void endDdmAndDss ()
+	{
+		endDdm();	// updates last DDM object
+		endDss();
+	}
+	/**
+	 * Copy Data to End
+	 * Create a buffer and copy from the position given to the end of data
+	 *
+	 * @param start
+	 */
+	protected byte [] copyDataToEnd(int start)
+	{
+		int length = offset - start;
+		byte [] temp = new byte[length];
+		System.arraycopy(bytes,start,temp,0,length);
+		return temp;
+	}
+
+	// Collection methods
+
+	/**
+	 * Mark the location of the length bytes for the collection so they
+	 * can be updated later
+	 *
+	 */
+	protected void startDdm (int codePoint)
+	{
+		// save the location of the beginning of the collection so
+		// that we can come back and fill in the length bytes
+		markStack[top++] = offset;
+		offset += 2; // move past the length bytes before writing the code point
+		bytes[offset] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) (codePoint & 0xff);
+		offset += 2;
+	}
+
+	/**
+	 * Erase all writes for the current ddm and reset the
+	 * top
+	 */
+	protected void clearDdm ()
+	{
+		offset = markStack[top--];
+	}
+
+	/**
+	 * Clear the entire send buffer
+	 *
+	 */
+	protected void clearBuffer()
+	{
+		offset = 0;
+		top = 0;
+		dssLengthLocation = 0;
+		correlationID = DssConstants.CORRELATION_ID_UNKNOWN;
+		isDRDAProtocol = true;
+	}
+
+	/**
+	 * End the current DDM
+	 *
+	 */
+	protected void endDdm ()
+	{
+		// remove the top length location offset from the mark stack
+		// calculate the length based on the marked location and end of data.
+		int lengthLocation = markStack[--top];
+		int length = offset - lengthLocation;
+
+		// determine if any extended length bytes are needed.	the value returned
+		// from calculateExtendedLengthByteCount is the number of extended length
+		// bytes required. 0 indicates no exteneded length.
+		int extendedLengthByteCount = calculateExtendedLengthByteCount (length);
+		if (extendedLengthByteCount != 0)
+		{
+			// ensure there is enough room in the buffer for the extended length bytes.
+			ensureLength (extendedLengthByteCount);
+
+			// calculate the length to be placed in the extended length bytes.
+			// this length does not include the 4 byte llcp.
+			int extendedLength = length - 4;
+
+			// shift the data to the right by the number of extended
+			// length bytes needed.
+			int extendedLengthLocation = lengthLocation + 4;
+			System.arraycopy (bytes,
+					              extendedLengthLocation,
+					              bytes,
+					              extendedLengthLocation + extendedLengthByteCount,
+					              extendedLength);
+
+			// write the extended length
+			int shiftSize = (extendedLengthByteCount -1) * 8;
+			for (int i = 0; i < extendedLengthByteCount; i++)
+			{
+				bytes[extendedLengthLocation++] =
+					(byte) ((extendedLength >>> shiftSize ) & 0xff);
+				shiftSize -= 8;
+			}
+
+			// adjust the offset to account for the shift and insert
+			offset += extendedLengthByteCount;
+
+			// the two byte length field before the codepoint contains the length
+			// of itself, the length of the codepoint, and the number of bytes used
+			// to hold the extended length.	the 2 byte length field also has the first
+			// bit on to indicate extended length bytes were used.
+			length = extendedLengthByteCount + 4;
+			length |= DssConstants.CONTINUATION_BIT;
+		}
+
+		// write the 2 byte length field (2 bytes before codepoint).
+		bytes[lengthLocation] = (byte) ((length >>> 8) & 0xff);
+		bytes[lengthLocation+1] = (byte) (length & 0xff);
+
+	}
+
+	/**
+	 * Get offset
+	 *
+	 * @return offset into the buffer
+	 */
+	protected int getOffset()
+	{
+		return offset;
+	}
+
+	/**
+	 * Set offset
+	 *
+	 * @param value new offset value
+	 */
+	protected void setOffset(int value)
+	{
+		offset = value;
+	}
+
+
+
+	// Write routines
+
+	/**
+	 * Write byte
+	 *
+	 * @param 	value	byte to be written
+	 */
+	protected void writeByte (int value)
+	{
+		if (SanityManager.DEBUG)
+		{
+			if (value > 255)
+				SanityManager.THROWASSERT(
+									   "writeByte value: " + value +
+									   " may not be > 255");
+		}
+
+		ensureLength (1);
+		bytes[offset++] = (byte) (value & 0xff);
+	}
+
+
+	/**
+	 * Write network short
+	 *
+	 * @param 	value	value to be written
+	 */
+	protected void writeNetworkShort (int value)
+	{
+		ensureLength (2);
+		bytes[offset] = (byte) ((value >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) (value & 0xff);
+		offset += 2;
+	}
+
+	/**
+	 * Write network int
+	 *
+	 * @param 	value	value to be written
+	 */
+	protected void writeNetworkInt (int value)
+	{
+		ensureLength (4);
+		bytes[offset] = (byte) ((value >>> 24) & 0xff);
+		bytes[offset + 1] = (byte) ((value >>> 16) & 0xff);
+		bytes[offset + 2] = (byte) ((value >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (value & 0xff);
+		offset += 4;
+	}
+
+
+	/**
+	 * Write byte array
+	 *
+	 * @param 	buf	byte array to be written
+	 * @param	length  - length to write
+	 */
+	protected void writeBytes (byte[] buf, int length)
+	{
+		writeBytes(buf, 0,length);
+	}
+
+
+
+	/**
+	 * Write byte array
+	 *
+	 * @param 	buf	byte array to be written
+	 * @param	start  - starting position
+	 * @param	length  - length to write
+	 */
+	protected void writeBytes (byte[] buf, int start, int length)
+	{
+
+		if (SanityManager.DEBUG)
+		{
+			if (buf == null && length > 0)
+		    	SanityManager.THROWASSERT("Buf is null");
+			if (length + start - 1 > buf.length)
+		    	SanityManager.THROWASSERT("Not enough bytes in buffer");
+
+		}
+		ensureLength (length);
+		System.arraycopy(buf,start,bytes,offset,length);
+		offset += length;
+	}
+	/**
+	 * Write byte array
+	 *
+	 * @param 	buf	byte array to be written
+	 **/
+	protected void writeBytes (byte[] buf)
+	{
+		writeBytes(buf,buf.length);
+	}
+
+
+
+	protected void writeLDBytes(byte[] buf)
+	{
+		writeLDBytes(buf, 0);
+	}
+
+	protected void writeLDBytes(byte[] buf, int index)
+	{
+
+		int length = buf.length;
+		int writeLen =  buf.length;
+
+		writeShort(writeLen);
+
+		writeBytes(buf,0,writeLen);
+	}
+
+
+	/**
+	 * Write code point and 4 bytes
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	value  - value to write after code point
+	 */
+	void writeCodePoint4Bytes (int codePoint, int value)
+	{
+		ensureLength (4);
+		bytes[offset] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) (codePoint & 0xff);
+		bytes[offset + 2] = (byte) ((value >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (value & 0xff);
+		offset += 4;
+	}
+
+	/**
+	 * Write scalar 1 byte object includes length, codepoint and value
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	value  - value to write after code point
+	 */
+	void writeScalar1Byte (int codePoint, int value)
+	{
+		ensureLength (5);
+		bytes[offset] = 0x00;
+		bytes[offset + 1] = 0x05;
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		bytes[offset + 4] = (byte) (value & 0xff);
+		offset += 5;
+	}
+
+	/**
+	 * Write scalar 2 byte object includes length, codepoint and value
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	value  - value to write after code point
+	 */
+	protected void writeScalar2Bytes (int codePoint, int value)
+	{
+		ensureLength (6);
+		bytes[offset] = 0x00;
+		bytes[offset + 1] = 0x06;
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		bytes[offset + 4] = (byte) ((value >>> 8) & 0xff);
+		bytes[offset + 5] = (byte) (value & 0xff);
+		offset += 6;
+	}
+
+	protected void writeScalar2Bytes ( int value)
+	{
+		ensureLength (2);
+		bytes[offset] = (byte) ((value >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) (value & 0xff);
+		offset += 2;
+	}
+
+	/**
+	 * Write length and codepoint
+	 *
+	 * @param 	length - length of object
+	 * @param 	codePoint - code point to write
+	 */
+	protected void startDdm (int length, int codePoint)
+	{
+		ensureLength (4);
+		bytes[offset] = (byte) ((length >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) (length & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		offset += 4;
+	}
+
+	/**
+	 * Write scalar byte array object includes length, codepoint and value
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	buf  - value to write after code point
+	 * @param	length - number of bytes to write
+	 */
+	protected void writeScalarBytes (int codePoint, byte[] buf, int length)
+	{
+		if (SanityManager.DEBUG)
+		{
+			if (buf == null && length > 0)
+		    	SanityManager.THROWASSERT("Buf is null");
+			if (length > buf.length)
+		    	SanityManager.THROWASSERT("Not enough bytes in buffer");
+		}
+		ensureLength (length + 4);
+		bytes[offset] = (byte) (((length+4) >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) ((length+4) & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		System.arraycopy(buf,0,bytes,offset + 4, length);
+		offset += length + 4;
+	}
+
+
+	protected int  writeScalarStream (boolean chained,
+									  boolean chainedWithSameCorrelator,
+									  int codePoint,
+									  int length,
+									  java.io.InputStream in,
+									  boolean writeNullByte) 
+		throws DRDAProtocolException
+	{
+		int leftToRead = length;
+		int bytesToRead = prepScalarStream (chained,
+											chainedWithSameCorrelator,
+											codePoint,
+											writeNullByte,
+											leftToRead);
+		
+		if (length == 0)
+			return 0;
+
+		// write the data
+		int bytesRead = 0;
+		int totalBytesRead = 0;
+		do {
+			do {
+				try {
+					bytesRead = in.read (bytes, offset, bytesToRead);
+					totalBytesRead += bytesRead;
+				}
+				catch (java.io.IOException e) {
+					padScalarStreamForError (leftToRead, bytesToRead);
+					return totalBytesRead;
+				}
+				if (bytesRead == -1) {
+					padScalarStreamForError (leftToRead, bytesToRead);
+					return totalBytesRead;
+				}
+				else {
+					bytesToRead -= bytesRead;
+					offset += bytesRead;
+					leftToRead -= bytesRead;
+				}
+			} while (bytesToRead > 0);
+			
+			bytesToRead = flushScalarStreamSegment (leftToRead, bytesToRead);
+		} while (leftToRead > 0);
+		
+		// check to make sure that the specified length wasn't too small
+		try {
+			if (in.read() != -1) {
+				totalBytesRead += 1;
+			}
+		}
+		catch (java.io.IOException e) {
+			// Encountered error in stream length verification for 
+			// InputStream, parameter #" + parameterIndex + ".  
+			// Don't think we need to error for this condition
+		}
+		return totalBytesRead;
+	}
+	
+	
+	private void beginDss (boolean dssHasSameCorrelator,
+						   boolean chainedToNextStructure,
+						   boolean nextHasSameCorrelator,
+						   int dssType,
+						   int corrId,
+						   boolean simpleFinalizeBuildingNextDss)
+  {
+	  if (doesRequestContainData()) {
+		  if (simpleDssFinalize)
+		  {
+			  finalizeDssLength();
+
+		  }
+		  else
+			  finalizePreviousChainedDss (dssHasSameCorrelator);
+	  }
+
+	  ensureLength (6);
+
+	  // save the length position and skip
+	  // note: the length position is saved so it can be updated
+	  // with a different value later.
+	  dssLengthLocation = offset;
+	  // always turn on chaining flags... this is helpful for lobs...
+	  // these bytes will get rest if dss lengths are finalized.
+	  bytes[offset] = (byte) 0xFF;
+	  bytes[offset + 1] = (byte) 0xFF;
+
+	  // insert the manditory 0xD0 and the dssType
+	  bytes[offset + 2] = (byte) 0xD0;
+
+    if (chainedToNextStructure) {
+      dssType |= DssConstants.GDSCHAIN;
+      if (nextHasSameCorrelator)
+        dssType |= DssConstants.GDSCHAIN_SAME_ID;
+    }
+    bytes[offset + 3] = (byte) (dssType & 0xff);
+
+    // write the request correlation id
+    // use method that writes a short !!!
+    bytes[offset + 4] = (byte) ((corrId >>> 8) & 0xff);
+    bytes[offset + 5] = (byte) (corrId & 0xff);
+	offset +=6;
+    simpleDssFinalize = simpleFinalizeBuildingNextDss;
+  }
+
+
+  // prepScalarStream does the following prep for writing stream data:
+  // 1.  Flushes an existing DSS segment, if necessary
+  // 2.  Determines if extended length bytes are needed
+  // 3.  Creates a new DSS/DDM header and a null byte indicator, if applicable
+  protected int prepScalarStream  (boolean chained,
+                                   boolean chainedWithSameCorrelator,
+                                   int codePoint,
+                                   boolean writeNullByte,
+                                   int leftToRead) throws DRDAProtocolException
+  {
+    int extendedLengthByteCount;
+
+    int nullIndicatorSize = 0;
+    if (writeNullByte) 
+		nullIndicatorSize = 1;
+	extendedLengthByteCount = calculateExtendedLengthByteCount (leftToRead + 4 + nullIndicatorSize);
+
+    // flush the existing DSS segment if this stream will not fit in the send buffer
+    if (10 + extendedLengthByteCount + nullIndicatorSize + leftToRead + offset > DssConstants.MAX_DSS_LENGTH) {
+      try {
+        if (simpleDssFinalize)
+          finalizeDssLength();
+        else
+          finalizePreviousChainedDss (true);
+        sendBytes(agent.getOutputStream());
+      }
+      catch (java.io.IOException e) {
+         agent.markCommunicationsFailure ("DDMWriter.writeScalarStream()",
+                                              "OutputStream.flush()",
+                                              e.getMessage(),"*");
+      }
+    }
+
+    // buildStreamDss should not call ensure length.
+    beginDss (true,
+			  chained,
+			  chainedWithSameCorrelator,
+			  DssConstants.GDSFMT_OBJDSS,
+			  correlationID,
+			  true);
+
+    if (extendedLengthByteCount > 0) {
+      // method should never ensure length
+      writeLengthCodePoint (0x8004 + extendedLengthByteCount, codePoint);
+
+      if (writeNullByte)
+        writeExtendedLengthBytes (extendedLengthByteCount, leftToRead + 1);
+      else
+        writeExtendedLengthBytes (extendedLengthByteCount, leftToRead);
+    }
+    else {
+      if (writeNullByte)
+        writeLengthCodePoint (leftToRead + 4 + 1, codePoint);
+      else
+        writeLengthCodePoint (leftToRead + 4, codePoint);
+    }
+
+    // write the null byte, if necessary
+    if (writeNullByte)
+      writeByte(0x0);
+
+    int bytesToRead;
+
+    if (writeNullByte)
+      bytesToRead = Math.min (leftToRead, DssConstants.MAX_DSS_LENGTH - 6 - 4 - 1 - extendedLengthByteCount);
+    else
+      bytesToRead = Math.min (leftToRead, DssConstants.MAX_DSS_LENGTH - 6 - 4 - extendedLengthByteCount);
+
+    return bytesToRead;
+  }
+
+
+  // method to determine if any data is in the request.
+  // this indicates there is a dss object already in the buffer.
+	protected boolean doesRequestContainData()
+	{
+		return offset != 0;
+	}
+
+
+	// Writes out a scalar stream DSS segment, along with DSS continuation
+	// headers if necessary.
+	protected int flushScalarStreamSegment (int leftToRead,
+											int bytesToRead)
+		throws DRDAProtocolException
+  {
+	  int newBytesToRead = bytesToRead;
+
+	  // either at end of data, end of dss segment, or both.
+	  if (leftToRead != 0) {
+		  // 32k segment filled and not at end of data.
+		  if ((Math.min (2 + leftToRead, 32767)) > (bytes.length - offset)) {
+        try {
+          sendBytes (agent.getOutputStream());
+        }
+        catch (java.io.IOException ioe) {
+			agent.markCommunicationsFailure ("DDMWriter.flushScalarStreamSegment()",
+                                               "",
+                                               ioe.getMessage(),
+                                               "*");
+        }
+      }
+      dssLengthLocation = offset;
+      bytes[offset++] = (byte) (0xff);
+      bytes[offset++] = (byte) (0xff);
+      newBytesToRead = Math.min (leftToRead,32765);
+    }
+
+    return newBytesToRead;
+  }
+
+  // the offset must not be updated when an error is encountered
+  // note valid data may be overwritten
+  protected void padScalarStreamForError (int leftToRead, int bytesToRead) throws DRDAProtocolException
+  {
+    do {
+      do {
+        bytes[offset++] = (byte)(0x0); // use 0x0 as the padding byte
+        bytesToRead--;
+        leftToRead--;
+      } while (bytesToRead > 0);
+
+      bytesToRead = flushScalarStreamSegment (leftToRead, bytesToRead);
+    } while(leftToRead > 0);
+  }
+
+
+
+	private void writeExtendedLengthBytes (int extendedLengthByteCount, long length)
+	{
+	int shiftSize = (extendedLengthByteCount -1) * 8;
+    for (int i = 0; i < extendedLengthByteCount; i++) {
+      bytes[offset + i] = (byte) ((length >>> shiftSize) & 0xff);
+      shiftSize -= 8;
+    }
+	offset += extendedLengthByteCount;
+  }
+
+
+  // insert a 4 byte length/codepoint pair into the buffer.
+  // total of 4 bytes inserted in buffer.
+  // Note: the length value inserted in the buffer is the same as the value
+  // passed in as an argument (this value is NOT incremented by 4 before being
+  // inserted).
+  void writeLengthCodePoint (int length, int codePoint)
+  {
+    ensureLength (4);
+    bytes[offset] = (byte) ((length >>> 8) & 0xff);
+    bytes[offset + 1] = (byte) (length & 0xff);
+    bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+    bytes[offset + 3] = (byte) (codePoint & 0xff);
+	offset +=4;
+  }
+
+	/**
+	 * Write scalar object header includes length and codepoint
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	dataLength - length of object data
+	 * @param	length - number of bytes to write
+	 */
+	protected void writeScalarHeader (int codePoint, int dataLength)
+	{
+		ensureLength (dataLength + 4);
+		bytes[offset] = (byte) (((dataLength+4) >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) ((dataLength+4) & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		offset += 4;
+	}
+
+	/**
+	 * Write scalar string object includes length, codepoint and value
+	 * the string is converted into the appropriate codeset (EBCDIC)
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	string - string to be written
+	 */
+	void writeScalarString (int codePoint, String string)
+	{
+		int stringLength = string.length();
+		ensureLength ((stringLength * 2)  + 4);
+		bytes[offset] = (byte) (((stringLength+4) >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) ((stringLength+4) & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		offset = ccsidManager.convertFromUCS2 (string, bytes, offset + 4);
+	}
+
+	/**
+	 * Write padded scalar string object includes length, codepoint and value
+	 * the string is converted into the appropriate codeset (EBCDIC)
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	string - string to be written
+	 * @param 	paddedLength - length to pad string to
+	 */
+	void writeScalarPaddedString (int codePoint, String string, int paddedLength)
+	{
+		int stringLength = string.length();
+		int fillLength = paddedLength - stringLength;
+		ensureLength (paddedLength + 4);
+		bytes[offset] = (byte) (((paddedLength+4) >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) ((paddedLength+4) & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		offset = ccsidManager.convertFromUCS2 (string, bytes, offset + 4);
+		Arrays.fill(bytes,offset, offset + fillLength,ccsidManager.space);
+		offset += fillLength;
+	}
+
+	/**
+	 * Write padded scalar string object value
+	 * the string is converted into the appropriate codeset (EBCDIC)
+	 *
+	 * @param	string - string to be written
+	 * @param 	paddedLength - length to pad string to
+	 */
+	protected void writeScalarPaddedString (String string, int paddedLength)
+	{
+		int stringLength = string.length();
+
+		int fillLength = paddedLength -stringLength;
+		ensureLength (paddedLength);
+		offset = ccsidManager.convertFromUCS2 (string, bytes, offset);
+		Arrays.fill(bytes,offset, offset + fillLength,ccsidManager.space);
+		offset += fillLength;
+	}
+
+	/**
+	 * Write padded scalar byte array object includes length, codepoint and value
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	buf - byte array to be written
+	 * @param 	paddedLength - length to pad string to
+	 * @param	padByte - byte to be used for padding
+	 */
+	protected void writeScalarPaddedBytes (int codePoint, byte[] buf, int paddedLength, byte padByte)
+	{
+		int bufLength = buf.length;
+		ensureLength (paddedLength + 4);
+		bytes[offset] = (byte) (((paddedLength+4) >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) ((paddedLength+4) & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		offset += 4;
+		System.arraycopy(buf,0,bytes,offset,bufLength);
+		offset += bufLength;
+		int fillLength = paddedLength - bufLength;
+		Arrays.fill(bytes,offset,offset + fillLength,padByte);
+		offset += fillLength;
+	}
+
+	/**
+	 * Write padded scalar byte array object  value
+	 *
+	 * @param	buf - byte array to be written
+	 * @param 	paddedLength - length to pad string to
+	 * @param	padByte - byte to be used for padding
+	 */
+	protected void writeScalarPaddedBytes (byte[] buf, int paddedLength, byte padByte)
+	{
+		int bufLength = buf.length;
+		int fillLength = paddedLength - bufLength;
+		ensureLength (paddedLength);
+		System.arraycopy(buf,0,bytes,offset,bufLength);
+		offset +=bufLength;
+		Arrays.fill(bytes,offset,offset + fillLength,padByte);
+		offset += fillLength;
+	}
+
+	/**
+	 * Write scalar byte array object includes length, codepoint and value
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	buf - byte array to be written
+	 */
+	protected void writeScalarBytes (int codePoint, byte[] buf)
+	{
+		int bufLength = buf.length;
+		ensureLength (bufLength + 4);
+		bytes[offset] = (byte) (((bufLength+4) >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) ((bufLength+4) & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		System.arraycopy(buf,0,bytes,offset + 4,bufLength);
+		offset += bufLength + 4;
+	}
+
+	/**
+	 * Write scalar byte array object includes length, codepoint and value
+	 *
+	 * @param 	codePoint - code point to write
+	 * @param	buf - byte array to be written
+	 * @param	start - starting point
+	 * @param 	length - length to write
+	 */
+	protected void writeScalarBytes (int codePoint, byte[] buf, int start, int length)
+	{
+		if (SanityManager.DEBUG)
+		{
+			if (buf == null && length > start)
+		    	SanityManager.THROWASSERT("Buf is null");
+			if (length - start > buf.length)
+				SanityManager.THROWASSERT("Not enough bytes in buffer");
+		}
+		int numBytes = length - start;
+		ensureLength (numBytes + 4);
+		bytes[offset] = (byte) (((numBytes+4) >>> 8) & 0xff);
+		bytes[offset + 1] = (byte) ((numBytes+4) & 0xff);
+		bytes[offset + 2] = (byte) ((codePoint >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (codePoint & 0xff);
+		offset += 4;
+		System.arraycopy(buf,start,bytes,offset,numBytes);
+		offset += numBytes;
+	}
+	// The following methods write data in the platform format
+	// The platform format was indicated during connection time as ASC since
+	// JCC doesn't read JVM platform (yet)
+
+	/**
+	 * Write platform short
+	 *
+	 * @param 	v	value to be written
+	 */
+	protected void writeShort (int v)
+	{
+		writeNetworkShort(v);
+	}
+
+	/**
+	 * Write boolean as short
+	 * @param b boolean value true = 1 false = 0
+	 *
+	 */
+	protected void writeShort(boolean b)
+	{
+		writeNetworkShort(b ? 1 : 0);
+	}
+
+	/**
+	 * Write platform int
+	 *
+	 * @param 	v	value to be written
+	 */
+	protected void writeInt (int v)
+	{
+		writeNetworkInt(v);
+	}
+
+	/**
+	 * Write platform long
+	 *
+	 * @param 	v	value to be written
+	 */
+	protected void writeLong (long v)
+	{
+		ensureLength (8);
+		bytes[offset] =	(byte) ((v >>> 56) & 0xff);
+		bytes[offset + 1] =	(byte) ((v >>> 48) & 0xff);
+		bytes[offset + 2] =	(byte) ((v >>> 40) & 0xff);
+		bytes[offset + 3] =	(byte) ((v >>> 32) & 0xff);
+		bytes[offset + 4] =	(byte) ((v >>> 24) & 0xff);
+		bytes[offset + 5] =	(byte) ((v >>> 16) & 0xff);
+		bytes[offset + 6] =	(byte) ((v >>>  8) & 0xff);
+		bytes[offset + 7] =	(byte) ((v >>>  0) & 0xff);
+		offset += 8;
+	}
+
+	/**
+	 * Write platform float
+	 *
+	 * @param 	v	value to be written
+	 */
+	protected void writeFloat (float v)
+	{
+		writeInt (Float.floatToIntBits (v));
+	}
+
+	/**
+	 * Write platform double
+	 *
+	 * @param 	v	value to be written
+	 */
+	protected void writeDouble (double v)
+	{
+		writeLong (Double.doubleToLongBits (v));
+	}
+
+	/**
+	 * Write big decimal to buffer
+	 *
+	 * @param v value to write
+	 * @param precision Precison of decimal or numeric type
+	 * @param declared scale
+	 * @exception SQLException thrown if number of digits > 31
+	 */
+	protected void writeBigDecimal (java.math.BigDecimal v, int precision, int scale)
+		throws SQLException
+	{
+		int length = precision / 2 + 1;
+		ensureLength (offset + length);
+		bigDecimalToPackedDecimalBytes (v,precision, scale);
+		offset += length;
+	}
+
+	/**
+	 * Write platform boolean
+	 *
+	 * @param 	v	value to be written
+	 */
+	protected void writeBoolean (boolean v)
+	{
+		ensureLength (1);
+		bytes[offset++] = (byte) ((v ? 1 : 0) & 0xff);
+	}
+
+	/**
+	 * Write length delimited string
+	 *
+	 * @param s value to be written with integer
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	protected void writeLDString(String s) throws DRDAProtocolException
+	{
+		writeLDString(s,0);
+	}
+
+
+	/**
+	 * Write length delimited string
+	 *
+	 * @param s              value to be written with integer
+	 * @param index          column index to put in warning
+	 * @exception DRDAProtocolException
+	 */
+	protected void writeLDString(String s, int index) throws DRDAProtocolException
+	{
+		try {
+			byte [] byteval = s.getBytes(DB2jServerImpl.DEFAULT_ENCODING);
+			int origLen = byteval.length;
+			boolean multiByteTrunc = false;
+			int writeLen =
+				java.lang.Math.min(FdocaConstants.LONGVARCHAR_MAX_LEN,
+								   origLen);
+			/*
+			Need to make sure we truncate on character boundaries.
+			We are assuming
+			http://www.sun.com/developers/gadc/technicalpublications/articles/utf8.html
+			To find the beginning of a multibyte character:
+			1) Does the current byte start with the bit pattern 10xxxxxx?
+			2) If yes, move left and go to step #1.
+			3) Finished
+			We assume that DB2jServerImpl.DEFAULT_ENCODING remains UTF-8
+			*/
+
+			if (SanityManager.DEBUG)
+			{
+				if (!(DB2jServerImpl.DEFAULT_ENCODING.equals("UTF8")))
+					SanityManager.THROWASSERT("Encoding assumed to be UTF8, but is actually" + DB2jServerImpl.DEFAULT_ENCODING);
+			}
+
+			if (writeLen != origLen)
+				// first position on the first byte of the multibyte char
+				while ((byteval[writeLen -1] & 0xC0) == 0x80)
+				{
+					multiByteTrunc = true;
+					writeLen--;
+					// Then subtract one more to get to the end of the
+					// previous character
+					if (multiByteTrunc == true)
+					{
+						writeLen = writeLen -1;
+					}
+				}
+
+			writeShort(writeLen);
+			writeBytes(byteval,writeLen);
+		}
+		catch (Exception e) {
+			//this should never happen
+			agent.agentError("Encoding " + DB2jServerImpl.DEFAULT_ENCODING + " not supported");
+		}
+	}
+
+	/**
+	 * Write string with default encoding
+	 *
+	 * @param s value to be written
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	protected void writeString(String s) throws DRDAProtocolException
+	{
+		try {
+			writeBytes(s.getBytes(DB2jServerImpl.DEFAULT_ENCODING));
+		} catch (Exception e) {
+			//this should never happen
+			agent.agentError("Encoding " + DB2jServerImpl.DEFAULT_ENCODING + " not supported");
+		}
+	}
+
+	/**
+	 * Write string with default encoding and specified length
+	 *
+	 * @param s value to be written
+	 * @param length number of bytes to be written
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	protected void writeString(String s, int length) throws DRDAProtocolException
+	{
+		byte[] bs = null;
+		try {
+			bs = s.getBytes(DB2jServerImpl.DEFAULT_ENCODING);
+		} catch (Exception e) {
+			//this should never happen
+			agent.agentError("Encoding " + DB2jServerImpl.DEFAULT_ENCODING + " not supported");
+		}
+		int len = bs.length;
+		if (len >= length)
+			writeBytes(bs, length);
+		else
+		{
+			writeBytes(bs);
+			padBytes(DB2jServerImpl.SPACE_CHAR, length-len);
+		}
+	}
+
+	/**
+	 * Write pad bytes using spaceChar
+	 *
+	 * @param   val	value to be written
+	 * @param	length		length to be written
+	 */
+	protected void padBytes (byte val, int length)
+	{
+		Arrays.fill(bytes,offset, offset + length,val);
+		offset += length;
+	}
+
+	/**
+	 * Flush buffer to outputstream
+	 *
+	 *
+	 * @exception IOException
+	 */
+	protected void flush () throws java.io.IOException
+	{
+		OutputStream socketOutputStream = agent.getOutputStream();
+		try {
+			if (isDRDAProtocol)
+			{
+				finalizeDssLength();
+			}
+			socketOutputStream.write (bytes, 0, offset);
+			socketOutputStream.flush();
+		}
+		finally {
+			if ((dssTrace != null) && dssTrace.isComBufferTraceOn()) {
+			  dssTrace.writeComBufferData (bytes,
+			                               0,
+			                               offset,
+			                               DssTrace.TYPE_TRACE_SEND,
+			                               "Reply",
+			                               "flush",
+			                               5);
+			}
+			reset(dssTrace);
+		}
+	}
+	/**
+	 * Flush buffer to specified stream
+	 *
+	 * @param socketOutputStream
+	 *
+	 * @exception IOException
+	 */
+	protected void flush(OutputStream os) throws java.io.IOException
+	{
+		os.write(bytes, 0, offset);
+		os.flush();
+	}
+
+	// private methods
+
+	/**
+	 * Write DSS header
+	 * DSS Header format is
+	 * 	2 bytes	- length
+	 *	1 byte	- 'D0'	- indicates DDM data
+	 * 	1 byte	- DSS format
+	 *		|---|---------|----------|
+	 *		| 0	|	flags |	type     |
+	 *		|---|---------|----------|
+	 *		| 0 | 1	2	3 | 4 5 6 7	 |
+	 *		|---|---------|----------|
+	 *		bit 0 - '0'
+	 *		bit 1 - '0' - unchained, '1' - chained
+	 *		bit 2 - '0'	- do not continue on error, '1' - continue on error
+	 *		bit 3 - '0' - next DSS has different correlator, '1' - next DSS has
+	 *						same correlator
+	 *		type - 1 - Request DSS
+	 *			 - 2 - Reply DSS
+	 *			 - 3 - Object DSS
+	 *			 - 4 - Communications DSS
+	 *			 - 5 - Request DSS where no reply is expected
+	 */
+	private void beginDss (int dssType, int corrID)
+	{
+		// save correlationID for use in error messages while processing
+		// this DSS
+		correlationID = corrID;
+		// save length position, the length will be written at the end
+		dssLengthLocation = offset;
+
+		ensureLength(6);
+		offset += 2;
+
+		// write gds info
+		bytes[offset] = (byte) 0xD0;
+		bytes[offset + 1] = (byte) dssType;
+
+		// write the request correlation id
+		bytes[offset + 2] = (byte) ((corrID >>> 8) & 0xff);
+		bytes[offset + 3] = (byte) (corrID & 0xff);
+		offset += 4;
+	}
+
+	/**
+	 * finish the DSS in the buffer by updating the length and chaining bits
+	 *
+	 * @param nextDssHasSameCorrelator - how to set chaining bits
+	 */
+  	private void finalizePreviousChainedDss (boolean nextDssHasSameCorrelator)
+	{
+		finalizeDssLength();
+		bytes[dssLengthLocation + 3] |= 0x40;
+		if (nextDssHasSameCorrelator)
+			bytes[dssLengthLocation + 3] |= 0x10;
+		
+	}
+	/**
+     * Finish a DSS Layer A object.
+	 * The length of dss object will be calculated based on the difference between the
+	 * start of the dss, saved on the beginDss call, and the current
+	 * offset into the buffer which marks the end of the data.	In the event
+	 * the length requires the use of continuation Dss headers, one for each 32k
+	 * chunk of data, the data will be shifted and the continuation headers
+	 * will be inserted with the correct values as needed.
+	 */
+	private void finalizeDssLength ()
+	{
+		// calculate the total size of the dss and the number of bytes which would
+		// require continuation dss headers.	The total length already includes the
+		// the 6 byte dss header located at the beginning of the dss.	It does not
+		// include the length of any continuation headers.
+		int totalSize = offset - dssLengthLocation;
+		int bytesRequiringContDssHeader = totalSize - DssConstants.MAX_DSS_LENGTH;
+
+		// determine if continuation headers are needed
+		if (bytesRequiringContDssHeader > 0)
+		{
+			// the continuation headers are needed, so calculate how many.
+			// after the first 32767 worth of data, a continuation header is
+			// needed for every 32765 bytes (32765 bytes of data + 2 bytes of
+			// continuation header = 32767 Dss Max Size).
+			int contDssHeaderCount = bytesRequiringContDssHeader / 32765;
+			if (bytesRequiringContDssHeader % 32765 != 0)
+				contDssHeaderCount++;
+
+			// right now the code will shift to the right.	In the future we may want
+			// to try something fancier to help reduce the copying (maybe keep
+			// space in the beginning of the buffer??).
+			// the offset points to the next available offset in the buffer to place
+			// a piece of data, so the last dataByte is at offset -1.
+			// various bytes will need to be shifted by different amounts
+			// depending on how many dss headers to insert so the amount to shift
+			// will be calculated and adjusted as needed.	ensure there is enough room
+			// for all the conutinuation headers and adjust the offset to point to the
+			// new end of the data.
+			int dataByte = offset - 1;
+			int shiftSize = contDssHeaderCount * 2;
+			ensureLength (shiftSize);
+			offset += shiftSize;
+
+			// mark passOne to help with calculating the length of the final (first or
+			// rightmost) continuation header.
+			boolean passOne = true;
+			do {
+				// calculate chunk of data to shift
+				int dataToShift = bytesRequiringContDssHeader % 32765;
+				if (dataToShift == 0)
+					dataToShift = 32765;
+				// We start with the right most chunk. If we had to copy two
+				// chunks we would shift the first one 4 bytes and then 
+				// the second one
+				// 2 when we come back on the next loop so they would each have
+				// 2 bytes for the continuation header
+				int startOfCopyData = dataByte - dataToShift;
+				System.arraycopy(bytes,startOfCopyData, bytes, 
+								 startOfCopyData + shiftSize, dataToShift);
+				dataByte -= dataToShift;
+
+
+				// calculate the value the value of the 2 byte continuation dss
+				// header which includes the length of itself.  On the first pass,
+				// if the length is 32767
+				// we do not want to set the continuation dss header flag.
+				int twoByteContDssHeader = dataToShift + 2;
+				if (passOne)
+					passOne = false;
+				else
+				{
+					if (twoByteContDssHeader == DssConstants.MAX_DSS_LENGTH)
+				    	twoByteContDssHeader = DssConstants.CONTINUATION_BIT;
+				}
+
+				// insert the header's length bytes
+				bytes[dataByte + shiftSize - 1] = (byte)
+					((twoByteContDssHeader >>> 8) & 0xff);
+				bytes[dataByte + shiftSize] = (byte)
+					(twoByteContDssHeader & 0xff);
+
+				// adjust the bytesRequiringContDssHeader and the amount to shift for
+				// data in upstream headers.
+				bytesRequiringContDssHeader -= dataToShift;
+				shiftSize -= 2;
+
+				// shift and insert another header for more data.
+			}
+			while (bytesRequiringContDssHeader > 0);
+
+			// set the continuation dss header flag on for the first header
+			totalSize = DssConstants.CONTINUATION_BIT;
+
+		}
+
+		// insert the length bytes in the 6 byte dss header.
+		bytes[dssLengthLocation] = (byte) ((totalSize >>> 8) & 0xff);
+		bytes[dssLengthLocation + 1] = (byte) (totalSize & 0xff);
+	}
+
+	protected void writeExtendedLength(long size)
+	{
+		int numbytes = calculateExtendedLengthByteCount(size);
+		if (size > 0)
+			writeInt(0x8000 | numbytes);
+		else
+			writeInt(numbytes);
+	}
+
+
+	/**
+	 * Calculate extended length byte count which follows the DSS header
+	 * for extended DDM.
+	 *
+	 * @param ddmSize - size of DDM command
+	 * @return minimum number of extended length bytes needed. 0 indicates no
+	 * 	extended length needed.
+	 */
+	private int calculateExtendedLengthByteCount (long ddmSize)
+	{
+		if (ddmSize <= 0x7fff)
+			return 0;
+		// JCC does not support 2 at this time, so we always send
+		// at least 4
+		//		else if (ddmSize <= 0xffff)
+		//	return 2;
+		else if (ddmSize <= 0xffffffffL)
+			return 4;
+		else if (ddmSize <= 0xffffffffffffL)
+			return 6;
+		else if (ddmSize <= 0x7fffffffffffffffL)
+			return 8;
+		else
+			// shouldn't happen
+			// XXX - add sanity debug stuff here
+			return 0;
+	}
+
+	/**
+	 * Ensure that there is space in the buffer
+	 *
+	 * @param length space required
+	 */
+	private void ensureLength (int length)
+	{
+		length += offset;
+		if (length > bytes.length) {
+			if (SanityManager.DEBUG)
+			{
+				agent.trace("DANGER - Expensive expansion of  buffer");
+			}
+			byte newBytes[] = new byte[Math.max (bytes.length << 1, length)];
+			System.arraycopy (bytes, 0, newBytes, 0, offset);
+			bytes = newBytes;
+		}
+	}
+
+
+	/**
+	 * Write a Java <code>java.math.BigDecimal</code> to packed decimal bytes.
+	 *
+	 * @param b BigDecimal to write
+	 * @param precision Precision of decimal or numeric type
+	 * @return length written.
+	 *
+	 * @exception SQLException Thrown if # digits > 31
+	 */
+	private int bigDecimalToPackedDecimalBytes (java.math.BigDecimal b,
+												int precision, int scale)
+	throws SQLException
+	{
+		int declaredPrecision = precision;
+		int declaredScale = scale;
+
+		// packed decimal may only be up to 31 digits.
+		if (declaredPrecision > 31) // this is a bugcheck only !!!
+		{
+			clearDdm ();
+			throw new java.sql.SQLException ("Packed decimal may only be up to 31 digits!");
+		}
+
+		// get absolute unscaled value of the BigDecimal as a String.
+		String unscaledStr = b.unscaledValue().abs().toString();
+
+		// get precision of the BigDecimal.
+  	    int bigPrecision = unscaledStr.length();
+
+		if (bigPrecision > 31)
+		{
+			clearDdm ();
+  		    throw new SQLException ("The numeric literal \"" +
+                             b.toString() +
+                             "\" is not valid because its value is out of range.",
+                             "42820",
+                             -405);
+		}
+    	int bigScale = b.scale();
+  	    int bigWholeIntegerLength = bigPrecision - bigScale;
+	    if ( (bigWholeIntegerLength > 0) && (!unscaledStr.equals ("0")) ) {
+            // if whole integer part exists, check if overflow.
+            int declaredWholeIntegerLength = declaredPrecision - declaredScale;
+            if (bigWholeIntegerLength > declaredWholeIntegerLength)
+			{
+				clearDdm ();
+                throw new SQLException ("Overflow occurred during numeric data type conversion of \"" +
+                                       b.toString() +
+                                       "\".",
+                                       "22003",
+                                       -413);
+			}
+        }
+
+        // convert the unscaled value to a packed decimal bytes.
+
+        // get unicode '0' value.
+        int zeroBase = '0';
+
+        // start index in target packed decimal.
+        int packedIndex = declaredPrecision-1;
+
+        // start index in source big decimal.
+        int bigIndex;
+
+        if (bigScale >= declaredScale) {
+          // If target scale is less than source scale,
+          // discard excessive fraction.
+
+          // set start index in source big decimal to ignore excessive fraction.
+          bigIndex = bigPrecision-1-(bigScale-declaredScale);
+
+          if (bigIndex < 0) {
+            // all digits are discarded, so only process the sign nybble.
+            bytes[offset+(packedIndex+1)/2] =
+              (byte) ( (b.signum()>=0)?12:13 ); // sign nybble
+          }
+          else {
+            // process the last nybble together with the sign nybble.
+            bytes[offset+(packedIndex+1)/2] =
+              (byte) ( ( (unscaledStr.charAt(bigIndex)-zeroBase) << 4 ) + // last nybble
+                     ( (b.signum()>=0)?12:13 ) ); // sign nybble
+          }
+          packedIndex-=2;
+          bigIndex-=2;
+        }
+        else {
+          // If target scale is greater than source scale,
+          // pad the fraction with zero.
+
+          // set start index in source big decimal to pad fraction with zero.
+          bigIndex = declaredScale-bigScale-1;
+
+          // process the sign nybble.
+          bytes[offset+(packedIndex+1)/2] =
+            (byte) ( (b.signum()>=0)?12:13 ); // sign nybble
+
+          for (packedIndex-=2, bigIndex-=2; bigIndex>=0; packedIndex-=2, bigIndex-=2)
+            bytes[offset+(packedIndex+1)/2] = (byte) 0;
+
+          if (bigIndex == -1) {
+            bytes[offset+(packedIndex+1)/2] =
+              (byte) ( (unscaledStr.charAt(bigPrecision-1)-zeroBase) << 4 ); // high nybble
+
+            packedIndex-=2;
+            bigIndex = bigPrecision-3;
+          }
+          else {
+            bigIndex = bigPrecision-2;
+          }
+        }
+
+        // process the rest.
+        for (; bigIndex>=0; packedIndex-=2, bigIndex-=2) {
+          bytes[offset+(packedIndex+1)/2] =
+            (byte) ( ( (unscaledStr.charAt(bigIndex)-zeroBase) << 4 ) + // high nybble
+                   ( unscaledStr.charAt(bigIndex+1)-zeroBase ) ); // low nybble
+        }
+
+        // process the first nybble when there is one left.
+        if (bigIndex == -1) {
+          bytes[offset+(packedIndex+1)/2] =
+            (byte) (unscaledStr.charAt(0) - zeroBase);
+
+          packedIndex-=2;
+        }
+
+        // pad zero in front of the big decimal if necessary.
+        for (; packedIndex>=-1; packedIndex-=2)
+          bytes[offset+(packedIndex+1)/2] = (byte) 0;
+
+        return declaredPrecision/2 + 1;
+	}
+
+
+	/***
+	 * Prepend zeros to numeric string
+	 *
+	 * @param s string
+	 * @param precision - length of padded string
+ 	 *
+	 * @return zero padded string
+	 */
+	public static String zeroPadString(String s, int precision)
+	{
+
+		if (s == null)
+			return s;
+
+		int slen = s.length();
+		if (precision == slen)
+			return s;
+		else if (precision > slen)
+		{
+			char[] ca  = new char[precision - slen];
+			Arrays.fill(ca,0,precision - slen,'0');
+			return new String(ca) + s;
+		}
+		else
+		{
+			// Shouldn't happen but just in case 
+			// truncate
+			return s.substring(0,precision);
+		}
+
+	}
+
+
+
+  private void sendBytes (java.io.OutputStream socketOutputStream) throws java.io.IOException
+  {
+    try {
+      socketOutputStream.write (bytes, 0, offset);
+      socketOutputStream.flush();
+    }
+    finally {
+		if ((dssTrace != null) && dssTrace.isComBufferTraceOn()) {
+			dssTrace.writeComBufferData (bytes,
+			                               0,
+			                               offset,
+			                               DssTrace.TYPE_TRACE_SEND,
+			                               "Reply",
+			                               "flush",
+			                               5);
+      }
+      clearBuffer();
+    }
+  }
+
+
+private void buildStreamDssObject (boolean chainedToNextStructure,
+								   boolean nextHasSameCorrelator,
+								   int corrID)
+  {
+	int dssType =   DssConstants.GDSFMT_OBJDSS;
+    if (offset != 0) {
+        finalizePreviousChainedDss (true);
+	}
+
+    ensureLength (6);
+
+    // save the length position and skip
+    // note: the length position is saved so it can be updated
+    // with a different value later.
+    dssLengthLocation = offset;
+    // always turn on chaining flags... this is helpful for lobs...
+    // these bytes will get rest if dss lengths are finalized.
+    bytes[offset] = (byte) 0xFF;
+    bytes[offset + 1] = (byte) 0xFF;
+
+    // insert the manditory 0xD0 and the dssType
+    bytes[offset + 2] = (byte) 0xD0;
+    if (chainedToNextStructure) {
+      dssType |= DssConstants.GDSCHAIN;
+      if (nextHasSameCorrelator)
+        dssType |= DssConstants.GDSCHAIN_SAME_ID;
+    }
+    bytes[offset + 3] = (byte) (  dssType & 0xff);
+
+    // write the request correlation id
+    // use method that writes a short !!!
+    bytes[offset + 4] = (byte) ((corrID >>> 8) & 0xff);
+    bytes[offset + 5] = (byte) (corrID & 0xff);
+	offset += 6;
+	}
+
+
+	private static int min (int i, int j)
+	{
+		return (i < j) ? i : j;
+	}
+
+	protected String toDebugString(String indent)
+	{
+		String s = indent + "***** DDMWriter toDebugString ******\n";
+		int byteslen = 0;
+		if ( bytes != null)
+			byteslen = bytes.length;
+		s += indent + "byte array length  = " + bytes.length + "\n";
+		return s;
+	}
+
+}
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,7171 @@
+/*
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+/**
+ * This class translates DRDA protocol from an application requester to JDBC
+ * for Cloudscape and then translates the results from Cloudscape to DRDA
+ * for return to the application requester.
+ * @author ge, marsden, peachey
+ */
+package org.apache.derby.impl.drda;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.*;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.DataTruncation;
+import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Types;
+import java.sql.Blob;
+import java.sql.Clob;
+
+import java.util.Properties;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.ArrayList;
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.derby.iapi.tools.i18n.LocalizedResource;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.reference.Attribute;
+import org.apache.derby.iapi.reference.DB2Limit;
+import org.apache.derby.iapi.error.ExceptionSeverity;
+import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.impl.jdbc.EmbedSQLException;
+import org.apache.derby.impl.jdbc.EmbedSQLWarning;
+import org.apache.derby.impl.jdbc.EmbedStatement;
+import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
+import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
+import org.apache.derby.impl.jdbc.EmbedConnection;
+
+import org.apache.derby.iapi.reference.JDBC30Translation;
+
+import org.apache.derby.iapi.services.info.JVMInfo;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
+import org.apache.derby.iapi.services.monitor.Monitor;
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+
+public class DRDAConnThread extends Thread { private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+
+	private static final String leftBrace = "{";
+	private static final String rightBrace = "}";
+	private static final byte NULL_VALUE = (byte)0xff;
+	private static final String SYNTAX_ERR = "42X01";
+
+	// Manager Level 3 constant.
+	private static final int MGRLVL_3 = 0x03;
+
+	// Manager Level 4 constant.
+	private static final int MGRLVL_4 = 0x04;
+
+	// Manager Level 5 constant.
+	private static final int MGRLVL_5 = 0x05;
+
+	// Manager level 6 constant.
+	private static final int MGRLVL_6 = 0x06;
+
+	// Manager Level 7 constant.
+	private static final int MGRLVL_7 = 0x07;
+
+
+	// Commit or rollback UOWDSP values
+	private static final int COMMIT = 1;
+	private static final int ROLLBACK = 2;
+
+
+	protected CcsidManager ccsidManager = new EbcdicCcsidManager();
+	private int correlationID;
+	private InputStream sockis;
+	private OutputStream sockos;
+	private DDMReader reader;
+	private DDMWriter writer;
+	private static int [] ACCRDB_REQUIRED = {CodePoint.RDBACCCL, 
+											 CodePoint.CRRTKN,
+											 CodePoint.PRDID,
+											 CodePoint.TYPDEFNAM,
+											 CodePoint.TYPDEFOVR};
+	private static int MAX_REQUIRED_LEN = 5;
+
+	private int currentRequiredLength = 0;
+	private int [] required = new int[MAX_REQUIRED_LEN];
+
+
+	private DB2jServerImpl server;			// server who created me
+	private Session	session;	// information about the session
+	private long timeSlice;				// time slice for this thread
+	private Object timeSliceSync = new Object(); // sync object for updating time slice 
+	private boolean logConnections;		// log connections to databases
+
+	private boolean	sendWarningsOnCNTQRY = false;	// Send Warnings for SELECT if true
+	private Object logConnectionsSync = new Object(); // sync object for log connect
+	private boolean close;				// end this thread
+	private Object closeSync = new Object();	// sync object for parent to close us down
+	private static HeaderPrintWriter logStream;
+	private AppRequester appRequester;	// pointer to the application requester
+										// for the session being serviced
+	private Database database; 	// pointer to the current database
+	private int sqlamLevel;		// SQLAM Level - determines protocol
+
+	// manager processing
+	private Vector unknownManagers;
+	private Vector knownManagers;
+	private Vector errorManagers;
+	private Vector errorManagersLevel;
+
+	// database accessed failed
+	private SQLException databaseAccessException;
+
+	// these fields are needed to feed back to jcc about a statement/procedure's PKGNAMCSN
+	private String rdbnam;
+	private String rdbcolid;
+	private String pkgid;
+	private String pkgcnstknStr;
+	private int secnumber;
+
+	// this flag is for an execute statement/procedure which actually returns a result set;
+	// do not commit the statement, otherwise result set is closed
+
+	// for decryption
+	private static DecryptionManager decryptionManager;
+	// public key generated by Deffie-Hellman algorithm, to be passed to the encrypter,
+	// as well as used to initialize the cipher
+	private byte[] myPublicKey;
+
+	// constructor
+	/**
+	 * Create a new Thread for processing session requests
+	 *
+	 * @param session Session requesting processing
+	 * @param server  Server starting thread
+	 * @param timeSlice timeSlice for thread
+	 * @param logConnections
+	 **/
+
+	public DRDAConnThread(Session session, DB2jServerImpl server, 
+						  long timeSlice,
+						  boolean logConnections) {
+	
+   	super();
+
+		// Create a more meaningful name for this thread (but preserve its
+		// thread id from the default name).
+		DB2jServerImpl.setUniqueThreadName(this, "DRDAConnThread");
+
+		this.session = session;
+		this.server = server;
+		this.timeSlice = timeSlice;
+		this.logConnections = logConnections;
+		initialize();
+    }
+
+	/**
+	 * Main routine for thread, loops until the thread is closed
+	 * Gets a session, does work for the session
+	 */
+    public void run() {
+		if (SanityManager.DEBUG)
+			trace("Starting new connection thread");
+
+		Session prevSession;
+		while(!closed())
+		{
+
+			// get a new session
+			prevSession = session;
+			session = server.getNextSession(session);
+			if (session == null)
+				close();
+
+			if (closed())
+				break;
+			if (session != prevSession)
+			{
+				initializeForSession();
+			}
+			try {
+				long timeStart = System.currentTimeMillis();
+
+				switch (session.state)
+				{
+					case Session.INIT:
+						sessionInitialState();
+						if (session == null)
+							break;
+					case Session.ATTEXC:
+						long currentTimeSlice;
+
+						do {
+							processCommands();
+							currentTimeSlice = getTimeSlice();
+						} while ((currentTimeSlice == 0)  || 
+							(System.currentTimeMillis() - timeStart < currentTimeSlice));
+
+						break;
+					default:
+						// this is an error
+						agentError("Session in invalid state:" + session.state);
+				}
+			} catch (Exception e) {
+				if (e instanceof DRDAProtocolException && 
+						((DRDAProtocolException)e).isDisconnectException())
+				{
+				 	// client went away - this is O.K. here
+					closeSession();
+				}
+				else
+				{
+					handleException(e);
+				}
+			}
+		}
+		if (SanityManager.DEBUG)
+			trace("Ending connection thread");
+		server.getThreadList().removeElement(this);
+
+	}
+	/**
+	 * Get input stream
+	 *
+	 * @return input stream
+	 */
+	protected InputStream getInputStream()
+	{
+		return sockis;
+	}
+
+	/**
+	 * Get output stream
+	 *
+	 * @return output stream
+	 */
+	protected OutputStream getOutputStream()
+	{
+		return sockos;
+	}
+
+	/**
+	 * Get correlation id
+	 *
+	 * @return correlation id
+	 */
+	protected int getCorrelationID ()
+	{
+		return correlationID;
+	}
+
+	/**
+	 * Get session we are working on
+	 *
+	 * @return session
+	 */
+	protected Session getSession()
+	{
+		return session;
+	}
+
+	/**
+	 * Get Database we are working on
+	 *
+	 * @return database
+	 */
+	protected Database getDatabase()
+	{
+		return database;
+	}
+	/**
+	 * Get server
+	 *
+	 * @return server
+	 */
+	protected DB2jServerImpl getServer()
+	{
+		return server;
+	}
+	/**
+	 * Get correlation token
+	 *
+	 * @return crrtkn
+	 */
+	protected byte[] getCrrtkn()
+	{
+		if (database != null)
+			return database.crrtkn;
+		return null;
+	}
+	/**
+	 * Get database name
+	 *
+	 * @return database name
+	 */
+	protected String getDbName()
+	{
+		if (database != null)
+			return database.dbName;
+		return null;
+	}
+	/**
+	 * Close DRDA  connection thread
+	 */
+	protected void close()
+	{
+		synchronized (closeSync)
+		{
+			close = true;
+		}
+	}
+
+	/**
+	 * Set logging of connections
+	 * 
+	 * @param value value to set for logging connections
+	 */
+	protected void setLogConnections(boolean value)
+	{
+		synchronized(logConnectionsSync) {
+			logConnections = value;
+		}
+	}
+	/**
+	 * Set time slice value
+	 *
+	 * @param value new value for time slice
+	 */
+	protected void setTimeSlice(long value)
+	{
+		synchronized(timeSliceSync) {
+			timeSlice = value;
+		}
+	}
+	/**
+	 * Indicate a communications failure
+	 * 
+	 * @param arg1 - info about the communications failure
+	 * @param arg2 - info about the communications failure
+	 * @param arg3 - info about the communications failure
+	 * @param arg4 - info about the communications failure
+	 *
+	 * @exception DRDAProtocolException  disconnect exception always thrown
+	 */
+	protected void markCommunicationsFailure(String arg1, String arg2, String arg3,
+		String arg4) throws DRDAProtocolException
+	{
+		Object[] oa = {arg1,arg2,arg3,arg4};
+		throw DRDAProtocolException.newDisconnectException(this,oa);
+
+	}
+	/**
+	 * Syntax error
+	 *
+	 * @param errcd		Error code
+	 * @param cpArg  code point value
+	 * @exception DRDAProtocolException
+	 */
+
+	protected  void throwSyntaxrm(int errcd, int cpArg)
+		throws DRDAProtocolException
+	{
+		throw new
+			DRDAProtocolException(DRDAProtocolException.DRDA_Proto_SYNTAXRM,
+								  this,
+								  cpArg,
+								  errcd);
+	}
+	/**
+	 * Agent error - something very bad happened
+	 *
+	 * @param msg	Message describing error
+	 *
+	 * @exception DRDAProtocolException  newAgentError always thrown
+	 */
+	protected void agentError(String msg) throws DRDAProtocolException
+	{
+
+		String dbname = null;
+		if (database != null)
+			dbname = database.dbName;
+		throw DRDAProtocolException.newAgentError(this, CodePoint.SVRCOD_PRMDMG, 
+			dbname, msg);
+	}
+	/**
+	 * Missing code point
+	 *
+	 * @param codePoint  code point value
+	 * @exception DRDAProtocolException
+	 */
+	protected void missingCodePoint(int codePoint) throws DRDAProtocolException
+	{
+		throwSyntaxrm(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND, codePoint);
+	}
+	/**
+	 * Print a line to the DB2j log
+	 *
+	 * @param dbname  database name
+	 * @param drdaID	DRDA identifier
+	 * @param msg	message
+	 */
+	protected static void println2Log(String dbname, String drdaID, String msg)
+	{
+		if (logStream == null)
+			logStream = Monitor.getStream();
+
+		if (dbname != null)
+		{
+			int endOfName = dbname.indexOf(';');
+			if (endOfName != -1)
+				dbname = dbname.substring(0, endOfName);
+		}
+		logStream.printlnWithHeader("(DATABASE = " + dbname + "), (DRDAID = " + drdaID + "), " + msg);
+	}
+	/**
+	 * Write RDBNAM
+	 *
+	 * @param rdbnam 	database name
+	 * @exception DRDAProtocolException
+	 */
+	protected void writeRDBNAM(String rdbnam)
+		throws DRDAProtocolException
+	{
+		int len = rdbnam.length();
+		if (len < CodePoint.RDBNAM_LEN)
+			len = CodePoint.RDBNAM_LEN;
+		writer.writeScalarHeader(CodePoint.RDBNAM, len);
+		try {
+			writer.writeScalarPaddedBytes(rdbnam.getBytes(server.DEFAULT_ENCODING),
+				len, server.SPACE_CHAR);
+		}
+		catch (UnsupportedEncodingException e)
+		{
+			agentError("Unsupported coding exception for server encoding "
+				+ server.DEFAULT_ENCODING);
+		}
+	}
+	/***************************************************************************
+	 *                   Private methods
+	 ***************************************************************************/
+
+	/**
+	 * Initialize class
+	 */
+	private void initialize()
+	{
+		// set input and output sockets
+		// this needs to be done before creating reader
+		sockis = session.sessionInput;
+		sockos = session.sessionOutput;
+
+		reader = new DDMReader(this, session.dssTrace);
+		writer = new DDMWriter(ccsidManager, this, session.dssTrace);
+	}
+
+	/**
+	 * Initialize for a new session
+	 */
+	private void initializeForSession()
+	{
+		// set input and output sockets
+		sockis = session.sessionInput;
+		sockos = session.sessionOutput;
+
+		// intialize reader and writer
+		reader.initialize(this, session.dssTrace);
+		writer.reset(session.dssTrace);
+
+		// initialize local pointers to session info
+		database = session.database;
+		appRequester = session.appRequester;
+
+		// set sqlamLevel
+		if (session.state == Session.ATTEXC)
+			sqlamLevel = appRequester.getManagerLevel(CodePoint.SQLAM);
+
+	}
+	/**      
+	 * In initial state for a session, 
+	 * determine whether this is a command
+	 * session or a DRDA protocol session.  A command session is for changing
+	 * the configuration of the Net server, e.g., turning tracing on
+	 * If it is a command session, process the command and close the session.
+	 * If it is a DRDA session, exchange server attributes and change session
+	 * state.
+	 */
+	private void sessionInitialState()
+		throws Exception
+	{
+		// process NetworkServerControl commands - if it is not either valid protocol  let the 
+		// DRDA error handling handle it
+		if (reader.isCmd())
+		{
+			try {
+				server.processCommands(reader, writer, session);
+				// reset reader and writer
+				reader.initialize(this, null);
+				writer.reset(null);
+				closeSession();
+			} catch (Throwable t) {
+				if (t instanceof InterruptedException)
+					throw (InterruptedException)t;
+				else
+				{
+					server.consoleExceptionPrintTrace(t);
+				}
+			}
+
+		}
+		else
+		{
+			// exchange attributes with application requester
+			if (exchangeServerAttributes())
+				session.state = Session.ATTEXC;
+			else
+				closeSession();
+		}
+	}
+	/**
+	 * Process DRDA commands we can receive once server attributes have been
+	 * exchanged.
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void processCommands() throws DRDAProtocolException
+	{
+		DRDAStatement stmt = null;
+		int updateCount = 0;
+		boolean PRPSQLSTTfailed = false;
+		do
+		{
+			correlationID = reader.readDssHeader();
+			int codePoint = reader.readLengthAndCodePoint();
+			switch(codePoint)
+			{
+				case CodePoint.CNTQRY:
+					try{
+						stmt = parseCNTQRY();
+						if (stmt != null)
+						{
+							writeQRYDTA(stmt);
+							if (stmt.rsIsClosed())
+							{
+								writeENDQRYRM(CodePoint.SVRCOD_WARNING);
+								writeNullSQLCARDobject();
+							}
+							// Send any warnings if JCC can handle them
+							checkWarning(null, null, stmt.getResultSet(), true, 0, false, sendWarningsOnCNTQRY);
+						}
+						send();
+
+					}
+					catch(SQLException e)
+					{
+						if (stmt != null)
+ 						{
+							// if we got a SQLException we need to clean up and
+ 							// close the statement Beetle 4758
+							writer.clearBuffer();
+ 							if (! stmt.rsIsClosed())
+ 							{
+ 								try {
+ 									stmt.rsClose();
+ 								}
+ 								catch (SQLException ec)
+ 								{
+ 									if (SanityManager.DEBUG)
+ 										trace("Warning: Error closing statement");
+								}
+								writeABNUOWRM();
+								writeSQLCARD(true,e,CodePoint.SVRCOD_ERROR,0,0);
+							}
+						}
+						else 
+						{
+							writeSQLCARDs(e, false, 0);
+						}
+						errorInChain(e);
+					}
+					break;
+				case CodePoint.EXCSQLIMM:
+					try {
+						updateCount = parseEXCSQLIMM();
+						// RESOLVE: checking updateCount is not sufficient
+						// since it will be 0 for creates, we need to know when
+						// any logged changes are made to the database
+						// Not getting this right for JCC is probably O.K., this
+						// will probably be a problem for ODBC and XA
+						// The problem is that JDBC doesn't provide this information
+						// so we would have to expand the JDBC API or call a
+						// builtin method to check(expensive)
+						// For now we will assume that every execute immediate
+						// does an update (that is the most conservative thing)
+						boolean reuseCorrID = false;
+						if (database.RDBUPDRM_sent == false)
+						{
+							writeRDBUPDRM();
+							reuseCorrID = true;
+						}
+
+						// we need to set update count in SQLCARD
+						checkWarning(null, database.getDefaultStatement().getStatement(), null, reuseCorrID, updateCount, true, true);
+					} catch (SQLException e)
+					{
+						writeSQLCARDs(e, false, 0);
+						errorInChain(e);
+					}
+					break;
+
+				case CodePoint.EXCSQLSET:
+					try {
+						if (parseEXCSQLSET())
+						// all went well.
+							writeSQLCARDs(null,true,0);
+						writer.endDss();
+						send();
+					}
+					catch (SQLWarning w)
+					{
+						writeSQLCARD(true, w, CodePoint.SVRCOD_WARNING, 0, 0);
+						writer.endDss();
+						send();
+					}
+					catch (SQLException e)
+					{
+						writeSQLCARDs(e,false,0);
+						writer.endDss();
+						send();
+						errorInChain(e);
+					}
+					break;
+					
+				case CodePoint.PRPSQLSTT:
+					int sqldaType;
+					PRPSQLSTTfailed = false;
+					try {
+						database.getConnection().clearWarnings();
+						sqldaType = parsePRPSQLSTT();
+						if (sqldaType > 0)		// do write SQLDARD
+							writeSQLDARD(database.getCurrentStatement(),
+										 (sqldaType ==  CodePoint.TYPSQLDA_LIGHT_OUTPUT),
+										 database.getConnection().getWarnings());
+						else
+							checkWarning(database.getConnection(), null, null, false, 0, true, true);
+
+					} catch (SQLException e)
+					{
+						writeSQLCARDs(e, false, 0, true);
+						PRPSQLSTTfailed = true;
+						errorInChain(e);
+					}
+					break;
+				case CodePoint.OPNQRY:
+					PreparedStatement ps = null;
+					try {
+						if (PRPSQLSTTfailed) {
+							reader.skipBytes();
+							// read the command objects
+							// for ps with parameter
+							// Skip parameters too
+							if (reader.isChainedWithSameID())
+							{
+								correlationID = reader.readDssHeader();
+								reader.skipDss();
+							}
+							// If we failed to prepare, then we fail
+							// to open, which  means OPNQFLRM.
+							writeOPNQFLRM(null);
+							break;
+						}
+						String pkgnamcsn = parseOPNQRY();
+						if (pkgnamcsn != null)
+						{
+							stmt = database.getDRDAStatement(pkgnamcsn);
+							ps = stmt.getPreparedStatement();
+							ps.clearWarnings();
+							stmt.execute();
+							writeOPNQRYRM(false, stmt);
+							checkWarning(null, ps, null, true, 0, false, true);
+
+							writeQRYDSC(stmt, false);
+							// We could send QRYDTA here if there's no LOB data
+							// in the result set, and if we are using LMTBLKPRC, as
+							// allowed by drda spec, as an option.
+
+							stmt.rsSuspend();
+						}
+					}
+					catch (SQLException e)
+					{
+						try {
+							// Try to cleanup if we hit an error.
+							// We me have written all or part of
+							// OPNQRYRM and/or QRYDSC before hitting
+							// the error, so we have to clear the write
+							// buffer and ONLY write the OPNQLFRM.
+							writer.clearBuffer();
+							if (ps != null)
+								ps.close();
+							writeOPNQFLRM(e);
+						}
+						catch (SQLException pse) {}
+						errorInChain(e);
+					}
+					send();
+					break;
+				case CodePoint.RDBCMM:
+					try
+					{
+						if (SanityManager.DEBUG)
+							trace("Received commit");
+						if (!database.getConnection().getAutoCommit())
+						{
+							database.getConnection().clearWarnings();
+							database.commit();
+							writeENDUOWRM(COMMIT);
+							checkWarning(database.getConnection(), null, null, true, 0, true, true);
+						}
+						// we only want to write one of these per transaction
+						// so set to false in preparation for next command
+						database.RDBUPDRM_sent = false;
+					}
+					catch (SQLException e)
+					{
+						// Even in case of error, we have to write the ENDUOWRM.
+						writeENDUOWRM(COMMIT);
+						writeSQLCARDs(e, true, 0);
+						errorInChain(e);
+					}
+					break;
+				case CodePoint.RDBRLLBCK:
+					try
+					{
+						if (SanityManager.DEBUG)
+							trace("Received rollback");
+						database.getConnection().clearWarnings();
+						database.rollback();
+						writeENDUOWRM(ROLLBACK);
+						checkWarning(database.getConnection(), null, null, true, 0, true, true);
+						// we only want to write one of these per transaction
+						// so set to false in preparation for next command
+						database.RDBUPDRM_sent = false;
+					}
+					catch (SQLException e)
+					{
+						// Even in case of error, we have to write the ENDUOWRM.
+						writeENDUOWRM(ROLLBACK);
+						writeSQLCARDs(e, true, 0);
+						errorInChain(e);
+					}
+					break;
+				case CodePoint.CLSQRY:
+					try{
+						stmt = parseCLSQRY();
+						stmt.rsClose();
+						writeSQLCARDs(null, false, 0);
+					}
+					catch (SQLException e)
+					{
+						writeSQLCARDs(e, false, 0);
+						errorInChain(e);
+					}
+					break;
+				case CodePoint.EXCSAT:
+					parseEXCSAT2();
+					writeEXCSATRD();
+					break;
+				/* since we don't support sqlj, we won't get bind commands from jcc, we
+				 * might get it from ccc; just skip them.
+				 */
+				case CodePoint.BGNBND:
+					reader.skipBytes();
+					writeSQLCARDs(null, false, 0);
+					break;
+				case CodePoint.BNDSQLSTT:
+					reader.skipBytes();
+					parseSQLSTTDss();
+					writeSQLCARDs(null, false, 0);
+					break;
+				case CodePoint.SQLSTTVRB:
+					reader.skipBytes();
+					break;
+				case CodePoint.ENDBND:
+					reader.skipBytes();
+					writeSQLCARDs(null, false, 0);
+					break;
+				case CodePoint.DSCSQLSTT:
+					if (PRPSQLSTTfailed) {
+						reader.skipBytes();
+						writeSQLCARDs(null, false, 0);
+						break;
+					}
+					try {
+						boolean rtnOutput = parseDSCSQLSTT();
+						writeSQLDARD(database.getCurrentStatement(), rtnOutput,
+									 null);
+						
+					} catch (SQLException e)
+					{
+						server.consoleExceptionPrint(e);
+						try {
+							writeSQLDARD(database.getCurrentStatement(), true, e);
+						} catch (SQLException e2) {	// should not get here since doing nothing with ps
+							agentError("Why am I getting another SQLException?");
+						}
+						errorInChain(e);
+					}
+					send();
+					break;
+				case CodePoint.EXCSQLSTT:
+					if (PRPSQLSTTfailed) {
+						reader.skipBytes();
+						// Skip parameters too if they are chained Beetle 4867
+						while(reader.isChainedWithSameID())
+						{
+							correlationID = reader.readDssHeader();
+							reader.skipDss();
+						}
+						writeSQLCARDs(null, false, 0);
+						break;
+					}
+					try {
+						parseEXCSQLSTT();
+
+						DRDAStatement curStmt = database.getCurrentStatement();
+						if (curStmt != null)
+							curStmt.rsSuspend();
+					} catch (SQLException e)
+					{
+						if (SanityManager.DEBUG) 
+						{
+							server.consoleExceptionPrint(e);
+						}
+						writeSQLCARDs(e, false, 0);
+						errorInChain(e);
+					}
+					break;
+				default:
+					codePointNotSupported(codePoint);
+			}
+		}
+		while (reader.isChainedWithSameID() || reader.isChainedWithDiffID());
+		send();
+	}
+
+	/**
+	 * If there's a severe error in the DDM chain, and if the header indicates
+	 * "terminate chain on error", we stop processing further commands in the chain
+	 * nor do we send any reply for them.  In accordance to this, a SQLERRRM message 
+	 * indicating the severe error must have been sent! (otherwise application requestor,
+	 * such as JCC, would not terminate the receiving of chain replies.)
+	 *
+	 * Each DRDA command is processed independently. DRDA defines no interdependencies
+	 * across chained commands. A command is processed the same when received within
+	 * a set of chained commands or received separately.  The chaining was originally
+	 * defined as a way to save network costs.
+	 *
+ 	 * @param		the SQLException raised
+	 * @exception	DRDAProtocolException
+	 */
+	private void errorInChain(SQLException e) throws DRDAProtocolException
+	{
+		if (reader.terminateChainOnErr() && (getExceptionSeverity(e) > CodePoint.SVRCOD_ERROR))
+		{
+			if (SanityManager.DEBUG)  trace("terminating the chain on error...");
+			while(reader.isChainedWithSameID() || reader.isChainedWithDiffID())
+			{
+				correlationID = reader.readDssHeader();
+				reader.skipDss();
+			}
+		}
+	}
+
+	/**
+	 * Exchange server attributes with application requester
+	 *
+ 	 * @return true if the session was started successfully; false otherwise
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private boolean exchangeServerAttributes()
+		throws  DRDAProtocolException, SQLException
+	{
+		int codePoint;
+		boolean sessionOK = true;
+		correlationID = reader.readDssHeader();
+		if (SanityManager.DEBUG) {
+		  if (correlationID == 0)
+		  {
+		    SanityManager.THROWASSERT(
+					      "Unexpected value for correlationId = " + correlationID);
+		  }
+		}
+
+		codePoint = reader.readLengthAndCodePoint();
+
+		// The first code point in the exchange of attributes must be EXCSAT
+		if (codePoint != CodePoint.EXCSAT)
+		{
+			//Throw PRCCNVRM 
+			throw
+			    new DRDAProtocolException(DRDAProtocolException.DRDA_Proto_PRCCNVRM,
+										  this, codePoint,
+										  CodePoint.PRCCNVCD_EXCSAT_FIRST_AFTER_CONN);
+		}
+
+		// set up a new Application Requester to store information about the
+		// application requester for this session
+		appRequester = new AppRequester();
+		parseEXCSAT();
+		writeEXCSATRD();
+		send();
+
+		//we may have to do the access security more than once if we don't
+		//provide the requested security mechanism or we run into errors
+		//if we don't know the requested security mechanism
+		//we'll send our known security mechanisms and the requester will pick
+		//if he picks one that requires a security token then another ACCSEC 
+		//will flow
+		int securityCheckCode = 0;
+		boolean notdone = true;
+		while (notdone)
+		{
+			correlationID = reader.readDssHeader();
+			codePoint = reader.readLengthAndCodePoint();
+			verifyInOrderACCSEC_SECCHK(codePoint,CodePoint.ACCSEC);
+			securityCheckCode = parseACCSEC();
+			// need security token
+			if (securityCheckCode == 0  && 
+				database.securityMechanism == CodePoint.SECMEC_EUSRIDPWD &&
+				database.publicKeyIn == null)
+					securityCheckCode = CodePoint.SECCHKCD_SECTKNMISSING;
+
+			// shouldn't have security token
+			if (securityCheckCode == 0 &&
+				database.securityMechanism == CodePoint.SECMEC_USRIDPWD &&
+				database.publicKeyIn != null)
+					securityCheckCode = CodePoint.SECCHKCD_SECTKNMISSING;
+			if (SanityManager.DEBUG)
+				trace("** ACCSECRD securityCheckCode is: "+securityCheckCode);
+			writeACCSECRD(securityCheckCode);
+			// everything is O.K., we're done
+			if (securityCheckCode == 0) 
+			{
+				notdone = false;
+			}
+		}
+		correlationID = reader.readDssHeader();
+		codePoint = reader.readLengthAndCodePoint();
+		verifyInOrderACCSEC_SECCHK(codePoint,CodePoint.SECCHK);
+		securityCheckCode = parseSECCHK();
+		if (SanityManager.DEBUG)
+			trace("*** SECCHKRM securityCheckCode is: "+securityCheckCode);
+		writeSECCHKRM(securityCheckCode);
+		//at this point if the security check failed, we're done, the session failed
+		if (securityCheckCode != 0)
+		{
+			send();
+			return false;
+		}
+
+		correlationID = reader.readDssHeader();
+		codePoint = reader.readLengthAndCodePoint();
+		verifyRequiredObject(codePoint,CodePoint.ACCRDB);
+		int svrcod = parseACCRDB();
+
+		//if earlier we couldn't access the database
+		if (databaseAccessException != null)
+		{
+
+			//if the Database was not found we will try DS
+			int failureType = getRdbAccessErrorCodePoint();
+			if (failureType == CodePoint.RDBNFNRM 
+				|| failureType == CodePoint.RDBATHRM)
+			{
+				writeRDBfailure(failureType);
+				writeSQLCARD(true,databaseAccessException,
+					CodePoint.SVRCOD_ERROR,0,0);
+			}
+			else
+			{
+				writeRDBfailure(CodePoint.RDBAFLRM);
+				// RDBAFLRM requires TYPDEFNAM and TYPDEFOVR
+				writer.writeScalarString(CodePoint.TYPDEFNAM,
+										 CodePoint.TYPDEFNAM_QTDSQLASC);
+				writeTYPDEFOVR();
+				writeSQLCARD(true,databaseAccessException,
+							 CodePoint.SVRCOD_ERROR,0,0);
+			}
+
+			send();
+			return false;
+		}
+		else if (database.accessCount > 1 )	// already in conversation with database
+		{
+			writeRDBfailure(CodePoint.RDBACCRM);
+			send();
+			return false;
+		}
+		else // everything is fine
+			writeACCRDBRM(svrcod);
+
+		// compare this application requester with previously stored
+		// application requesters and if we have already seen this one
+		// use stored application requester 
+		session.appRequester = server.getAppRequester(appRequester);
+		return sessionOK;
+	}
+	/**
+	 * Write RDB Failure
+	 *
+	 * Instance Variables
+	 * 	SVRCOD - Severity Code - required
+	 *	RDBNAM - Relational Database name - required
+	 *  SRVDGN - Server Diagnostics - optional (not sent for now)
+ 	 *
+	 * @param	codePoint	codepoint of failure
+	 */
+	private void writeRDBfailure(int codePoint) throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(codePoint);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, CodePoint.SVRCOD_ERROR);
+		writeRDBNAM(database.dbName);
+    	writer.endDdmAndDss();
+
+	}
+
+	/* Check the database access exception and return the appropriate
+	   error codepoint.
+	   RDBNFNRM - Database not found
+	   RDBATHRM - Not Authorized
+	   RDBAFLRM - Access failure
+	   @return RDB Access codepoint 
+	           
+	*/
+
+	private int getRdbAccessErrorCodePoint()
+	{
+		String sqlState = databaseAccessException.getSQLState();
+		if (sqlState.regionMatches(0,SQLState.DATABASE_NOT_FOUND,0,5) |
+			sqlState.regionMatches(0,SQLState.NO_SUCH_DATABASE,0,5))
+			return CodePoint.RDBNFNRM;
+		else
+			if (sqlState.regionMatches(0,SQLState.LOGIN_FAILED,0,5) ||
+				sqlState.regionMatches(0,SQLState.AUTH_INVALID_USER_NAME,0,5))
+				return CodePoint.RDBATHRM;
+		else
+				return CodePoint.RDBAFLRM;
+	}
+
+
+	/**
+	 * Verify userId and password
+	 *
+	 * Username and password is verified by making a connection to the
+	 * database
+	 *
+	 * @return security check code, 0 is O.K.
+	 * @exception DRDAProtocolException
+	 */
+	private int verifyUserIdPassword() throws DRDAProtocolException
+	{
+		databaseAccessException = null;
+		int retSecChkCode = 0;
+
+
+		String realName = database.dbName; //first strip off properties
+		int endOfName = realName.indexOf(';');
+		if (endOfName != -1)
+			realName = realName.substring(0, endOfName);
+		retSecChkCode = getConnFromDatabaseName();
+
+		return retSecChkCode;
+	}
+
+	/**
+	 * Get connection from a database name
+	 *
+	 * Username and password is verified by making a connection to the
+	 * database
+	 *
+	 * @return security check code, 0 is O.K.
+	 * @exception DRDAProtocolException
+	 */
+	private int getConnFromDatabaseName() throws DRDAProtocolException
+	{
+		Properties p = new Properties();
+		databaseAccessException = null;
+		p.put(Attribute.USERNAME_ATTR, database.userId);
+		p.put(Attribute.PASSWORD_ATTR, database.password);
+		//if we haven't got the correlation token yet, use session number for drdaID
+		if (session.drdaID == null)
+			session.drdaID = leftBrace + session.connNum + rightBrace;
+		p.put(Attribute.DRDAID_ATTR, session.drdaID);
+	 	try {
+			Connection conn =
+				server.cloudscapeDriver.connect(Attribute.PROTOCOL  + database.dbName, p);
+	  		conn.setAutoCommit(false);
+			database.setConnection(conn);
+	  	} catch (SQLException se) {
+			String sqlState = se.getSQLState();
+			// need to set the security check code based on the reason the connection     
+			// was denied, Cloudscape doesn't say whether the userid or password caused
+			// the problem, so we will just return userid invalid
+			databaseAccessException = se;
+			for (; se != null; se = se.getNextException())
+			{
+				if (SanityManager.DEBUG)
+					trace(se.getMessage());
+	 			println2Log(database.dbName, session.drdaID, se.getMessage());
+			}
+
+			if (sqlState.regionMatches(0,SQLState.LOGIN_FAILED,0,5))
+				return CodePoint.SECCHKCD_USERIDINVALID;
+
+			return 0;
+			
+		}
+		catch (Exception e)
+		{
+			// If cloudscape has shut down for some reason,
+			// we will send  an agent error and then try to 
+			// get the driver loaded again.  We have to get
+			// rid of the client first in case they are holding
+			// the DriverManager lock.
+			println2Log(database.dbName, session.drdaID, 
+						"Driver not loaded"
+						+ e.getMessage());
+				try {
+					agentError("Driver not loaded");
+				}
+				catch (DRDAProtocolException dpe)
+				{
+					// Retry starting the server before rethrowing 
+					// the protocol exception.  Then hopfully all
+					// will be well when they try again.
+					try {
+						server.startDB2j();
+					} catch (Exception re) {
+						println2Log(database.dbName, session.drdaID, "Failed attempt to reload driver " +re.getMessage()  );
+					}
+					throw dpe;
+				}
+		}
+		
+	
+		// Everything worked so log connection to the database.
+		if (getLogConnections())
+	 		println2Log(database.dbName, session.drdaID,
+				"Cloudscape Network Server connected to database " +
+						database.dbName);
+		return 0;
+	}
+
+
+	/**
+	 * Parses EXCSAT (Exchange Server Attributes)
+	 * Instance variables
+	 *	EXTNAM(External Name)	- optional
+	 *  MGRLVLLS(Manager Levels) - optional
+	 *	SPVNAM(Supervisor Name) - optional
+	 *  SRVCLSNM(Server Class Name) - optional
+	 *  SRVNAM(Server Name) - optional, ignorable
+	 *  SRVRLSLV(Server Product Release Level) - optional, ignorable
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void parseEXCSAT() throws DRDAProtocolException
+	{
+		int codePoint;
+		String strVal;
+
+
+		reader.markCollection();
+
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.EXTNAM:
+					appRequester.extnam = reader.readString();
+					if (SanityManager.DEBUG)
+						trace("extName = " + appRequester.extnam);
+					if (appRequester.extnam.length() > CodePoint.MAX_NAME)
+						tooBig(CodePoint.EXTNAM);
+					break;
+				// optional
+				case CodePoint.MGRLVLLS:
+					parseMGRLVLLS(1);
+					break;
+				// optional 
+				case CodePoint.SPVNAM:
+					appRequester.spvnam = reader.readString();
+					// This is specified as a null parameter so length should
+					// be zero
+					if (appRequester.spvnam != null)
+						badObjectLength(CodePoint.SPVNAM);
+					break;
+				// optional
+				case CodePoint.SRVNAM:
+					appRequester.srvnam = reader.readString();
+					if (SanityManager.DEBUG)
+						trace("serverName = " +  appRequester.srvnam);
+					if (appRequester.srvnam.length() > CodePoint.MAX_NAME)
+						tooBig(CodePoint.SRVNAM);
+					break;
+				// optional
+				case CodePoint.SRVRLSLV:
+					appRequester.srvrlslv = reader.readString();
+					if (SanityManager.DEBUG)
+						trace("serverlslv = " + appRequester.srvrlslv);
+					if (appRequester.srvrlslv.length() > CodePoint.MAX_NAME)
+						tooBig(CodePoint.SRVRLSLV);
+					break;
+				// optional
+				case CodePoint.SRVCLSNM:
+					appRequester.srvclsnm = reader.readString();
+					if (SanityManager.DEBUG)
+						trace("serverClassName = " + appRequester.srvclsnm);
+					if (appRequester.srvclsnm.length() > CodePoint.MAX_NAME)
+						tooBig(CodePoint.SRVCLSNM);
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+	}
+	/**
+	 * Parses EXCSAT2 (Exchange Server Attributes)
+	 * Instance variables
+	 *	EXTNAM(External Name)	- optional
+	 *  MGRLVLLS(Manager Levels) - optional
+	 *	SPVNAM(Supervisor Name) - optional
+	 *  SRVCLSNM(Server Class Name) - optional
+	 *  SRVNAM(Server Name) - optional, ignorable
+	 *  SRVRLSLV(Server Product Release Level) - optional, ignorable
+	 *
+	 * @exception DRDAProtocolException
+	 * 
+	 * This parses a second occurrence of an EXCSAT command
+	 * The target must ignore the values for extnam, srvclsnm, srvnam and srvrlslv.
+	 * I am also going to ignore spvnam since it should be null anyway.
+	 * Only new managers can be added.
+	 */
+	private void parseEXCSAT2() throws DRDAProtocolException
+	{
+		int codePoint;
+		reader.markCollection();
+
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.EXTNAM:
+				case CodePoint.SRVNAM:
+				case CodePoint.SRVRLSLV:
+				case CodePoint.SRVCLSNM:
+				case CodePoint.SPVNAM:
+					reader.skipBytes();
+					break;
+				// optional
+				case CodePoint.MGRLVLLS:
+					parseMGRLVLLS(2);
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+	}
+
+	/**
+	 *	Parse manager levels
+	 *  Instance variables
+	 *		MGRLVL - repeatable, required
+	 *		  CODEPOINT
+	 *			CCSIDMGR - CCSID Manager
+	 *			CMNAPPC - LU 6.2 Conversational Communications Manager 
+	 *			CMNSYNCPT - SNA LU 6.2 SyncPoint Conversational Communications Manager
+	 *			CMNTCPIP - TCP/IP Communication Manager 
+	 *			DICTIONARY - Dictionary
+	 *			RDB - Relational Database 
+	 *			RSYNCMGR - Resynchronization Manager 
+	 *			SECMGR - Security Manager
+	 *			SQLAM - SQL Application Manager
+	 *			SUPERVISOR - Supervisor
+	 *			SYNCPTMGR - Sync Point Manager 
+	 *		  VALUE
+	 *
+	 *	On the second appearance of this codepoint, it can only add managers
+	 *
+	 * @param time	1 for first time this is seen, 2 for subsequent ones
+	 * @exception DRDAProtocolException
+	 * 
+	 */
+	private void parseMGRLVLLS(int time) throws DRDAProtocolException
+	{
+		int manager, managerLevel;
+		int currentLevel;
+		// set up vectors to keep track of manager information
+		unknownManagers = new Vector();
+		knownManagers = new Vector();
+		errorManagers = new Vector();
+		errorManagersLevel = new Vector();
+		if (SanityManager.DEBUG)
+			trace("Manager Levels");
+
+		while (reader.moreDdmData())
+		{
+			manager = reader.readNetworkShort();
+			managerLevel = reader.readNetworkShort();
+			if (CodePoint.isKnownManager(manager))
+			{
+				knownManagers.addElement(new Integer(manager));
+				//if the manager level hasn't been set, set it
+				currentLevel = appRequester.getManagerLevel(manager);
+				if (currentLevel == appRequester.MGR_LEVEL_UNKNOWN)
+			    	appRequester.setManagerLevel(manager, managerLevel);
+				else
+				{
+					//if the level is still the same we'll ignore it
+					if (currentLevel != managerLevel)
+					{
+						//keep a list of conflicting managers
+						errorManagers.addElement(new Integer(manager));
+						errorManagersLevel.addElement(new Integer (managerLevel));
+					}
+				}
+
+			}
+			else
+				unknownManagers.addElement(new Integer(manager));
+			if (SanityManager.DEBUG)
+				trace("Manager = " + java.lang.Integer.toHexString(manager) + 
+					  " ManagerLevel " + managerLevel);
+		}
+		sqlamLevel = appRequester.getManagerLevel(CodePoint.SQLAM);
+		// did we have any errors
+		if (errorManagers.size() > 0)
+		{
+			Object [] oa = new Object[errorManagers.size()*2];
+			int j = 0;
+			for (int i = 0; i < errorManagers.size(); i++)
+			{
+				oa[j++] = errorManagers.elementAt(i);
+				oa[j++] = errorManagersLevel.elementAt(i);
+			}
+			throw new DRDAProtocolException(DRDAProtocolException.DRDA_Proto_MGRLVLRM,
+										  this, 0,
+										  0, oa);
+		}
+	}
+	/**
+	 * Write reply to EXCSAT command
+	 * Instance Variables
+	 *	EXTNAM - External Name (optional)
+	 *  MGRLVLLS - Manager Level List (optional)
+	 *  SRVCLSNM - Server Class Name (optional) - used by JCC
+	 *  SRVNAM - Server Name (optional)
+	 *  SRVRLSLV - Server Product Release Level (optional)
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void writeEXCSATRD() throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.EXCSATRD);
+		writer.writeScalarString(CodePoint.EXTNAM, server.att_extnam);
+		//only reply with manager levels if we got sent some
+		if (knownManagers != null && knownManagers.size() > 0)
+			writeMGRLEVELS();
+		writer.writeScalarString(CodePoint.SRVCLSNM, server.att_srvclsnm);
+		writer.writeScalarString(CodePoint.SRVNAM, server.ATT_SRVNAM);
+		writer.writeScalarString(CodePoint.SRVRLSLV, server.att_srvrlslv);
+    	writer.endDdmAndDss();
+	}
+	/**
+	 * Write manager levels
+	 * The target server must not provide information for any target
+	 * managers unless the source explicitly requests it.
+	 * For each manager class, if the target server's support level
+     * is greater than or equal to the source server's level, then the source
+     * server's level is returned for that class if the target server can operate
+     * at the source's level; otherwise a level 0 is returned.  If the target
+     * server's support level is less than the source server's level, the
+     * target server's level is returned for that class.  If the target server
+     * does not recognize the code point of a manager class or does not support
+     * that class, it returns a level of 0.  The target server then waits
+     * for the next command or for the source server to terminate communications.
+     * When the source server receives EXCSATRD, it must compare each of the entries
+     * in the mgrlvlls parameter it received to the corresponding entries in the mgrlvlls
+     * parameter it sent.  If any level mismatches, the source server must decide
+     * whether it can use or adjust to the lower level of target support for that manager
+     * class.  There are no architectural criteria for making this decision.
+     * The source server can terminate communications or continue at the target
+     * servers level of support.  It can also attempt to use whatever
+     * commands its user requests while receiving error reply messages for real
+     * functional mismatches.
+     * The manager levels the source server specifies or the target server
+     * returns must be compatible with the manager-level dependencies of the specified
+     * manangers.  Incompatible manager levels cannot be specified.
+	 *  Instance variables
+	 *		MGRLVL - repeatable, required
+	 *		  CODEPOINT
+	 *			CCSIDMGR - CCSID Manager
+	 *			CMNAPPC - LU 6.2 Conversational Communications Manager 
+	 *			CMNSYNCPT - SNA LU 6.2 SyncPoint Conversational Communications Manager
+	 *			CMNTCPIP - TCP/IP Communication Manager   
+	 *			DICTIONARY - Dictionary 
+	 *			RDB - Relational Database 
+	 *			RSYNCMGR - Resynchronization Manager   
+	 *			SECMGR - Security Manager
+	 *			SQLAM - SQL Application Manager 
+	 *			SUPERVISOR - Supervisor 
+	 *			SYNCPTMGR - Sync Point Manager 
+	 *			XAMGR - XA manager 
+	 *		  VALUE
+	 */
+	private void writeMGRLEVELS() throws DRDAProtocolException
+	{
+		int manager;
+		int appLevel;
+		int serverLevel;
+		writer.startDdm(CodePoint.MGRLVLLS);
+		for (int i = 0; i < knownManagers.size(); i++)
+		{
+			manager = ((Integer)knownManagers.elementAt(i)).intValue();
+			appLevel = appRequester.getManagerLevel(manager);
+			serverLevel = server.getManagerLevel(manager);
+			if (serverLevel >= appLevel)
+			{
+				//Note appLevel has already been set to 0 if we can't support
+				//the original app Level
+				writer.writeCodePoint4Bytes(manager, appLevel);
+			}
+			else
+			{
+				writer.writeCodePoint4Bytes(manager, serverLevel);
+				// reset application manager level to server level
+				appRequester.setManagerLevel(manager, serverLevel);
+			}
+		}
+		// write 0 for all unknown managers
+		for (int i = 0; i < unknownManagers.size(); i++)
+		{
+			manager = ((Integer)unknownManagers.elementAt(i)).intValue();
+			writer.writeCodePoint4Bytes(manager, 0);
+		}
+		writer.endDdm();
+	}
+	/**
+	 *  Parse Access Security
+	 *
+	 *	If the target server supports the SECMEC requested by the application requester
+	 *	then a single value is returned and it is identical to the SECMEC value
+	 *	in the ACCSEC command.  If the target server does not support the SECMEC
+	 *	requested, then one or more values are returned and the application requester
+	 *  must choose one of these values for the security mechanism.
+	 *  We currently support
+	 *		- user id and password (default for JCC)
+	 *		- encrypted user id and password
+	 *
+     *  Instance variables
+	 *    SECMGRNM  - security manager name - optional
+	 *	  SECMEC 	- security mechanism - required
+	 *	  RDBNAM	- relational database name - optional
+	 * 	  SECTKN	- security token - optional, (required if sec mech. needs it)
+	 *
+	 *  @return security check code - 0 if everything O.K.
+	 */
+	private int parseACCSEC() throws  DRDAProtocolException
+	{
+		int securityCheckCode = 0;
+		int securityMechanism = 0;
+		byte [] publicKeyIn = null;
+
+		reader.markCollection();
+		int codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch(codePoint)
+			{
+				//optional
+				case CodePoint.SECMGRNM:
+					// this is defined to be 0 length
+					if (reader.getDdmLength() != 0)
+						badObjectLength(CodePoint.SECMGRNM);
+					break;
+				//required
+				case CodePoint.SECMEC:
+					checkLength(CodePoint.SECMEC, 2);
+					securityMechanism = reader.readNetworkShort();
+					if (SanityManager.DEBUG)
+						trace("Security mechanism = " + securityMechanism);
+					if (securityMechanism != server.DEFAULT_SECURITY_MECHANISM)
+					{
+						//this is the only other one we understand
+						if (securityMechanism != CodePoint.SECMEC_EUSRIDPWD)
+							securityCheckCode = CodePoint.SECCHKCD_NOTSUPPORTED;
+						else
+						{
+							try {
+								if (decryptionManager == null)
+									decryptionManager = new DecryptionManager();
+								myPublicKey = decryptionManager.obtainPublicKey();
+							} catch (SQLException e) {
+								println2Log(null, session.drdaID, e.getMessage());
+								// Local security service non-retryable error.
+								securityCheckCode = CodePoint.SECCHKCD_0A;
+							}
+						}
+					}
+					break;
+				//optional (currently required for Cloudscape - may need to revisit)
+				case CodePoint.RDBNAM:
+					String dbname = parseRDBNAM();
+					Database d = session.getDatabase(dbname);
+					if (d == null)
+						addDatabase(dbname);
+					else
+						database = d;
+					break;
+				//optional - depending on security Mechanism 
+				case CodePoint.SECTKN:
+					publicKeyIn = reader.readBytes();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+		// check for required CodePoint's
+		if (securityMechanism == 0)
+			missingCodePoint(CodePoint.SECMEC);
+
+
+		// RESOLVE - when we look further into security we might want to
+		// handle this part of the protocol at the session level without
+		// requiring a database for when authentication is used but there
+		// is no database level security
+		if (database == null)
+			missingCodePoint(CodePoint.RDBNAM);
+
+		database.securityMechanism = securityMechanism;
+		database.publicKeyIn = publicKeyIn;
+
+		return securityCheckCode;
+
+	}
+	/**
+	 * Parse OPNQRY
+	 * Instance Variables
+	 *  RDBNAM - relational database name - optional
+	 *  PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required
+	 *  QRYBLKSZ - Query Block Size - required
+	 *  QRYBLKCTL - Query Block Protocol Control - optional 
+	 *  MAXBLKEXT - Maximum Number of Extra Blocks - optional - default value 0
+	 *  OUTOVROPT - Output Override Option
+	 *  QRYROWSET - Query Rowset Size - optional - level 7
+	 *  MONITOR - Monitor events - optional.
+	 *
+	 * @return package name consistency token
+	 * @exception DRDAProtocolException
+	 */
+	private String parseOPNQRY() throws DRDAProtocolException, SQLException
+	{
+		String pkgnamcsn = null;
+		boolean gotQryblksz = false;
+		int blksize = 0;
+		int qryblkctl = CodePoint.QRYBLKCTL_DEFAULT;
+		int maxblkext = CodePoint.MAXBLKEXT_DEFAULT;
+		int qryrowset = CodePoint.QRYROWSET_DEFAULT;
+		int qryclsimp = CodePoint.QRYCLSIMP_DEFAULT;
+		int outovropt = CodePoint.OUTOVRFRS;
+		reader.markCollection();
+		int codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch(codePoint)
+			{
+				//optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.OPNQRY);
+					break;
+				//required
+				case CodePoint.PKGNAMCSN:
+					pkgnamcsn = parsePKGNAMCSN();
+					break;
+				//required
+			  	case CodePoint.QRYBLKSZ:
+					blksize = parseQRYBLKSZ();
+					gotQryblksz = true;
+					break;
+				//optional
+			  	case CodePoint.QRYBLKCTL:
+					qryblkctl = reader.readNetworkShort();
+					//The only type of query block control we can specify here
+					//is forced fixed row
+					if (qryblkctl != CodePoint.FRCFIXROW)
+						invalidCodePoint(qryblkctl);
+					if (SanityManager.DEBUG)
+						trace("!!qryblkctl = "+Integer.toHexString(qryblkctl));
+					gotQryblksz = true;
+					break;
+				//optional
+			  	case CodePoint.MAXBLKEXT:
+					maxblkext = reader.readSignedNetworkShort();
+					if (SanityManager.DEBUG)
+						trace("maxblkext = "+maxblkext);
+					break;
+				// optional
+				case CodePoint.OUTOVROPT:
+					outovropt = parseOUTOVROPT();
+					break;
+				//optional
+				case CodePoint.QRYROWSET:
+					//Note minimum for OPNQRY is 0
+					qryrowset = parseQRYROWSET(0);
+					break;
+				case CodePoint.QRYCLSIMP:
+					// Implicitly close non-scrollable cursor
+					qryclsimp = parseQRYCLSIMP();
+					break;
+				case CodePoint.QRYCLSRLS:
+					// Ignore release of read locks.  Nothing we can do here
+					parseQRYCLSRLS();
+					break;
+				case CodePoint.QRYOPTVAL:
+					// optimize for n rows. Not supported by cloudscape(ignore)
+					parseQRYOPTVAL();
+					break;
+				// optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+			  	default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+		// check for required variables
+		if (pkgnamcsn == null)
+			missingCodePoint(CodePoint.PKGNAMCSN);
+		if (!gotQryblksz)
+			missingCodePoint(CodePoint.QRYBLKSZ);
+
+		// get the statement we are opening
+		DRDAStatement stmt = database.getDRDAStatement(pkgnamcsn);
+		if (stmt == null)
+		{
+			//XXX should really throw a SQL Exception here
+			invalidValue(CodePoint.PKGNAMCSN);
+		}
+
+		// check that this statement is not already open
+		// commenting this check out for now
+		// it turns out that JCC doesn't send a close if executeQuery is
+		// done again without closing the previous result set
+		// this check can't be done since the second executeQuery should work
+		//if (stmt.state != DRDAStatement.NOT_OPENED)
+		//{
+		//	writeQRYPOPRM();
+		//	pkgnamcsn = null;
+		//}
+		//else
+		//{
+		stmt.setOPNQRYOptions(blksize,qryblkctl,maxblkext,outovropt,
+							  qryrowset, qryclsimp);
+		//}
+
+		// read the command objects
+		// for ps with parameter
+		if (reader.isChainedWithSameID())
+		{
+			if (SanityManager.DEBUG)
+				trace("&&&&&& parsing SQLDTA");
+			parseOPNQRYobjects(stmt);
+		}
+		return pkgnamcsn;
+	}
+	/**
+	 * Parse OPNQRY objects
+	 * Objects
+	 *  TYPDEFNAM - Data type definition name - optional
+	 *  TYPDEFOVR - Type defintion overrides - optional
+	 *  SQLDTA- SQL Program Variable Data - optional
+	 *
+	 * If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects
+	 * sent with the statement.  Once the statement is over, the default values
+	 * sent in the ACCRDB are once again in effect.  If no values are supplied,
+	 * the values sent in the ACCRDB are used.
+	 * Objects may follow in one DSS or in several DSS chained together.
+	 * 
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void parseOPNQRYobjects(DRDAStatement stmt) 
+		throws DRDAProtocolException, SQLException
+	{
+		int codePoint;
+		do
+		{
+			correlationID = reader.readDssHeader();
+			while (reader.moreDssData())
+			{
+				codePoint = reader.readLengthAndCodePoint();
+				switch(codePoint)
+				{
+					// optional
+					case CodePoint.TYPDEFNAM:
+						setStmtOrDbByteOrder(false, stmt, parseTYPDEFNAM());
+						break;
+					// optional
+					case CodePoint.TYPDEFOVR:
+						parseTYPDEFOVR(stmt);
+						break;
+					// optional 
+					case CodePoint.SQLDTA:
+						parseSQLDTA(stmt);
+						break;
+					// optional
+					case CodePoint.EXTDTA:	
+						readAndSetAllExtParams(stmt);
+						break;
+					default:
+						invalidCodePoint(codePoint);
+				}
+			}
+		} while (reader.isChainedWithSameID());
+
+	}
+	/**
+	 * Parse OUTOVROPT - this indicates whether output description can be
+	 * overridden on just the first CNTQRY or on any CNTQRY
+	 *
+	 * @return output override option
+	 * @exception DRDAProtocolException
+	 */
+	private int parseOUTOVROPT() throws DRDAProtocolException
+	{
+		checkLength(CodePoint.OUTOVROPT, 1);
+		int outovropt = reader.readUnsignedByte();
+		if (SanityManager.DEBUG)
+			trace("output override option: "+outovropt);
+		if (outovropt != CodePoint.OUTOVRFRS && outovropt != CodePoint.OUTOVRANY)
+			invalidValue(CodePoint.OUTOVROPT);
+		return outovropt;
+	}
+
+	/**
+	 * Parse QRYBLSZ - this gives the maximum size of the query blocks that
+	 * can be returned to the requester
+	 *
+	 * @return query block size
+	 * @exception DRDAProtocolException
+	 */
+	private int parseQRYBLKSZ() throws DRDAProtocolException
+	{
+		checkLength(CodePoint.QRYBLKSZ, 4);
+		int blksize = reader.readNetworkInt();
+		if (SanityManager.DEBUG)
+			trace("qryblksz = "+blksize);
+		if (blksize < CodePoint.QRYBLKSZ_MIN || blksize > CodePoint.QRYBLKSZ_MAX)
+			invalidValue(CodePoint.QRYBLKSZ);
+		return blksize;
+	}
+	/**
+ 	 * Parse QRYROWSET - this is the number of rows to return
+	 *
+	 * @param minVal - minimum value
+	 * @return query row set size
+	 * @exception DRDAProtocolException
+	 */
+	private int parseQRYROWSET(int minVal) throws DRDAProtocolException
+	{
+		checkLength(CodePoint.QRYROWSET, 4);
+		int qryrowset = reader.readNetworkInt();
+		if (SanityManager.DEBUG)
+			trace("qryrowset = " + qryrowset);
+		if (qryrowset < minVal || qryrowset > CodePoint.QRYROWSET_MAX)
+			invalidValue(CodePoint.QRYROWSET);
+		return qryrowset;
+	}
+
+	/** Parse a QRYCLSIMP - Implicitly close non-scrollable cursor 
+	 * after end of data.
+	 * @return  true to close on end of data 
+	 */
+	private int  parseQRYCLSIMP() throws DRDAProtocolException
+	{
+	   
+		checkLength(CodePoint.QRYCLSIMP, 1);
+		int qryclsimp = reader.readUnsignedByte();
+		if (SanityManager.DEBUG)
+			trace ("qryclsimp = " + qryclsimp);
+		if (qryclsimp != CodePoint.QRYCLSIMP_SERVER_CHOICE &&
+			qryclsimp != CodePoint.QRYCLSIMP_YES &&
+			qryclsimp != CodePoint.QRYCLSIMP_NO )
+			invalidValue(CodePoint.QRYCLSIMP);
+		return qryclsimp;
+	}
+
+
+	private int parseQRYCLSRLS() throws DRDAProtocolException
+	{
+		reader.skipBytes();
+		return 0;
+	}
+
+	private int parseQRYOPTVAL() throws DRDAProtocolException
+	{
+		reader.skipBytes();
+		return 0;
+	}
+
+	/**
+	 * Write a QRYPOPRM - Query Previously opened
+	 * Instance Variables
+	 *  SVRCOD - Severity Code - required - 8 ERROR
+	 *  RDBNAM - Relational Database Name - required
+	 *  PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required
+	 * 
+	 * @exception DRDAProtocolException
+	 */
+	private void writeQRYPOPRM() throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.QRYPOPRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, CodePoint.SVRCOD_ERROR);
+		writeRDBNAM(database.dbName);
+		writePKGNAMCSN();
+		writer.endDdmAndDss();
+	}
+	/**
+	 * Write a QRYNOPRM - Query Not Opened
+	 * Instance Variables
+	 *  SVRCOD - Severity Code - required -  4 Warning 8 ERROR
+	 *  RDBNAM - Relational Database Name - required
+	 *  PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required
+	 * 
+	 * @param svrCod	Severity Code
+	 * @exception DRDAProtocolException
+	 */
+	private void writeQRYNOPRM(int svrCod) throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.QRYNOPRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, svrCod);
+		writeRDBNAM(database.dbName);
+		writePKGNAMCSN();
+		writer.endDdmAndDss();
+	}
+	/**
+	 * Write a OPNQFLRM - Open Query Failure
+	 * Instance Variables
+	 *  SVRCOD - Severity Code - required - 8 ERROR
+	 *  RDBNAM - Relational Database Name - required
+	 *
+	 * @param	e	Exception describing failure
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void writeOPNQFLRM(SQLException e) throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.OPNQFLRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, CodePoint.SVRCOD_ERROR);
+		writeRDBNAM(database.dbName);
+		writer.endDdm();
+		writer.startDdm(CodePoint.SQLCARD);
+		writeSQLCAGRP(e, getSqlCode(getExceptionSeverity(e)), 0, 0);
+		writer.endDdmAndDss();
+	}
+	/**
+	 * Write PKGNAMCSN
+	 * Instance Variables
+	 *   NAMESYMDR - database name - not validated
+	 *   RDBCOLID - RDB Collection Identifier
+	 *   PKGID - RDB Package Identifier
+	 *   PKGCNSTKN - RDB Package Consistency Token
+	 *   PKGSN - RDB Package Section Number
+	 *
+	 * There are two possible formats, fixed and extended which includes length
+	 * information for the strings
+	 *
+	 * @exception throws DRDAProtocolException
+	 */
+	private void writePKGNAMCSN(String pkgcnstknStr) throws DRDAProtocolException
+	{
+		writer.startDdm(CodePoint.PKGNAMCSN);
+		if (rdbcolid.length() == CodePoint.RDBCOLID_LEN && rdbnam.length() <= CodePoint.RDBNAM_LEN)
+		{	//fixed format
+			writer.writeScalarPaddedString(rdbnam, CodePoint.RDBNAM_LEN);
+			writer.writeScalarPaddedString(rdbcolid, CodePoint.RDBCOLID_LEN);
+			writer.writeScalarPaddedString(pkgid, CodePoint.PKGID_LEN);
+			writer.writeScalarPaddedString(pkgcnstknStr, CodePoint.PKGCNSTKN_LEN);
+			writer.writeShort(secnumber);
+		}
+		else	// extended format
+		{
+			writer.writeShort(rdbnam.length());
+			writer.writeScalarPaddedString(rdbnam, rdbnam.length());
+			writer.writeShort(rdbcolid.length());
+			writer.writeScalarPaddedString(rdbcolid, rdbcolid.length());
+			writer.writeShort(pkgid.length());
+			writer.writeScalarPaddedString(pkgid, pkgid.length());
+			writer.writeScalarPaddedString(pkgcnstknStr, CodePoint.PKGCNSTKN_LEN);
+			writer.writeShort(secnumber);
+		}
+		writer.endDdm();
+	}
+
+	private void writePKGNAMCSN() throws DRDAProtocolException
+	{
+		writePKGNAMCSN(pkgcnstknStr);
+	}
+
+	/**
+	 * Parse CNTQRY - Continue Query
+	 * Instance Variables
+	 *   RDBNAM - Relational Database Name - optional
+	 *   PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required
+	 *   QRYBLKSZ - Query Block Size - required
+	 *   QRYRELSCR - Query Relative Scrolling Action - optional
+	 *   QRYSCRORN - Query Scroll Orientation - optional - level 7
+	 *   QRYROWNBR - Query Row Number - optional
+	 *   QRYROWSNS - Query Row Sensitivity - optional - level 7
+	 *   QRYBLKRST - Query Block Reset - optional - level 7
+	 *   QRYRTNDTA - Query Returns Data - optional - level 7
+	 *   QRYROWSET - Query Rowset Size - optional - level 7
+	 *   QRYRFRTBL - Query Refresh Answer Set Table - optional
+	 *   NBRROW - Number of Fetch or Insert Rows - optional
+	 *   MAXBLKEXT - Maximum number of extra blocks - optional
+	 *   RTNEXTDTA - Return of EXTDTA Option - optional
+	 *   MONITOR - Monitor events - optional.
+	 *
+	 * @return DRDAStatement we are continuing
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private DRDAStatement parseCNTQRY() throws DRDAProtocolException, SQLException
+	{
+		byte val;
+		String pkgnamcsn = null;
+		boolean gotQryblksz = false;
+		boolean qryrelscr = true;
+		long qryrownbr = 1;
+		boolean qryrfrtbl = false;
+		int nbrrow = 1;
+		int blksize = 0;
+		int maxblkext = -1;
+		long qryinsid;
+		boolean gotQryinsid = false;
+		int qryscrorn = CodePoint.QRYSCRREL;
+		boolean qryrowsns = false;
+		boolean gotQryrowsns = false;
+		boolean qryblkrst = false;
+		boolean qryrtndta = true;
+		int qryrowset = CodePoint.QRYROWSET_DEFAULT;
+		int rtnextdta = CodePoint.RTNEXTROW;
+		reader.markCollection();
+		int codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch(codePoint)
+			{
+				//optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.CNTQRY);
+					break;
+				//required
+				case CodePoint.PKGNAMCSN:
+					pkgnamcsn = parsePKGNAMCSN();
+					break;
+				//required
+				case CodePoint.QRYBLKSZ:
+					blksize = parseQRYBLKSZ();
+					gotQryblksz = true;
+					break;
+				//optional
+				case CodePoint.QRYRELSCR:
+					qryrelscr = readBoolean(CodePoint.QRYRELSCR);
+					if (SanityManager.DEBUG)
+						trace("qryrelscr = "+qryrelscr);
+					break;
+				//optional
+				case CodePoint.QRYSCRORN:
+					checkLength(CodePoint.QRYSCRORN, 1);
+					qryscrorn = reader.readUnsignedByte();
+					if (SanityManager.DEBUG)
+						trace("qryscrorn = "+qryscrorn);
+					switch (qryscrorn)
+					{
+						case CodePoint.QRYSCRREL:
+						case CodePoint.QRYSCRABS:
+						case CodePoint.QRYSCRAFT:
+						case CodePoint.QRYSCRBEF:
+							break;
+						default:
+							invalidValue(CodePoint.QRYSCRORN);
+					}
+					break;
+				//optional
+				case CodePoint.QRYROWNBR:
+					checkLength(CodePoint.QRYROWNBR, 8);
+					qryrownbr = reader.readNetworkLong();
+					if (SanityManager.DEBUG)
+						trace("qryrownbr = "+qryrownbr);
+					break;
+				//optional
+				case CodePoint.QRYROWSNS:
+					checkLength(CodePoint.QRYROWSNS, 1);
+					qryrowsns = readBoolean(CodePoint.QRYROWSNS);
+					if (SanityManager.DEBUG)
+						trace("qryrowsns = "+qryrowsns);
+					gotQryrowsns = true;
+					break;
+				//optional
+				case CodePoint.QRYBLKRST:
+					checkLength(CodePoint.QRYBLKRST, 1);
+					qryblkrst = readBoolean(CodePoint.QRYBLKRST);
+					if (SanityManager.DEBUG)
+						trace("qryblkrst = "+qryblkrst);
+					break;
+				//optional
+				case CodePoint.QRYRTNDTA:
+					qryrtndta = readBoolean(CodePoint.QRYRTNDTA);
+					if (SanityManager.DEBUG)
+						trace("qryrtndta = "+qryrtndta);
+					break;
+				//optional
+				case CodePoint.QRYROWSET:
+					//Note minimum for CNTQRY is 1
+					qryrowset = parseQRYROWSET(1);
+					if (SanityManager.DEBUG)
+						trace("qryrowset = "+qryrowset);
+					break;
+				//optional
+				case CodePoint.QRYRFRTBL:
+					qryrfrtbl = readBoolean(CodePoint.QRYRFRTBL);
+					if (SanityManager.DEBUG)
+						trace("qryrfrtbl = "+qryrfrtbl);
+					break;
+				//optional
+				case CodePoint.NBRROW:
+					checkLength(CodePoint.NBRROW, 4);
+					nbrrow = reader.readNetworkInt();
+					if (SanityManager.DEBUG)
+						trace("nbrrow = "+nbrrow);
+					break;
+				//optional
+				case CodePoint.MAXBLKEXT:
+					checkLength(CodePoint.MAXBLKEXT, 2);
+					maxblkext = reader.readSignedNetworkShort();
+					if (SanityManager.DEBUG)
+						trace("maxblkext = "+maxblkext);
+					break;
+				//optional
+				case CodePoint.RTNEXTDTA:
+					checkLength(CodePoint.RTNEXTDTA, 1);
+					rtnextdta = reader.readUnsignedByte();
+					if (rtnextdta != CodePoint.RTNEXTROW && 
+							rtnextdta != CodePoint.RTNEXTALL)
+						invalidValue(CodePoint.RTNEXTDTA);
+					if (SanityManager.DEBUG)
+						trace("rtnextdta = "+rtnextdta);
+					break;
+				// required for SQLAM >= 7
+				case CodePoint.QRYINSID:
+					checkLength(CodePoint.QRYINSID, 8);
+					qryinsid = reader.readNetworkLong();
+					gotQryinsid = true;
+					if (SanityManager.DEBUG)
+						trace("qryinsid = "+qryinsid);
+					break;
+				// optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+		// check for required variables
+		if (pkgnamcsn == null)
+			missingCodePoint(CodePoint.PKGNAMCSN);
+		if (!gotQryblksz)
+			missingCodePoint(CodePoint.QRYBLKSZ);
+		if (sqlamLevel >= MGRLVL_7 && !gotQryinsid)
+			missingCodePoint(CodePoint.QRYINSID);
+
+		// get the statement we are continuing
+		DRDAStatement stmt = database.getDRDAStatement(pkgnamcsn);
+		if (stmt == null)
+		{
+			//XXX should really throw a SQL Exception here
+			invalidValue(CodePoint.CNTQRY);
+		}
+
+		if (stmt.rsIsClosed())
+		{
+			writeQRYNOPRM(CodePoint.SVRCOD_ERROR);
+			skipRemainder();
+			return null;
+		}
+		stmt.setQueryOptions(blksize,qryrelscr,qryrownbr,qryrfrtbl,nbrrow,maxblkext,
+						 qryscrorn,qryrowsns,qryblkrst,qryrtndta,qryrowset,
+						 rtnextdta);
+
+		if (reader.isChainedWithSameID())
+			parseCNTQRYobjects(stmt);
+		return stmt;
+	}
+	/**
+	 * Skip remainder of current DSS and all chained DSS'es
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void skipRemainder() throws DRDAProtocolException
+	{
+		reader.skipDss();
+		while (reader.isChainedWithSameID())
+		{
+			reader.readDssHeader();
+			reader.skipDss();
+		}
+	}
+	/**
+	 * Parse CNTQRY objects
+	 * Instance Variables
+	 *   OUTOVR - Output Override Descriptor - optional
+	 *
+	 * @param stmt DRDA statement we are working on
+	 * @exception DRDAProtocolException
+	 */
+	private void parseCNTQRYobjects(DRDAStatement stmt) throws DRDAProtocolException, SQLException
+	{
+		int codePoint;
+		do
+		{
+			correlationID = reader.readDssHeader();
+			while (reader.moreDssData())
+			{
+				codePoint = reader.readLengthAndCodePoint();
+				switch(codePoint)
+				{
+					// optional
+					case CodePoint.OUTOVR:
+						parseOUTOVR(stmt);
+						break;
+					default:
+						invalidCodePoint(codePoint);
+				}
+			}
+		} while (reader.isChainedWithSameID());
+
+	}
+	/**
+	 * Parse OUTOVR - Output Override Descriptor
+	 * This specifies the output format for data to be returned as output to a SQL
+	 * statement or as output from a query.
+	 *
+	 * @param stmt	DRDA statement this applies to
+	 * @exception DRDAProtocolException
+	 */
+	private void parseOUTOVR(DRDAStatement stmt) throws DRDAProtocolException, SQLException
+	{
+		boolean first = true;
+		int numVars;
+		int dtaGrpLen;
+		int tripType;
+		int tripId;
+		int precision;
+		int start = 0;
+		while (true)
+		{
+			dtaGrpLen = reader.readUnsignedByte();
+			tripType = reader.readUnsignedByte();
+			tripId = reader.readUnsignedByte();
+			// check if we have reached the end of the data
+			if (tripType == FdocaConstants.RLO_TRIPLET_TYPE)
+			{
+				//read last part of footer
+				reader.skipBytes();
+				break;
+			}
+			numVars = (dtaGrpLen - 3) / 3;
+			if (SanityManager.DEBUG)
+				trace("num of vars is: "+numVars);
+			int[] outovr_drdaType = null;
+			if (first)
+			{
+				outovr_drdaType = new int[numVars];
+				first = false;
+			}
+			else
+			{
+				int[] oldoutovr_drdaType = stmt.getOutovr_drdaType();
+				int oldlen = oldoutovr_drdaType.length;
+				// create new array and copy over already read stuff
+				outovr_drdaType = new int[oldlen + numVars];
+				System.arraycopy(oldoutovr_drdaType, 0,
+								 outovr_drdaType,0,
+								 oldlen);
+				start = oldlen;
+			}
+			for (int i = start; i < numVars + start; i++)
+			{
+				outovr_drdaType[i] = reader.readUnsignedByte();
+				if (SanityManager.DEBUG)
+					trace("drdaType is: "+ outovr_drdaType[i]);
+				precision = reader.readNetworkShort();
+				if (SanityManager.DEBUG)
+					trace("drdaLength is: "+precision);
+				outovr_drdaType[i] |= (precision << 8);
+			}
+			stmt.setOutovr_drdaType(outovr_drdaType);
+		}
+	}
+
+	/**
+	 * Write OPNQRYRM - Open Query Complete
+	 * Instance Variables
+	 *   SVRCOD - Severity Code - required
+	 *   QRYPRCTYP - Query Protocol Type - required
+	 *   SQLCSRHLD - Hold Cursor Position - optional
+	 *   QRYATTSCR - Query Attribute for Scrollability - optional - level 7
+	 *   QRYATTSNS - Query Attribute for Sensitivity - optional - level 7
+	 *   QRYATTUPD - Query Attribute for Updatability -optional - level 7
+	 *   QRYINSID - Query Instance Identifier - required - level 7
+	 *   SRVDGN - Server Diagnostic Information - optional
+	 *
+	 * @param isDssObject - return as a DSS object (part of a reply) 
+	 * @param stmt - DRDA statement we are processing
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void writeOPNQRYRM(boolean isDssObject, DRDAStatement stmt) 
+		throws DRDAProtocolException, SQLException
+	{
+		if (SanityManager.DEBUG)
+			trace("WriteOPNQRYRM");
+
+		if (isDssObject)
+			writer.createDssObject();
+		else
+			writer.createDssReply();
+		writer.startDdm(CodePoint.OPNQRYRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD,CodePoint.SVRCOD_INFO);
+
+		// There is currently a problem specifying LMTBLKPRC for LOBs with JCC
+		// JCC will throw an ArrayOutOfBounds exception.  Once this is fixed, we
+		// don't need to pass the two arguments for getQryprctyp.
+		int prcType = stmt.getQryprctyp();
+		if (SanityManager.DEBUG)
+			trace("sending QRYPRCTYP: " + prcType);
+		writer.writeScalar2Bytes(CodePoint.QRYPRCTYP, prcType);
+
+		//pass the SQLCSRHLD codepoint only if statement has hold cursors over commit set
+		if (stmt.withHoldCursor == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT)
+			writer.writeScalar1Byte(CodePoint.SQLCSRHLD, CodePoint.TRUE);
+		if (sqlamLevel >= MGRLVL_7)
+		{
+			writer.writeScalarHeader(CodePoint.QRYINSID, 8);
+			//This is implementer defined.  DB2 uses this for the nesting level
+			//of the query.  A query from an application would be nesting level 0,
+			//from a stored procedure, nesting level 1, from a recursive call of
+			//a stored procedure, nesting level 2, etc.
+			writer.writeInt(0);     
+			//This is a unique sequence number per session
+			writer.writeInt(session.qryinsid++);
+			//Write the scroll attributes if they are set
+			if (stmt.getScrollType() != 0)
+			{
+				writer.writeScalar1Byte(CodePoint.QRYATTSCR, CodePoint.TRUE);
+				//Cloudscape only supports insensitive scroll cursors
+				writer.writeScalar1Byte(CodePoint.QRYATTSNS, CodePoint.QRYINS);
+				//Cloudscape only supports read only scrollable cursors
+				writer.writeScalar1Byte(CodePoint.QRYATTUPD, CodePoint.QRYRDO);
+			}
+			else
+			{
+				if (stmt.getConcurType() == ResultSet.CONCUR_UPDATABLE)
+					writer.writeScalar1Byte(CodePoint.QRYATTUPD, CodePoint.QRYUPD);
+				else
+					writer.writeScalar1Byte(CodePoint.QRYATTUPD, CodePoint.QRYRDO);
+			}
+
+		}
+		writer.endDdmAndDss ();
+	}
+	/**
+	 * Write ENDQRYRM - query process has terminated in such a manner that the
+	 *	query or result set is now closed.  It cannot be resumed with the CNTQRY
+	 *  command or closed with the CLSQRY command
+	 * @param srvCod  Severity code - WARNING or ERROR
+	 * @exception DRDAProtocolException
+	 */
+	private void writeENDQRYRM(int svrCod) throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.ENDQRYRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD,svrCod);
+		writer.endDdmAndDss();
+	}
+/**
+	 * Write ABNUOWRM - query process has terminated in an error condition
+	 * such as deadlock or lock timeout.
+	 * Severity code is always error
+	 * 	 * @exception DRDAProtocolException
+	 */
+	private void writeABNUOWRM() throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.ABNUOWRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD,CodePoint.SVRCOD_ERROR);
+		writeRDBNAM(database.dbName);
+		writer.endDdmAndDss();
+	}
+	/**
+	 * Parse database name
+	 *
+	 * @return database name
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private String parseRDBNAM() throws DRDAProtocolException
+	{
+		String name;
+		byte [] rdbName = reader.readBytes();
+		if (rdbName.length == 0)
+		{
+			// throw RDBNFNRM
+			rdbNotFound(null);
+		}
+		//SQLAM level 7 allows db name up to 255, level 6 fixed len 18
+		if (rdbName.length < CodePoint.RDBNAM_LEN || rdbName.length > CodePoint.MAX_NAME)
+			badObjectLength(CodePoint.RDBNAM);
+		name = reader.convertBytes(rdbName);
+		// trim trailing blanks from the database name
+		name = name.trim();
+		if (SanityManager.DEBUG)
+			trace("RdbName " + name);
+		return name;
+	}
+	/**
+	 * Write ACCSECRD
+	 * If the security mechanism is known, we just send it back along with
+	 * the security token if encryption is going to be used.
+	 * If the security mechanism is not known, we send a list of the ones
+	 * we know.
+	 * Instance Variables
+	 * 	SECMEC - security mechanism - required
+	 *	SECTKN - security token	- optional (required if security mechanism 
+	 *						uses encryption)
+	 *  SECCHKCD - security check code - error occurred in processing ACCSEC
+	 *
+	 * @param securityCheckCode
+	 * 
+	 * @exception DRDAProtocolException
+	 */
+	private void writeACCSECRD(int securityCheckCode) 
+		throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.ACCSECRD);
+		if (securityCheckCode != CodePoint.SECCHKCD_NOTSUPPORTED)
+			writer.writeScalar2Bytes(CodePoint.SECMEC, database.securityMechanism);
+		else
+		{ 
+			// these are the ones we know about
+			writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_USRIDPWD);
+			writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_EUSRIDPWD);
+		}
+		if (securityCheckCode != 0)
+		{
+			writer.writeScalar1Byte(CodePoint.SECCHKCD, securityCheckCode);
+		}
+		else
+		{
+			// we need to send back the key if encryption is being used
+			if (database.securityMechanism == CodePoint.SECMEC_EUSRIDPWD)
+				writer.writeScalarBytes(CodePoint.SECTKN, myPublicKey);
+		}
+    	writer.endDdmAndDss ();
+
+		/* The chaining status in reader is for the latest request DSS ACCSEC.
+		 * There's a difference between JCC and CCC here.  CCC chains ACCSEC, SECCHK,
+		 * and ACCRDB together, whereas JCC sends ACCSEC separately.  DRDA spec
+		 * requires that if requests are chained, replies must be chained.  When we
+		 * call "send", we terminate the chain.  So can't do it if ACCSEC is chained.
+		 */
+		if (! (reader.isChainedWithSameID() || reader.isChainedWithDiffID()))
+			send();
+	}
+	/**
+	 * Parse security check
+	 * Instance Variables
+	 *	SECMGRNM - security manager name - optional, ignorable
+	 *  SECMEC	- security mechanism - required
+	 *	SECTKN	- security token - optional, (required if encryption used)
+	 *	PASSWORD - password - optional, (required if security mechanism uses it)
+	 *	NEWPASSWORD - new password - optional, (required if sec mech. uses it)
+	 *	USRID	- user id - optional, (required if sec mec. uses it)
+	 *	RDBNAM	- database name - optional (required if databases can have own sec.)
+	 *
+	 * 
+	 * @return security check code
+	 * @exception DRDAProtocolException
+	 */
+	private int parseSECCHK() throws DRDAProtocolException
+	{
+		int codePoint, securityCheckCode = 0;
+		int securityMechanism = 0;
+		databaseAccessException = null;
+		reader.markCollection();
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				//optional, ignorable
+				case CodePoint.SECMGRNM:
+					reader.skipBytes();
+					break;
+				//required
+				case CodePoint.SECMEC:
+					checkLength(CodePoint.SECMEC, 2);
+					securityMechanism = reader.readNetworkShort();
+					if (SanityManager.DEBUG) 
+						trace("Security mechanism = " + securityMechanism);
+					//RESOLVE - spec is not clear on what should happen
+					//in this case
+					if (securityMechanism != database.securityMechanism)
+						invalidValue(CodePoint.SECMEC);
+					break;
+				//optional - depending on security Mechanism 
+				case CodePoint.SECTKN:
+					if (database.securityMechanism != CodePoint.SECMEC_EUSRIDPWD)
+					{
+						securityCheckCode = CodePoint.SECCHKCD_SECTKNMISSING;
+						reader.skipBytes();
+					}
+					else if (database.decryptedUserId == null) {
+						try {
+							database.decryptedUserId = reader.readEncryptedString(decryptionManager,
+												database.securityMechanism, myPublicKey, database.publicKeyIn);
+						} catch (SQLException se)
+						{
+							println2Log(database.dbName, session.drdaID, se.getMessage());
+							if (securityCheckCode == 0)
+								securityCheckCode = CodePoint.SECCHKCD_13;	//userid invalid
+						}
+						database.userId = database.decryptedUserId;
+						if (SanityManager.DEBUG) trace("**decrypted userid is: "+database.userId);
+					}
+					else if (database.decryptedPassword == null) {
+						try {
+							database.decryptedPassword = reader.readEncryptedString(decryptionManager,
+												database.securityMechanism, myPublicKey, database.publicKeyIn);
+						} catch (SQLException se)
+						{	
+							println2Log(database.dbName, session.drdaID, se.getMessage());
+							if (securityCheckCode == 0)
+								securityCheckCode = CodePoint.SECCHKCD_0F;	//password invalid
+						}
+						database.password = database.decryptedPassword;
+						if (SanityManager.DEBUG) trace("**decrypted password is: "+database.password);
+					}
+					else
+					{
+						tooMany(CodePoint.SECTKN);
+					}
+					break;
+				//optional - depending on security Mechanism
+				case CodePoint.PASSWORD:
+					database.password = reader.readString();
+					if (SanityManager.DEBUG) trace("PASSWORD " + database.password);
+					break;
+				//optional - depending on security Mechanism
+				//we are not supporting this method so we'll skip bytes
+				case CodePoint.NEWPASSWORD:
+					reader.skipBytes();
+					break;
+				//optional - depending on security Mechanism
+				case CodePoint.USRID:
+					database.userId = reader.readString();
+					if (SanityManager.DEBUG) trace("USERID " + database.userId);
+					break;
+				//optional - depending on security Mechanism
+				case CodePoint.RDBNAM:
+					String dbname = parseRDBNAM();
+					if (database != null) 
+					{
+						if (!database.dbName.equals(dbname))
+							rdbnamMismatch(CodePoint.SECCHK);
+					}
+					else
+					{
+						// we should already have added the database in ACCSEC
+						// added code here in case we make the SECMEC session rather
+						// than database wide
+						addDatabase(dbname);
+					}
+					break;
+				default:
+					invalidCodePoint(codePoint);
+
+			}
+			codePoint = reader.getCodePoint();
+		}
+		// check for SECMEC which is required
+		if (securityMechanism == 0)
+			missingCodePoint(CodePoint.SECMEC);
+
+		//check if we have a userid and password when we need it
+		if (securityCheckCode == 0 && 
+				database.securityMechanism == CodePoint.SECMEC_USRIDPWD)
+		{
+			if (database.userId == null)
+				securityCheckCode = CodePoint.SECCHKCD_USERIDMISSING;
+			else if (database.password == null)
+				securityCheckCode = CodePoint.SECCHKCD_PASSWORDMISSING;
+			//Note, we'll ignore encryptedUserId and encryptedPassword if they
+			//are also set
+		}
+		if (securityCheckCode == 0 && 
+				database.securityMechanism == CodePoint.SECMEC_EUSRIDPWD)
+		{
+			if (database.decryptedUserId == null)
+				securityCheckCode = CodePoint.SECCHKCD_USERIDMISSING;
+			else if (database.decryptedPassword == null)
+				securityCheckCode = CodePoint.SECCHKCD_PASSWORDMISSING;
+
+		}
+		// RESOLVE - when we do security we need to decrypt encrypted userid & password
+		// before proceeding
+
+		// verify userid and password, if we haven't had any errors thus far.
+		if ((securityCheckCode == 0) && (databaseAccessException == null))
+		{
+			securityCheckCode = verifyUserIdPassword();
+		}
+		return securityCheckCode;
+
+	}
+	/**
+	 * Write security check reply
+	 * Instance variables
+	 * 	SVRCOD - serverity code - required
+	 *	SECCHKCD	- security check code  - required
+	 *	SECTKN - security token - optional, ignorable
+	 *	SVCERRNO	- security service error number
+	 *	SRVDGN	- Server Diagnostic Information
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void writeSECCHKRM(int securityCheckCode) throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.SECCHKRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, svrcodFromSecchkcd(securityCheckCode));
+		writer.writeScalar1Byte(CodePoint.SECCHKCD, securityCheckCode);
+
+    	writer.endDdmAndDss ();
+	}
+	/**
+	 * Calculate SVRCOD value from SECCHKCD
+	 *
+	 * @param securityCheckCode
+	 * @return SVRCOD value
+	 */
+	private int svrcodFromSecchkcd(int securityCheckCode)
+	{
+		if (securityCheckCode == 0 || securityCheckCode == 2 ||
+			securityCheckCode == 5 || securityCheckCode == 8)
+			return CodePoint.SVRCOD_INFO;
+		else
+			return CodePoint.SVRCOD_ERROR;
+	}
+	/**
+	 * Parse access RDB
+	 * Instance variables
+	 *	RDBACCCL - RDB Access Manager Class - required must be SQLAM
+	 *  CRRTKN - Correlation Token - required
+	 *  RDBNAM - Relational database name -required
+	 *  PRDID - Product specific identifier - required
+	 *  TYPDEFNAM	- Data Type Definition Name -required
+	 *  TYPDEFOVR	- Type definition overrides -required
+	 *  RDBALWUPD -  RDB Allow Updates optional
+	 *  PRDDTA - Product Specific Data - optional - ignorable
+	 *  STTDECDEL - Statement Decimal Delimiter - optional
+	 *  STTSTRDEL - Statement String Delimiter - optional
+	 *  TRGDFTRT - Target Default Value Return - optional
+	 *
+	 * @return severity code
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private int parseACCRDB() throws  DRDAProtocolException
+	{
+		int codePoint;
+		int svrcod = 0;
+		copyToRequired(ACCRDB_REQUIRED);
+		reader.markCollection();
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				//required
+				case CodePoint.RDBACCCL:
+					checkLength(CodePoint.RDBACCCL, 2);
+					int sqlam = reader.readNetworkShort();
+					if (SanityManager.DEBUG) 
+						trace("RDBACCCL = " + sqlam);
+					// required to be SQLAM 
+
+					if (sqlam != CodePoint.SQLAM)
+						invalidValue(CodePoint.RDBACCCL);
+					removeFromRequired(CodePoint.RDBACCCL);
+					break;
+				//required
+				case CodePoint.CRRTKN:
+					database.crrtkn = reader.readBytes();
+					if (SanityManager.DEBUG) 
+						trace("crrtkn " + convertToHexString(database.crrtkn));
+					removeFromRequired(CodePoint.CRRTKN);
+					int l = database.crrtkn.length;
+					if (l > CodePoint.MAX_NAME)
+						tooBig(CodePoint.CRRTKN);
+					// the format of the CRRTKN is defined in the DRDA reference
+					// x.yz where x is 1 to 8 bytes (variable)
+					// 		y is 1 to 8 bytes (variable)
+					//		x is 6 bytes fixed
+					//		size is variable between 9 and 23
+					if (l < 9 || l > 23)
+						invalidValue(CodePoint.CRRTKN);
+					byte[] part1 = new byte[l - 6];
+					for (int i = 0; i < part1.length; i++)
+						part1[i] = database.crrtkn[i];
+					long time = SignedBinary.getLong(database.crrtkn, 
+							l-8, SignedBinary.BIG_ENDIAN); // as "long" as unique
+					session.drdaID = reader.convertBytes(part1) + 
+									time + leftBrace + session.connNum + rightBrace;
+					if (SanityManager.DEBUG) 
+						trace("******************************************drdaID is: " + session.drdaID);
+					EmbedConnection conn = (EmbedConnection)(database.getConnection());
+					if (conn != null)
+						conn.setDrdaID(session.drdaID);
+					break;
+				//required
+				case CodePoint.RDBNAM:
+					String dbname = parseRDBNAM();
+					if (database != null)
+					{ 
+						if (!database.dbName.equals(dbname))
+							rdbnamMismatch(CodePoint.ACCRDB);
+					}
+					else
+					{
+						//first time we have seen a database name
+						Database d = session.getDatabase(dbname);
+						if (d == null)
+							addDatabase(dbname);
+						else
+						{
+							database = d;
+							database.accessCount++;
+						}
+					}
+					removeFromRequired(CodePoint.RDBNAM);
+					break;
+				//required
+				case CodePoint.PRDID:
+					appRequester.setClientVersion(reader.readString());
+					if (SanityManager.DEBUG) 
+						trace("prdId " + appRequester.prdid);
+					if (appRequester.prdid.length() > CodePoint.PRDID_MAX)
+						tooBig(CodePoint.PRDID);
+
+					/* If JCC version is 1.5 or later, send SQLWarning on CNTQRY */
+					if ((appRequester.getClientType() == appRequester.JCC_CLIENT) &&
+						(appRequester.greaterThanOrEqualTo(1, 5, 0)))
+					{
+						sendWarningsOnCNTQRY = true;
+					}
+					else sendWarningsOnCNTQRY = false;
+
+					removeFromRequired(CodePoint.PRDID);
+					break;
+				//required
+				case CodePoint.TYPDEFNAM:
+					setStmtOrDbByteOrder(true, null, parseTYPDEFNAM());
+					removeFromRequired(CodePoint.TYPDEFNAM);
+					break;
+				//required
+				case CodePoint.TYPDEFOVR:
+					parseTYPDEFOVR(null);
+					removeFromRequired(CodePoint.TYPDEFOVR);
+					break;
+				//optional 
+				case CodePoint.RDBALWUPD:
+					checkLength(CodePoint.RDBALWUPD, 1);
+					database.rdbAllowUpdates = readBoolean(CodePoint.RDBALWUPD);
+					if (SanityManager.DEBUG) 
+						trace("rdbAllowUpdates = "+database.rdbAllowUpdates);
+					break;
+				//optional, ignorable
+				case CodePoint.PRDDTA:
+					// check that it fits in maximum but otherwise ignore for now
+					if (reader.getDdmLength() > CodePoint.MAX_NAME)
+						tooBig(CodePoint.PRDDTA);
+					reader.skipBytes();
+					break;
+				case CodePoint.TRGDFTRT:
+					byte b = reader.readByte();
+					if (b == 0xF1)
+						database.sendTRGDFTRT = true;
+					break;
+				//optional - not used in JCC so skip for now
+				case CodePoint.STTDECDEL:
+				case CodePoint.STTSTRDEL:
+					codePointNotSupported(codePoint);
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+		checkRequired(CodePoint.ACCRDB);
+		// check that we can support the double-byte and mixed-byte CCSIDS
+		// set svrcod to warning if they are not supported
+		if ((database.ccsidDBC != 0 && !server.supportsCCSID(database.ccsidDBC)) ||
+				(database.ccsidMBC != 0 && !server.supportsCCSID(database.ccsidMBC))) 
+			svrcod = CodePoint.SVRCOD_WARNING;
+		return svrcod;
+	}
+	/**
+	 * Parse TYPDEFNAM
+	 *
+	 * @return typdefnam
+	 * @exception DRDAProtocolException
+	 */
+	private String parseTYPDEFNAM() throws DRDAProtocolException
+	{
+		String typDefNam = reader.readString();
+		if (SanityManager.DEBUG) trace("typeDefName " + typDefNam);
+		if (typDefNam.length() > CodePoint.MAX_NAME)
+			tooBig(CodePoint.TYPDEFNAM);
+		checkValidTypDefNam(typDefNam);
+		// check if the typedef is one we support
+		if (!typDefNam.equals(CodePoint.TYPDEFNAM_QTDSQLASC)  &&
+			!typDefNam.equals(CodePoint.TYPDEFNAM_QTDSQLJVM) &&
+			!typDefNam.equals(CodePoint.TYPDEFNAM_QTDSQLX86))
+			valueNotSupported(CodePoint.TYPDEFNAM);
+		return typDefNam;
+	}
+
+	/**
+	 * Set a statement or the database' byte order, depending on the arguments
+	 *
+	 * @param setDatabase   if true, set database' byte order, otherwise set statement's
+	 * @param stmt          DRDAStatement, used when setDatabase is false
+	 * @param typDefNam     TYPDEFNAM value
+	 */
+	private void setStmtOrDbByteOrder(boolean setDatabase, DRDAStatement stmt, String typDefNam)
+	{
+		int byteOrder = (typDefNam.equals(CodePoint.TYPDEFNAM_QTDSQLX86) ?
+							SignedBinary.LITTLE_ENDIAN : SignedBinary.BIG_ENDIAN);
+		if (setDatabase)
+		{
+			database.typDefNam = typDefNam;
+			database.byteOrder = byteOrder;
+		}
+		else
+		{
+			stmt.typDefNam = typDefNam;
+			stmt.byteOrder = byteOrder;
+		}
+	}
+
+	/**
+	 * Write Access to RDB Completed
+	 * Instance Variables
+	 *  SVRCOD - severity code - 0 info, 4 warning -required
+	 *  PRDID - product specific identifier -required
+	 *  TYPDEFNAM - type definition name -required
+	 *  TYPDEFOVR - type definition overrides - required
+	 *  RDBINTTKN - token which can be used to interrupt DDM commands - optional
+	 *  CRRTKN	- correlation token - only returned if we didn't get one from requester
+	 *  SRVDGN - server diagnostic information - optional
+	 *  PKGDFTCST - package default character subtype - optional
+	 *  USRID - User ID at the target system - optional
+	 *  SRVLST - Server List
+	 * 
+	 * @exception DRDAProtocolException
+	 */
+	private void writeACCRDBRM(int svrcod) throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.ACCRDBRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, svrcod);
+		writer.writeScalarString(CodePoint.PRDID, server.prdId);
+		//TYPDEFNAM -required - JCC doesn't support QTDSQLJVM so for now we
+		// just use ASCII, though we should eventually be able to use QTDSQLJVM
+		// at level 7
+		writer.writeScalarString(CodePoint.TYPDEFNAM,
+								 CodePoint.TYPDEFNAM_QTDSQLASC);
+		writeTYPDEFOVR();
+		writer.endDdmAndDss ();
+		send();
+	}
+	
+	private void writeTYPDEFOVR() throws DRDAProtocolException
+	{
+		//TYPDEFOVR - required - only single byte and mixed byte are specified
+		writer.startDdm(CodePoint.TYPDEFOVR);
+		writer.writeScalar2Bytes(CodePoint.CCSIDSBC, server.CCSIDSBC);
+		writer.writeScalar2Bytes(CodePoint.CCSIDMBC, server.CCSIDMBC);
+		// PKGDFTCST - Send character subtype and userid if requested
+		if (database.sendTRGDFTRT)
+		{
+			// default to multibyte character
+			writer.startDdm(CodePoint.PKGDFTCST);
+			writer.writeShort(CodePoint.CSTMBCS);
+			writer.endDdm();
+			// userid
+			writer.startDdm(CodePoint.USRID);
+			writer.writeString(database.userId);
+			writer.endDdm();
+		}
+		writer.endDdm();
+
+	}
+	
+	/**
+	 * Parse Type Defintion Overrides
+	 * 	TYPDEF Overrides specifies the Coded Character SET Identifiers (CCSIDs)
+	 *  that are in a named TYPDEF.
+	 * Instance Variables
+	 *  CCSIDSBC - CCSID for Single-Byte - optional
+	 *  CCSIDDBC - CCSID for Double-Byte - optional
+	 *  CCSIDMBC - CCSID for Mixed-byte characters -optional
+	 *
+ 	 * @param st	Statement this TYPDEFOVR applies to
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void parseTYPDEFOVR(DRDAStatement st) throws  DRDAProtocolException
+	{
+		int codePoint;
+		int ccsidSBC = 0;
+		int ccsidDBC = 0;
+		int ccsidMBC = 0;
+		String ccsidSBCEncoding = null;
+		String ccsidDBCEncoding = null;
+		String ccsidMBCEncoding = null;
+
+		reader.markCollection();
+
+		codePoint = reader.getCodePoint();
+		// at least one of the following instance variable is required
+		// if the TYPDEFOVR is specified in a command object
+		if (codePoint == -1 && st != null)
+			missingCodePoint(CodePoint.CCSIDSBC);
+
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				case CodePoint.CCSIDSBC:
+					checkLength(CodePoint.CCSIDSBC, 2);
+					ccsidSBC = reader.readNetworkShort();
+					try {
+						ccsidSBCEncoding = 
+							CharacterEncodings.getJavaEncoding(ccsidSBC);
+					} catch (Exception e) {
+						valueNotSupported(CodePoint.CCSIDSBC);
+					}
+					if (SanityManager.DEBUG) 
+						trace("ccsidsbc = " + ccsidSBC + " encoding = " + ccsidSBCEncoding);
+					break;
+				case CodePoint.CCSIDDBC:
+					checkLength(CodePoint.CCSIDDBC, 2);
+					ccsidDBC = reader.readNetworkShort();
+					try {
+						ccsidDBCEncoding = 
+							CharacterEncodings.getJavaEncoding(ccsidDBC);
+					} catch (Exception e) {
+						// we write a warning later for this so no error
+						// unless for a statement
+						ccsidDBCEncoding = null;
+						if (st != null)
+							valueNotSupported(CodePoint.CCSIDSBC);
+					}
+					if (SanityManager.DEBUG) 
+						trace("ccsiddbc = " + ccsidDBC + " encoding = " + ccsidDBCEncoding);
+					break;
+				case CodePoint.CCSIDMBC:
+					checkLength(CodePoint.CCSIDMBC, 2);
+					ccsidMBC = reader.readNetworkShort();
+					try {
+						ccsidMBCEncoding = 
+							CharacterEncodings.getJavaEncoding(ccsidMBC);
+					} catch (Exception e) {
+						// we write a warning later for this so no error
+						ccsidMBCEncoding = null;
+						if (st != null)
+							valueNotSupported(CodePoint.CCSIDMBC);
+					}
+					if (SanityManager.DEBUG) 
+						trace("ccsidmbc = " + ccsidMBC + " encoding = " + ccsidMBCEncoding);
+					break;
+				default:
+					invalidCodePoint(codePoint);
+
+			}
+			codePoint = reader.getCodePoint();
+		}
+		if (st == null)
+		{
+			if (ccsidSBC != 0)
+			{
+				database.ccsidSBC = ccsidSBC;
+				database.ccsidSBCEncoding = ccsidSBCEncoding;
+			}
+			if (ccsidDBC != 0)
+			{
+				database.ccsidDBC = ccsidDBC;
+				database.ccsidDBCEncoding = ccsidDBCEncoding;
+			}
+			if (ccsidMBC != 0)
+			{
+				database.ccsidMBC = ccsidMBC;
+				database.ccsidMBCEncoding = ccsidMBCEncoding;
+			}
+		}
+		else
+		{
+			if (ccsidSBC != 0)
+			{
+				st.ccsidSBC = ccsidSBC;
+				st.ccsidSBCEncoding = ccsidSBCEncoding;
+			}
+			if (ccsidDBC != 0)
+			{
+				st.ccsidDBC = ccsidDBC;
+				st.ccsidDBCEncoding = ccsidDBCEncoding;
+			}
+			if (ccsidMBC != 0)
+			{
+				st.ccsidMBC = ccsidMBC;
+				st.ccsidMBCEncoding = ccsidMBCEncoding;
+			}
+		}
+	}
+	/**
+	 * Parse PRPSQLSTT - Prepare SQL Statement
+	 * Instance Variables
+	 *   RDBNAM - Relational Database Name - optional
+	 *   PKGNAMCAN - RDB Package Name, Consistency Token, and Section Number - required
+	 *   RTNSQLDA - Return SQL Descriptor Area - optional
+	 *   MONITOR - Monitor events - optional.
+	 *   
+	 * @return return 0 - don't return sqlda, 1 - return input sqlda, 
+	 * 		2 - return output sqlda
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private int parsePRPSQLSTT() throws DRDAProtocolException,SQLException
+	{
+		int codePoint;
+		boolean rtnsqlda = false;
+		boolean rtnOutput = true; 	// Return output SQLDA is default
+		String typdefnam;
+		String pkgnamcsn = null;
+
+		DRDAStatement stmt = null;  
+		Database databaseToSet = null;
+
+		reader.markCollection();
+
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.PRPSQLSTT);
+					databaseToSet = database;
+					break;
+				// required
+				case CodePoint.PKGNAMCSN:
+					pkgnamcsn = parsePKGNAMCSN(); 
+					break;
+				//optional
+				case CodePoint.RTNSQLDA:
+				// Return SQLDA with description of statement
+					rtnsqlda = readBoolean(CodePoint.RTNSQLDA);
+					break;
+				//optional
+				case CodePoint.TYPSQLDA:
+					rtnOutput = parseTYPSQLDA();
+					break;
+				//optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+
+			}
+			codePoint = reader.getCodePoint();
+		}
+
+		stmt = database.newDRDAStatement(pkgnamcsn);
+		String sqlStmt = parsePRPSQLSTTobjects(stmt);
+		if (databaseToSet != null)
+			stmt.setDatabase(database);
+		stmt.explicitPrepare(sqlStmt);
+		// set the statement as the current statement
+		database.setCurrentStatement(stmt);
+
+		if (!rtnsqlda)
+			return 0;
+		else if (rtnOutput)   
+			return 2;
+		else
+			return 1;
+	}
+	/**
+	 * Parse PRPSQLSTT objects
+	 * Objects
+	 *  TYPDEFNAM - Data type definition name - optional
+	 *  TYPDEFOVR - Type defintion overrides - optional
+	 *  SQLSTT - SQL Statement required
+	 *  SQLATTR - Cursor attributes on prepare - optional - level 7
+	 *
+	 * If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects
+	 * sent with the statement.  Once the statement is over, the default values
+	 * sent in the ACCRDB are once again in effect.  If no values are supplied,
+	 * the values sent in the ACCRDB are used.
+	 * Objects may follow in one DSS or in several DSS chained together.
+	 * 
+	 * @return SQL statement
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private String parsePRPSQLSTTobjects(DRDAStatement stmt) 
+		throws DRDAProtocolException, SQLException
+	{
+		String sqlStmt = null;
+		int codePoint;
+		do
+		{
+			correlationID = reader.readDssHeader();
+			while (reader.moreDssData())
+			{
+				codePoint = reader.readLengthAndCodePoint();
+				switch(codePoint)
+				{
+					// required
+					case CodePoint.SQLSTT:
+						sqlStmt = parseEncodedString();
+						if (SanityManager.DEBUG) 
+							trace("sqlStmt = " + sqlStmt);
+						break;
+					// optional
+					case CodePoint.TYPDEFNAM:
+						setStmtOrDbByteOrder(false, stmt, parseTYPDEFNAM());
+						break;
+					// optional
+					case CodePoint.TYPDEFOVR:
+						parseTYPDEFOVR(stmt);
+						break;
+					// optional
+					case CodePoint.SQLATTR:
+						parseSQLATTR(stmt);
+						break;
+					default:
+						invalidCodePoint(codePoint);
+				}
+			}
+		} while (reader.isChainedWithSameID());
+		if (sqlStmt == null)
+			missingCodePoint(CodePoint.SQLSTT);
+
+		return sqlStmt;
+	}
+
+	/**
+	 * Parse TYPSQLDA - Type of the SQL Descriptor Area
+	 *
+	 * @return true if for output; false otherwise
+	 * @exception DRDAProtocolException
+	 */
+	private boolean parseTYPSQLDA() throws DRDAProtocolException
+	{
+		checkLength(CodePoint.TYPSQLDA, 1);
+		byte sqldaType = reader.readByte();
+		if (SanityManager.DEBUG) 
+			trace("typSQLDa " + sqldaType);
+		if (sqldaType == CodePoint.TYPSQLDA_STD_OUTPUT ||
+				sqldaType == CodePoint.TYPSQLDA_LIGHT_OUTPUT ||
+				sqldaType == CodePoint.TYPSQLDA_X_OUTPUT)
+			return true;
+		else if (sqldaType == CodePoint.TYPSQLDA_STD_INPUT ||
+					 sqldaType == CodePoint.TYPSQLDA_LIGHT_INPUT ||
+					 sqldaType == CodePoint.TYPSQLDA_X_INPUT)
+				return false;
+		else
+			invalidValue(CodePoint.TYPSQLDA);
+
+		// shouldn't get here but have to shut up compiler
+		return false;
+	}
+	/**
+	 * Parse SQLATTR - Cursor attributes on prepare
+	 *   This is an encoded string. Can have combination of following, eg INSENSITIVE SCROLL WITH HOLD
+	 * Possible strings are
+	 *  SENSITIVE DYNAMIC SCROLL [FOR UPDATE]
+	 *  SENSITIVE STATIC SCROLL [FOR UPDATE]
+	 *  INSENSITIVE SCROLL
+	 *  FOR UPDATE
+	 *  WITH HOLD
+	 *
+	 * @param stmt DRDAStatement
+	 * @exception DRDAProtocolException
+	 */
+	protected void parseSQLATTR(DRDAStatement stmt) throws DRDAProtocolException
+	{
+		String attrs = parseEncodedString();
+		if (SanityManager.DEBUG)
+			trace("sqlattr = '" + attrs+"'");
+		//let Cloudscape handle any errors in the types it doesn't support
+		//just set the attributes
+
+		boolean insensitive = false;
+		boolean validAttribute = false;
+		if (attrs.indexOf("INSENSITIVE SCROLL") != -1 || attrs.indexOf("SCROLL INSENSITIVE") != -1) //CLI
+		{
+			stmt.scrollType = ResultSet.TYPE_SCROLL_INSENSITIVE;
+			stmt.concurType = ResultSet.CONCUR_READ_ONLY;
+			insensitive = true;
+			validAttribute = true;
+		}
+		if ((attrs.indexOf("SENSITIVE DYNAMIC SCROLL") != -1) || (attrs.indexOf("SENSITIVE STATIC SCROLL") != -1))
+		{
+			stmt.scrollType = ResultSet.TYPE_SCROLL_SENSITIVE;
+			validAttribute = true;
+		}
+
+		if ((attrs.indexOf("FOR UPDATE") != -1))
+		{
+			validAttribute = true;
+			if (!insensitive)
+			stmt.concurType = ResultSet.CONCUR_UPDATABLE;
+		}
+
+		if (attrs.indexOf("WITH HOLD") != -1)
+		{
+			stmt.withHoldCursor = JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
+			validAttribute = true;
+		}
+
+		if (!validAttribute)
+		{
+			invalidValue(CodePoint.SQLATTR);
+		}
+	}
+
+	/**
+	 * Parse DSCSQLSTT - Describe SQL Statement previously prepared
+	 * Instance Variables
+	 *	TYPSQLDA - sqlda type expected (output or input)
+	 *  RDBNAM - relational database name - optional
+	 *  PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required
+	 *  MONITOR - Monitor events - optional.
+	 *
+	 * @return expect "output sqlda" or not
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private boolean parseDSCSQLSTT() throws DRDAProtocolException,SQLException
+	{
+		int codePoint;
+		boolean rtnOutput = true;	// default
+		String pkgnamcsn = null;
+		reader.markCollection();
+
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.TYPSQLDA:
+					rtnOutput = parseTYPSQLDA();
+					break;
+				// optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.DSCSQLSTT);
+					break;
+				// required
+				case CodePoint.PKGNAMCSN:
+					pkgnamcsn = parsePKGNAMCSN();
+					DRDAStatement stmt = database.getDRDAStatement(pkgnamcsn);     
+					if (stmt == null)
+					{
+						invalidValue(CodePoint.PKGNAMCSN);
+					}
+					break;
+				//optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+		if (pkgnamcsn == null)
+			missingCodePoint(CodePoint.PKGNAMCSN);
+		return rtnOutput;
+	}
+
+	/**
+	 * Parse EXCSQLSTT - Execute non-cursor SQL Statement previously prepared
+	 * Instance Variables
+	 *  RDBNAM - relational database name - optional
+	 *  PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required
+	 *  OUTEXP - Output expected
+	 *  NBRROW - Number of rows to be inserted if it's an insert
+	 *  PRCNAM - procedure name if specified by host variable, not needed for Cloudscape
+	 *  QRYBLKSZ - query block size
+	 *  MAXRSLCNT - max resultset count
+	 *  MAXBLKEXT - Max number of extra blocks
+	 *  RSLSETFLG - resultset flag
+	 *  RDBCMTOK - RDB Commit Allowed - optional
+	 *  OUTOVROPT - output override option
+	 *  QRYROWSET - Query Rowset Size - Level 7
+	 *  MONITOR - Monitor events - optional.
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void parseEXCSQLSTT() throws DRDAProtocolException,SQLException
+	{
+		int codePoint;
+		String strVal;
+		reader.markCollection();
+
+		codePoint = reader.getCodePoint();
+		boolean outputExpected = false;
+		String pkgnamcsn = null;
+		int numRows = 1;	// default value
+		int blkSize =  0;
+ 		int maxrslcnt = 0; 	// default value
+		int maxblkext = CodePoint.MAXBLKEXT_DEFAULT;
+		int qryrowset = CodePoint.QRYROWSET_DEFAULT;
+		int outovropt = CodePoint.OUTOVRFRS;
+		byte [] rslsetflg = null;
+		String procName = null;
+
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.EXCSQLSTT);
+					break;
+				// required
+				case CodePoint.PKGNAMCSN:
+					pkgnamcsn = parsePKGNAMCSN();
+					break;
+				// optional
+				case CodePoint.OUTEXP:
+					outputExpected = readBoolean(CodePoint.OUTEXP);
+					if (SanityManager.DEBUG) 
+						trace("outexp = "+ outputExpected);
+					break;
+				// optional
+				case CodePoint.NBRROW:
+					checkLength(CodePoint.NBRROW, 4);
+					numRows = reader.readNetworkInt();
+					if (SanityManager.DEBUG) 
+						trace("# of rows: "+numRows);
+					break;
+				// optional
+				case CodePoint.PRCNAM:
+					procName = reader.readString();
+					if (SanityManager.DEBUG) 
+						trace("Procedure Name = " + procName);
+					break;
+				// optional
+				case CodePoint.QRYBLKSZ:
+					blkSize = parseQRYBLKSZ();
+					break;
+				// optional
+				case CodePoint.MAXRSLCNT:
+					// this is the maximum result set count
+					// values are 0 - requester is not capabable of receiving result
+					// sets as reply data in the response to EXCSQLSTT
+					// -1 - requester is able to receive all result sets
+					checkLength(CodePoint.MAXRSLCNT, 2);
+					maxrslcnt = reader.readNetworkShort();
+					if (SanityManager.DEBUG) 
+						trace("max rs count: "+maxrslcnt);
+					break;
+				// optional
+				case CodePoint.MAXBLKEXT:
+					// number of extra qury blocks of answer set data per result set
+					// 0 - no extra query blocks
+					// -1 - can receive entire result set
+					checkLength(CodePoint.MAXBLKEXT, 2);
+					maxblkext = reader.readNetworkShort();
+					if (SanityManager.DEBUG) 
+						trace("max extra blocks: "+maxblkext);
+					break;
+				// optional
+				case CodePoint.RSLSETFLG:
+					//Result set flags
+					rslsetflg = reader.readBytes();
+					for (int i=0;i<rslsetflg.length;i++)
+						if (SanityManager.DEBUG) 
+							trace("rslsetflg: "+rslsetflg[i]);
+					break;
+				// optional
+				case CodePoint.RDBCMTOK:
+					parseRDBCMTOK();
+					break;
+				// optional
+				case CodePoint.OUTOVROPT:
+					outovropt = parseOUTOVROPT();
+					break;
+				// optional
+				case CodePoint.QRYROWSET:
+					//Note minimum for OPNQRY is 0, we'll assume it is the same
+					//for EXCSQLSTT though the standard doesn't say
+					qryrowset = parseQRYROWSET(0);
+					break;
+				//optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+
+		if (pkgnamcsn == null)
+			missingCodePoint(CodePoint.PKGNAMCSN);
+
+		DRDAStatement stmt;
+		boolean needPrepareCall = false;
+
+		stmt  = database.getDRDAStatement(pkgnamcsn);
+		boolean isProcedure = (procName !=null || 
+							   (stmt != null && 
+								stmt.wasExplicitlyPrepared() &&
+								stmt.isCall));
+
+		if (isProcedure)		// stored procedure call
+		{
+			if ( stmt == null  || !(stmt.wasExplicitlyPrepared()))
+			{ 				
+				stmt  = database.newDRDAStatement(pkgnamcsn);
+				stmt.setQryprctyp(CodePoint.QRYBLKCTL_DEFAULT);				
+				needPrepareCall = true;
+			}
+				
+			stmt.procName = procName;
+			stmt.outputExpected = outputExpected;
+		}
+		else
+		{
+			// we can't find the statement
+			if (stmt == null)
+			{
+				invalidValue(CodePoint.PKGNAMCSN);
+			}
+			stmt.setQryprctyp(CodePoint.QRYBLKCTL_DEFAULT);
+		}
+
+ 		stmt.nbrrow = numRows;
+ 		stmt.qryrowset = qryrowset;
+ 		stmt.blksize = blkSize;
+ 		stmt.maxblkext = maxblkext;
+ 		stmt.maxrslcnt = maxrslcnt;
+ 		stmt.outovropt = outovropt;
+ 		stmt.rslsetflg = rslsetflg;
+ 
+	
+		// set the statement as the current statement
+		database.setCurrentStatement(stmt);
+		
+		
+		if (reader.isChainedWithSameID())
+			parseEXCSQLSTTobjects(stmt);
+		else if (isProcedure  && (needPrepareCall))
+		{
+			// if we had parameters the callable statement would
+			// be prepared with parseEXCQLSTTobjects, otherwise we
+			// have to do it here
+			String prepareString = "call " + stmt.procName +"()";
+			if (SanityManager.DEBUG) 
+				trace ("$$$prepareCall is: "+prepareString);
+			database.getConnection().clearWarnings();
+			CallableStatement cs = (CallableStatement) stmt.prepare(prepareString);
+		}
+		
+		stmt.ps.clearWarnings();
+
+		boolean hasResultSet = stmt.execute();
+		ResultSet rs = null;
+		if (hasResultSet)
+		{
+			rs = stmt.getResultSet();
+		}
+		// temp until ps.execute() return value fixed
+		hasResultSet = (rs != null);
+		int numResults = 0;
+		if (hasResultSet)
+		{
+			numResults = stmt.getNumResultSets();
+			writeRSLSETRM(stmt);
+		}
+
+		// First of all, we send if there really are output params. Otherwise
+		// CLI (.Net driver) fails. DRDA spec (page 151,152) says send SQLDTARD
+		// if server has output param data to send.
+		boolean sendSQLDTARD = stmt.hasOutputParams() && outputExpected;
+		if (isProcedure)
+		{
+			if (sendSQLDTARD) {
+				writer.createDssObject();
+				writer.startDdm(CodePoint.SQLDTARD);
+				writer.startDdm(CodePoint.FDODSC);
+				writeQRYDSC(stmt, true);
+				writer.endDdm();
+				writer.startDdm(CodePoint.FDODTA);
+				writeFDODTA(stmt);
+				writer.endDdm();
+				writer.endDdmAndDss();
+			}
+			else if (hasResultSet)
+			// DRDA spec says that we MUST return either an
+			// SQLDTARD or an SQLCARD--the former when we have
+			// output parameters, the latter when we don't.
+			// If we have a result set, then we have to write
+			// the SQLCARD _now_, since it is expected before
+			// we send the result set info below; if we don't
+			// have a result set and we don't send SQLDTARD,
+			// then we can wait until we reach the call to
+			// checkWarning() below, which will write an
+			// SQLCARD for us.
+				writeNullSQLCARDobject();
+		}
+		
+		//We need to marke that params are finished so that we know we 
+		// are ready to send resultset info.
+		stmt.finishParams();
+			
+		PreparedStatement ps = stmt.getPreparedStatement();
+		int rsNum = 0;
+		do {
+		if (hasResultSet)
+		{
+			stmt.setCurrentDrdaResultSet(rsNum);
+			//indicate that we are going to return data
+			stmt.setQryrtndta(true);
+			if (! isProcedure)
+				checkWarning(null, ps, null, true, -1, true, true);
+			if (rsNum == 0)
+				writeSQLRSLRD(stmt);
+			writeOPNQRYRM(true, stmt);
+			writeSQLCINRD(stmt);
+			writeQRYDSC(stmt, false);
+			stmt.rsSuspend();
+
+			/* Currently, if LMTBLKPRC is used, a pre-condition is that no lob columns.
+			 * But in the future, when we do support LOB in LMTBLKPRC, the drda spec still
+			 * does not allow LOB to be sent with OPNQRYRM.  So this "if" here will have
+			 * to add "no lob columns".
+			 */
+			if (stmt.getQryprctyp() == CodePoint.LMTBLKPRC)
+				writeQRYDTA(stmt);
+		}
+		else  if (! sendSQLDTARD)
+		{
+			int updateCount = ps.getUpdateCount();
+			boolean reuseCorrID = false;			// RESOLVE:  We should send this but get protocol err if
+			// we do!!!
+			if (false && (database.RDBUPDRM_sent == false) &&
+				! isProcedure)
+			{
+				writeRDBUPDRM();
+				//following SQLCARD has to be in a continued DSS
+				reuseCorrID = true;
+			}
+
+
+			checkWarning(database.getConnection(), stmt.ps, null, false, updateCount, true, true);
+		}
+		else
+			writer.endDss();
+
+		} while(hasResultSet && (++rsNum < numResults));
+		
+		return;			// we are done
+	}
+
+
+	/**
+	 * Parse RDBCMTOK - tells the database whether to allow commits or rollbacks
+	 * to be executed as part of the command
+	 * Since we don't have a SQL commit or rollback command, we will just ignore
+	 * this for now
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void parseRDBCMTOK() throws DRDAProtocolException
+	{
+		boolean rdbcmtok = readBoolean(CodePoint.RDBCMTOK);
+		if (SanityManager.DEBUG) 
+			trace("rdbcmtok = " + rdbcmtok);
+	}
+
+	/**
+	 * Parse EXCSQLSTT command objects
+	 * Command Objects
+	 *  TYPDEFNAM - Data Type Definition Name - optional
+	 *  TYPDEFOVR - TYPDEF Overrides -optional
+	 *	SQLDTA - optional, variable data, specified if prpared statement has input parameters
+	 *	EXTDTA - optional, externalized FD:OCA data
+	 *	OUTOVR - output override descriptor, not allowed for stored procedure calls
+	 *
+	 * If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects
+	 * sent with the statement.  Once the statement is over, the default values
+	 * sent in the ACCRDB are once again in effect.  If no values are supplied,
+	 * the values sent in the ACCRDB are used.
+	 * Objects may follow in one DSS or in several DSS chained together.
+	 * 
+	 * @param the DRDAStatement to execute
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void parseEXCSQLSTTobjects(DRDAStatement stmt) throws DRDAProtocolException, SQLException
+	{
+		int codePoint;
+		boolean gotSQLDTA = false, typeDefChanged = false;
+		do
+		{
+			correlationID = reader.readDssHeader();
+			while (reader.moreDssData())
+			{
+				codePoint = reader.readLengthAndCodePoint();
+				switch(codePoint)
+				{
+					// optional
+					case CodePoint.TYPDEFNAM:
+						setStmtOrDbByteOrder(false, stmt, parseTYPDEFNAM());
+						typeDefChanged = true;
+						break;
+					// optional
+					case CodePoint.TYPDEFOVR:
+						parseTYPDEFOVR(stmt);
+						typeDefChanged = true;
+						break;
+					// required
+					case CodePoint.SQLDTA:
+						parseSQLDTA(stmt);
+						gotSQLDTA = true;
+						break;
+					// optional
+					case CodePoint.EXTDTA:	
+						readAndSetAllExtParams(stmt);
+						break;
+					// optional
+					case CodePoint.OUTOVR:
+						parseOUTOVR(stmt);
+						break;
+					default:
+						invalidCodePoint(codePoint);
+				}
+			}
+		} while (reader.isChainedWithSameID());
+
+		// SQLDTA is required
+		if (! gotSQLDTA)
+			missingCodePoint(CodePoint.SQLDTA);
+		if (typeDefChanged)
+			stmt.setTypDefValues();
+	}
+
+	/**
+	 * Write SQLCINRD - result set column information
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeSQLCINRD(DRDAStatement stmt) throws DRDAProtocolException,SQLException
+	{
+		ResultSet rs = null;
+		PreparedStatement ps = stmt.getPreparedStatement();
+		
+		if (!stmt.needsToSendParamData)
+			rs = stmt.getResultSet();
+
+		writer.createDssObject();
+		writer.startDdm(CodePoint.SQLCINRD);
+		if (sqlamLevel >= MGRLVL_7)
+			writeSQLDHROW (stmt);
+
+		ResultSetMetaData rsmeta = rs.getMetaData();
+		int ncols = rsmeta.getColumnCount();
+		writer.writeShort(ncols);	// num of columns
+		if (sqlamLevel >= MGRLVL_7)
+		{
+			for (int i = 0; i < ncols; i++)
+				writeSQLDAGRP (rsmeta, null, i, true);
+		}
+		else
+		{
+			for (int i = 0; i < ncols; i++)
+			{
+				writeVCMorVCS(rsmeta.getColumnName(i+1));
+				writeVCMorVCS(rsmeta.getColumnLabel(i+1));
+				writeVCMorVCS(null);
+			}
+		}
+		writer.endDdmAndDss();
+	}
+
+	/**
+	 * Write SQLRSLRD - result set reply data
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeSQLRSLRD(DRDAStatement stmt) throws DRDAProtocolException,SQLException
+	{
+
+		EmbedPreparedStatement ps = (EmbedPreparedStatement) stmt.getPreparedStatement();
+		int numResults = stmt.getNumResultSets();
+
+		writer.createDssObject();
+		writer.startDdm(CodePoint.SQLRSLRD);
+		writer.writeShort(numResults); // num of result sets
+
+		for (int i = 0; i < numResults; i ++)
+			{
+				writer.writeInt(i);	// rsLocator
+				writeVCMorVCS(stmt.getResultSetCursorName(i));
+				writer.writeInt(1);	// num of rows XXX resolve, it doesn't matter for now
+
+			}
+		writer.endDdmAndDss();
+	}
+
+	/**
+	 * Write RSLSETRM
+	 * Instance variables
+	 *  SVRCOD - Severity code - Information only - required
+	 *  PKGSNLST - list of PKGNAMCSN -required
+	 *  SRVDGN - Server Diagnostic Information -optional
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeRSLSETRM(DRDAStatement stmt) throws DRDAProtocolException,SQLException
+	{
+		int numResults = stmt.getNumResultSets();
+		writer.createDssReply();
+		writer.startDdm(CodePoint.RSLSETRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, 0);
+		writer.startDdm(CodePoint.PKGSNLST);
+		
+		for (int i = 0; i < numResults; i++)
+			writePKGNAMCSN(stmt.getResultSetPkgcnstknStr(i));
+		writer.endDdm();
+		writer.endDdmAndDss();
+	}
+
+	
+	/**
+	 * Parse SQLDTA - SQL program variable data 
+	 * and handle exception.
+	 * @see parseSQLDTA_work
+	 */
+
+	private void parseSQLDTA(DRDAStatement stmt) throws DRDAProtocolException,SQLException
+	{
+		try {
+			parseSQLDTA_work(stmt);
+		} 
+		catch (SQLException se)
+		{
+			reader.skipDss();
+			while (reader.isChainedWithSameID() || 
+				   reader.isChainedWithDiffID())
+			{
+				correlationID = reader.readDssHeader();
+				reader.skipDss();
+				
+			}
+			throw se;
+		}
+	}
+	
+	/**
+	 * Parse SQLDTA - SQL program variable data
+	 * Instance Variables
+	 *  FDODSC - FD:OCA data descriptor - required
+	 *  FDODTA - FD:OCA data - optional
+	 *    
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	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;
+
+		reader.markCollection();		
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+				switch (codePoint)
+				{
+					// required
+					case CodePoint.FDODSC:
+						while (reader.getDdmLength() > 6) //we get parameter info til last 6 byte
+					{
+						int dtaGrpLen = reader.readUnsignedByte();
+						int numVarsInGrp = (dtaGrpLen - 3) / 3;
+						if (SanityManager.DEBUG) 
+							trace("num of vars in this group is: "+numVarsInGrp);
+						reader.readByte();		// tripletType
+						reader.readByte();		// id
+						for (int j = 0; j < numVarsInGrp; j++)
+						{
+							paramDrdaTypes.addElement(new Byte(reader.readByte()));
+							if (SanityManager.DEBUG) 
+								trace("drdaType is: "+ "0x" +
+       								  Integer.toHexString(((Byte ) paramDrdaTypes.lastElement()).byteValue()));
+							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 (ps == null)		// it is a CallableStatement under construction
+					{
+						String marks = "(?";	// construct parameter marks
+						for (int i = 1; i < numVars; i++)
+							marks += ", ?";
+						String prepareString = "call " + stmt.procName + marks + ")";
+						if (SanityManager.DEBUG) 
+							trace ("$$ prepareCall is: "+prepareString);
+						CallableStatement cs = null;
+						try {
+							cs = (CallableStatement)
+								stmt.prepare(prepareString);			
+							stmt.registerAllOutParams();
+						} catch (SQLException se) {
+							if (! stmt.outputExpected || 
+								(!se.getSQLState().equals(SQLState.LANG_NO_METHOD_FOUND)))
+								throw se;
+							if (SanityManager.DEBUG) 
+								trace("****** second try with return parameter...");
+							// Save first SQLException most likely suspect
+							if (numVars == 1)
+								prepareString = "? = call " + stmt.procName +"()";
+							else
+								prepareString = "? = call " + stmt.procName +"("+marks.substring(3) + ")";
+							if (SanityManager.DEBUG)
+								trace ("$$ prepareCall is: "+prepareString);
+							try {
+								cs = (CallableStatement) stmt.prepare(prepareString);
+							} catch (SQLException se2)
+							{
+								// The first exception is the most likely suspect
+								throw se;
+							}
+							rtnParam = true;
+						}
+						ps = cs;
+					}
+
+					pmeta = ((EmbedPreparedStatement) ps).getEmbedParameterSetMetaData();
+
+					reader.readBytes(6);	// descriptor footer
+					break;
+				// optional
+				case CodePoint.FDODTA:
+					reader.readByte();	// row indicator
+					for (int i = 0; i < numVars; i++)
+					{
+					
+						if ((((Byte)paramDrdaTypes.elementAt(i)).byteValue() & 0x1) == 0x1)	// nullable
+						{
+							int nullData = reader.readUnsignedByte();
+							if ((nullData & 0xFF) == FdocaConstants.NULL_DATA)
+							{
+								if (SanityManager.DEBUG)
+									trace("******param null");
+								if (pmeta.getParameterMode(i + 1) 
+									!= JDBC30Translation.PARAMETER_MODE_OUT )
+										ps.setNull(i+1, pmeta.getParameterType(i+1));
+								if (stmt.isOutputParam(i+1))
+									stmt.registerOutParam(i+1);
+								continue;
+							}
+						}
+
+						// not null, read and set it
+						paramExtPositions = readAndSetParams(i, stmt,
+															 ((Byte)paramDrdaTypes.elementAt(i)).byteValue(),
+															 pmeta,
+															 paramExtPositions,
+															 ((Integer)(paramLens.elementAt(i))).intValue());
+					}
+					stmt.cliParamExtPositions = paramExtPositions;
+					stmt.cliParamDrdaTypes = paramDrdaTypes;
+					stmt.cliParamLens = paramLens;	
+					break;
+				case CodePoint.EXTDTA:
+					readAndSetAllExtParams(stmt);
+					break;
+				default:
+					invalidCodePoint(codePoint);
+
+			}
+				codePoint = reader.getCodePoint();
+		}
+
+
+	}
+
+	private int getByteOrder()
+	{
+		DRDAStatement stmt = database.getCurrentStatement();
+		return ((stmt != null && stmt.typDefNam != null) ? stmt.byteOrder : database.byteOrder);
+	}
+
+	/**
+	 * 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 pmeta		parameter meta data
+	 * @param paramExtPositions  ArrayList of parameters with extdta
+	 * @param paramLenNumBytes Number of bytes for encoding LOB Length
+	 *
+	 * @return updated paramExtPositions
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private ArrayList readAndSetParams(int i, DRDAStatement stmt, int
+									   drdaType, EmbedParameterSetMetaData pmeta,
+									   ArrayList paramExtPositions,
+									   int paramLenNumBytes)
+				throws DRDAProtocolException, SQLException
+	{
+		PreparedStatement ps = stmt.getPreparedStatement();
+		// mask out null indicator
+		drdaType = ((drdaType | 0x01) & 0x000000ff);
+
+		if (ps instanceof CallableStatement)
+		{
+			if (stmt.isOutputParam(i+1))
+			{
+				CallableStatement cs = (CallableStatement) ps;
+				cs.registerOutParameter(i+1, stmt.getOutputParamType(i+1));
+			}
+		}
+
+		switch (drdaType)
+		{
+			case FdocaConstants.DRDA_TYPE_NSMALL:
+			{
+				short paramVal = (short) reader.readShort(getByteOrder());
+				if (SanityManager.DEBUG)
+					trace("short parameter value is: "+paramVal);
+ 				// DB2 does not have a BOOLEAN java.sql.bit type, it's sent as small
+				if (pmeta.getParameterType(i+1) == JDBC30Translation.BOOLEAN)
+					ps.setBoolean(i+1, (paramVal == 1));
+				else
+					ps.setShort(i+1, paramVal);
+				break;
+		}
+			case  FdocaConstants.DRDA_TYPE_NINTEGER:
+			{
+				int paramVal = reader.readInt(getByteOrder());
+				if (SanityManager.DEBUG)
+					trace("integer parameter value is: "+paramVal);
+				ps.setInt(i+1, paramVal);
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NINTEGER8:
+			{
+				long paramVal = reader.readLong(getByteOrder());
+				if (SanityManager.DEBUG)
+					trace("parameter value is: "+paramVal);
+				ps.setLong(i+1, paramVal);
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NFLOAT4:
+			{
+				float paramVal = reader.readFloat(getByteOrder());
+				if (SanityManager.DEBUG) 
+					trace("parameter value is: "+paramVal);
+				ps.setFloat(i+1, paramVal);
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NFLOAT8:
+			{
+				double paramVal = reader.readDouble(getByteOrder());
+				if (SanityManager.DEBUG) 
+					trace("nfloat8 parameter value is: "+paramVal);
+				ps.setDouble(i+1, paramVal);
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NDECIMAL:
+			{
+				int precision = (paramLenNumBytes >> 8) & 0xff;
+				int scale = paramLenNumBytes & 0xff;
+				BigDecimal paramVal = reader.readBigDecimal(precision, scale);
+				if (SanityManager.DEBUG)
+					trace("ndecimal parameter value is: "+paramVal);
+				ps.setBigDecimal(i+1, paramVal);
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NDATE:
+			{
+				String paramVal = reader.readStringData(10).trim();  //parameter may be char value
+				if (SanityManager.DEBUG) 
+					trace("ndate parameter value is: \""+paramVal+"\"");
+				ps.setDate(i+1, java.sql.Date.valueOf(paramVal));
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NTIME:
+			{
+				String paramVal = reader.readStringData(8).trim();  //parameter may be char value
+				if (SanityManager.DEBUG) 
+					trace("ntime parameter value is: "+paramVal);
+				ps.setTime(i+1, java.sql.Time.valueOf(paramVal));
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NTIMESTAMP:
+			{
+				// DB2 represents ts with 26 chars, and a slightly different format than Java standard
+				// we do the conversion and pad 3 digits for nano seconds.
+				String paramVal = reader.readStringData(26).trim();  //parameter may be char value
+				if (SanityManager.DEBUG)
+					trace("ntimestamp parameter value is: "+paramVal);
+				String tsString = paramVal.substring(0,10)+" "+paramVal.substring(11,19).replace('.', ':')+paramVal.substring(19)+"000";
+				if (SanityManager.DEBUG)
+					trace("tsString is: "+tsString);
+				ps.setTimestamp(i+1, java.sql.Timestamp.valueOf(tsString));
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NCHAR:
+			case FdocaConstants.DRDA_TYPE_NVARCHAR:
+			case FdocaConstants.DRDA_TYPE_NLONG:
+			case FdocaConstants.DRDA_TYPE_NVARMIX:
+			case FdocaConstants.DRDA_TYPE_NLONGMIX:
+			{
+				String paramVal = reader.readLDStringData(stmt.ccsidMBCEncoding);
+				if (SanityManager.DEBUG)
+					trace("char/varchar parameter value is: "+paramVal);
+				ps.setString(i+1, paramVal);
+				break;
+			}
+			case  FdocaConstants.DRDA_TYPE_NFIXBYTE:
+			{
+				byte[] paramVal = reader.readBytes();
+				if (SanityManager.DEBUG) 
+					trace("fix bytes parameter value is: "+new String(paramVal));
+				ps.setBytes(i+1, paramVal);
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NVARBYTE:
+			case FdocaConstants.DRDA_TYPE_NLONGVARBYTE:
+			{
+				int length = reader.readNetworkShort();	//protocol control data always follows big endian
+				if (SanityManager.DEBUG)
+					trace("===== binary param length is: " + length);
+				byte[] paramVal = reader.readBytes(length);
+				ps.setBytes(i+1, paramVal);
+				break;
+			}
+			case FdocaConstants.DRDA_TYPE_NLOBBYTES:
+			case FdocaConstants.DRDA_TYPE_NLOBCMIXED:
+			case FdocaConstants.DRDA_TYPE_NLOBCSBCS:
+			case FdocaConstants.DRDA_TYPE_NLOBCDBCS:
+			 {
+				 long length = readLobLength(paramLenNumBytes);
+				 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));
+				 }
+				 else   /* empty */
+				 {
+					if (drdaType == FdocaConstants.DRDA_TYPE_NLOBBYTES)
+						ps.setBytes(i+1, new byte[0]);
+					else
+						ps.setString(i+1, "");
+				 }
+				 break;
+			 }
+			default:
+				{
+				String paramVal = reader.readLDStringData(stmt.ccsidMBCEncoding);
+				if (SanityManager.DEBUG) 
+					trace("default type parameter value is: "+paramVal);
+				ps.setObject(i+1, paramVal);
+			}
+		}
+		return paramExtPositions;
+	}
+
+	private long readLobLength(int extLenIndicator) 
+		throws DRDAProtocolException
+	{
+		switch (extLenIndicator)
+		{
+			case 0x8002:
+				return (long) reader.readNetworkShort();
+			case 0x8004:
+				return (long) reader.readNetworkInt();
+			case 0x8006:
+				return (long) reader.readNetworkSixByteLong();
+			case 0x8008:
+				return (long) reader.readNetworkLong();
+			default:
+				throwSyntaxrm(CodePoint.SYNERRCD_INCORRECT_EXTENDED_LEN, extLenIndicator);
+				return 0L;
+		}
+		
+
+
+	}
+	
+
+	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();
+						}
+					}
+
+	}
+	
+
+	/**
+	 * Read different types of input parameters and set them in PreparedStatement
+	 * @param i			index of the parameter
+	 * @param ps		associated ps
+	 * @param drdaType	drda type of the parameter
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void readAndSetExtParam( int i, DRDAStatement stmt,
+									  int drdaType, int extLen)
+				throws DRDAProtocolException, SQLException
+		{
+			PreparedStatement ps = stmt.getPreparedStatement();
+			drdaType = (drdaType & 0x000000ff); // need unsigned value
+			boolean checkNullability = false;
+			if (sqlamLevel >= MGRLVL_7 &&
+				FdocaConstants.isNullable(drdaType))
+				checkNullability = true;
+	
+			try {	
+				byte[] paramBytes = reader.getExtData(checkNullability);
+				String paramString = null;
+				switch (drdaType)
+				{
+					case  FdocaConstants.DRDA_TYPE_LOBBYTES:
+					case  FdocaConstants.DRDA_TYPE_NLOBBYTES:
+						if (SanityManager.DEBUG)
+							trace("parameter value is: "+paramBytes);
+						ps.setBytes(i+1, paramBytes);
+						break;
+					case FdocaConstants.DRDA_TYPE_LOBCSBCS:
+					case FdocaConstants.DRDA_TYPE_NLOBCSBCS:
+						paramString = new String(paramBytes, stmt.ccsidSBCEncoding);
+						if (SanityManager.DEBUG)
+							trace("parameter value is: "+ paramString);
+						ps.setString(i+1,paramString);
+						break;
+					case FdocaConstants.DRDA_TYPE_LOBCDBCS:
+					case FdocaConstants.DRDA_TYPE_NLOBCDBCS:
+						paramString = new String(paramBytes, stmt.ccsidDBCEncoding );
+						if (SanityManager.DEBUG)
+							trace("parameter value is: "+ paramString);
+						ps.setString(i+1,paramString);
+						break;
+					case FdocaConstants.DRDA_TYPE_LOBCMIXED:
+					case FdocaConstants.DRDA_TYPE_NLOBCMIXED:
+						paramString = new String(paramBytes, stmt.ccsidMBCEncoding);
+						if (SanityManager.DEBUG)
+							trace("parameter value is: "+ paramString);
+						ps.setString(i+1,paramString);
+						break;
+					default:
+						invalidValue(drdaType);
+				}
+			     
+			}
+			catch (java.io.UnsupportedEncodingException e) {
+				throw new SQLException (e.getMessage());
+			}
+		}
+
+	/**
+	 * Parse EXCSQLIMM - Execute Immediate Statement
+	 * Instance Variables
+	 *  RDBNAM - relational database name - optional
+	 *  PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required
+	 *  RDBCMTOK - RDB Commit Allowed - optional
+	 *  MONITOR - Monitor Events - optional
+	 *
+	 * Command Objects
+	 *  TYPDEFNAM - Data Type Definition Name - optional
+	 *  TYPDEFOVR - TYPDEF Overrides -optional
+	 *  SQLSTT - SQL Statement -required
+	 *
+	 * @return update count
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private int parseEXCSQLIMM() throws DRDAProtocolException,SQLException
+	{
+		int codePoint;
+		reader.markCollection();
+		String pkgnamcsn = null;
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.EXCSQLIMM);
+					break;
+				// required
+				case CodePoint.PKGNAMCSN:
+				    pkgnamcsn = parsePKGNAMCSN();
+					break;
+				case CodePoint.RDBCMTOK:
+					parseRDBCMTOK();
+					break;
+				//optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+
+			}
+			codePoint = reader.getCodePoint();
+		}
+		DRDAStatement drdaStmt =  database.getDefaultStatement(pkgnamcsn);
+		// initialize statement for reuse
+		drdaStmt.initialize();
+		String sqlStmt = parseEXECSQLIMMobjects();
+		drdaStmt.getStatement().clearWarnings();
+		int updCount = drdaStmt.getStatement().executeUpdate(sqlStmt);
+		return updCount;
+	}
+
+	/**
+	 * Parse EXCSQLSET - Execute Set SQL Environment
+	 * Instance Variables
+	 *  RDBNAM - relational database name - optional
+	 *  PKGNAMCT - RDB Package Name, Consistency Token  - optional
+	 *  MONITOR - Monitor Events - optional
+	 *
+	 * Command Objects
+	 *  TYPDEFNAM - Data Type Definition Name - required
+	 *  TYPDEFOVR - TYPDEF Overrides - required
+	 *  SQLSTT - SQL Statement - required (at least one; may be more)
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private boolean parseEXCSQLSET() throws DRDAProtocolException,SQLException
+	{
+
+		int codePoint;
+		reader.markCollection();
+
+
+		codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.EXCSQLSET);
+					break;
+				// optional
+				case CodePoint.PKGNAMCT:
+					// we are going to ignore this for EXCSQLSET
+					// since we are just going to reuse an existing statement
+					String pkgnamct = parsePKGNAMCT();
+					break;
+				// optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+				// required
+				case CodePoint.PKGNAMCSN:
+					// we are going to ignore this for EXCSQLSET.
+					// since we are just going to reuse an existing statement.
+					// NOTE: This codepoint is not in the DDM spec for 'EXCSQLSET',
+					// but since it DOES get sent by jcc1.2, we have to have
+					// a case for it...
+					String pkgnamcsn = parsePKGNAMCSN();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+
+			}
+			codePoint = reader.getCodePoint();
+		}
+
+		parseEXCSQLSETobjects();
+		return true;
+	}
+
+	/**
+	 * Parse EXCSQLIMM objects
+	 * Objects
+	 *  TYPDEFNAM - Data type definition name - optional
+	 *  TYPDEFOVR - Type defintion overrides
+	 *  SQLSTT - SQL Statement required
+	 *
+	 * If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects
+	 * sent with the statement.  Once the statement is over, the default values
+	 * sent in the ACCRDB are once again in effect.  If no values are supplied,
+	 * the values sent in the ACCRDB are used.
+	 * Objects may follow in one DSS or in several DSS chained together.
+	 * 
+	 * @return SQL Statement
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private String parseEXECSQLIMMobjects() throws DRDAProtocolException, SQLException
+	{
+		String sqlStmt = null;
+		int codePoint;
+		DRDAStatement stmt = database.getDefaultStatement();
+		do
+		{
+			correlationID = reader.readDssHeader();
+			while (reader.moreDssData())
+			{
+				codePoint = reader.readLengthAndCodePoint();
+				switch(codePoint)
+				{
+					// optional
+					case CodePoint.TYPDEFNAM:
+						setStmtOrDbByteOrder(false, stmt, parseTYPDEFNAM());
+						break;
+					// optional
+					case CodePoint.TYPDEFOVR:
+						parseTYPDEFOVR(stmt);
+						break;
+					// required
+					case CodePoint.SQLSTT:
+						sqlStmt = parseEncodedString();
+						if (SanityManager.DEBUG) 
+							trace("sqlStmt = " + sqlStmt);
+						break;
+					default:
+						invalidCodePoint(codePoint);
+				}
+			}
+		} while (reader.isChainedWithSameID());
+
+		// SQLSTT is required
+		if (sqlStmt == null)
+			missingCodePoint(CodePoint.SQLSTT);
+		return sqlStmt;
+	}
+
+	/**
+	 * Parse EXCSQLSET objects
+	 * Objects
+	 *  TYPDEFNAM - Data type definition name - optional
+	 *  TYPDEFOVR - Type defintion overrides - optional
+	 *  SQLSTT - SQL Statement - required (a list of at least one)
+	 *
+	 * Objects may follow in one DSS or in several DSS chained together.
+	 * 
+	 * @return Count of updated rows.
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void parseEXCSQLSETobjects()
+		throws DRDAProtocolException, SQLException
+	{
+
+		boolean gotSqlStt = false;
+		boolean hadUnrecognizedStmt = false;
+
+		String sqlStmt = null;
+		int codePoint;
+		DRDAStatement drdaStmt = database.getDefaultStatement();
+		drdaStmt.initialize();
+
+		do
+		{
+			correlationID = reader.readDssHeader();
+			while (reader.moreDssData())
+			{
+
+				codePoint = reader.readLengthAndCodePoint();
+
+				switch(codePoint)
+				{
+					// optional
+					case CodePoint.TYPDEFNAM:
+						setStmtOrDbByteOrder(false, drdaStmt, parseTYPDEFNAM());
+						break;
+					// optional
+					case CodePoint.TYPDEFOVR:
+						parseTYPDEFOVR(drdaStmt);
+						break;
+					// required
+					case CodePoint.SQLSTT:
+						sqlStmt = parseEncodedString();
+						if (sqlStmt != null)
+						// then we have at least one SQL Statement.
+							gotSqlStt = true;
+
+						if (canIgnoreStmt(sqlStmt)) {
+						// We _know_ Cloudscape doesn't recognize this
+						// statement; don't bother trying to execute it.
+						// NOTE: at time of writing, this only applies
+						// to "SET CLIENT" commands, and it was decided
+						// that throwing a Warning for these commands
+						// would confuse people, so even though the DDM
+						// spec says to do so, we choose not to (but
+						// only for SET CLIENT cases).  If this changes
+						// at some point in the future, simply remove
+						// the follwing line; we will then throw a
+						// warning.
+//							hadUnrecognizedStmt = true;
+							break;
+						}
+
+						if (SanityManager.DEBUG) 
+							trace("sqlStmt = " + sqlStmt);
+
+						// initialize statement for reuse
+						drdaStmt.initialize();
+						drdaStmt.getStatement().clearWarnings();
+						try {
+							drdaStmt.getStatement().executeUpdate(sqlStmt);
+						} catch (SQLException e) {
+
+							// if this is a syntax error, then we take it
+							// to mean that the given SET statement is not
+							// recognized; take note (so we can throw a
+							// warning later), but don't interfere otherwise.
+							if (e.getSQLState().equals(SYNTAX_ERR))
+								hadUnrecognizedStmt = true;
+							else
+							// something else; assume it's serious.
+								throw e;
+						}
+						break;
+					default:
+						invalidCodePoint(codePoint);
+				}
+			}
+
+		} while (reader.isChainedWithSameID());
+
+		// SQLSTT is required.
+		if (!gotSqlStt)
+			missingCodePoint(CodePoint.SQLSTT);
+
+		// Now that we've processed all SET statements (assuming no
+		// severe exceptions), check for warnings and, if we had any,
+		// note this in the SQLCARD reply object (but DON'T cause the
+		// EXCSQLSET statement to fail).
+		if (hadUnrecognizedStmt) {
+			SQLWarning warn = new SQLWarning("One or more SET statements " +
+				"not recognized.", "01000");
+			throw warn;
+		} // end if.
+
+		return;
+	}
+
+	private boolean canIgnoreStmt(String stmt)
+	{
+		if (stmt.indexOf("SET CLIENT") != -1)
+			return true;
+		return false;
+	}
+
+	/**
+	 * Write RDBUPDRM
+	 * Instance variables
+	 *  SVRCOD - Severity code - Information only - required
+	 *  RDBNAM - Relational database name -required
+	 *  SRVDGN - Server Diagnostic Information -optional
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void writeRDBUPDRM() throws DRDAProtocolException
+	{
+		database.RDBUPDRM_sent = true;
+		writer.createDssReply();
+		writer.startDdm(CodePoint.RDBUPDRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, CodePoint.SVRCOD_INFO);
+		writeRDBNAM(database.dbName);
+		writer.endDdmAndDss();
+	}
+
+
+	private String parsePKGNAMCT() throws DRDAProtocolException
+	{
+		reader.skipBytes();
+		return null;
+	}
+
+	/**
+	 * Parse PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number
+	 * Instance Variables
+	 *   NAMESYMDR - database name - not validated
+	 *   RDBCOLID - RDB Collection Identifier
+	 *   PKGID - RDB Package Identifier
+	 *   PKGCNSTKN - RDB Package Consistency Token
+	 *   PKGSN - RDB Package Section Number
+	 *
+	 * @exception throws DRDAProtocolException
+	 */
+	private String parsePKGNAMCSN() throws DRDAProtocolException
+	{
+		rdbnam = null;
+		rdbcolid = null;
+		pkgid = null;
+		secnumber = 0;
+
+		if (reader.getDdmLength() == CodePoint.PKGNAMCSN_LEN)
+		{
+			// This is a scalar object with the following fields
+			rdbnam = reader.readString(CodePoint.RDBNAM_LEN);
+			if (SanityManager.DEBUG) 
+				trace("rdbnam = " + rdbnam);
+
+			rdbcolid = reader.readString(CodePoint.RDBCOLID_LEN);
+			if (SanityManager.DEBUG) 
+				trace("rdbcolid = " + rdbcolid);
+
+			pkgid = reader.readString(CodePoint.PKGID_LEN);
+			if (SanityManager.DEBUG)
+				trace("pkgid = " + pkgid);
+
+			// we need to use the same UCS2 encoding, as this can be
+			// bounced back to jcc (or keep the byte array)
+			pkgcnstknStr = reader.readString(CodePoint.PKGCNSTKN_LEN);
+			if (SanityManager.DEBUG) 
+				trace("pkgcnstkn = " + pkgcnstknStr);
+
+			secnumber = reader.readNetworkShort();
+			if (SanityManager.DEBUG)
+				trace("secnumber = " + secnumber);
+		}
+		else	// extended format
+		{
+			int length = reader.readNetworkShort();
+			if (length < CodePoint.RDBNAM_LEN || length > CodePoint.MAX_NAME)
+				badObjectLength(CodePoint.RDBNAM);
+			rdbnam = reader.readString(length);
+			if (SanityManager.DEBUG)
+				trace("rdbnam = " + rdbnam);
+
+			//RDBCOLID can be variable length in this format
+			length = reader.readNetworkShort();
+			rdbcolid = reader.readString(length);
+			if (SanityManager.DEBUG) 
+				trace("rdbcolid = " + rdbcolid);
+
+			length = reader.readNetworkShort();
+			if (length != CodePoint.PKGID_LEN)
+				badObjectLength(CodePoint.PKGID);
+			pkgid = reader.readString(CodePoint.PKGID_LEN);
+			if (SanityManager.DEBUG) 
+				trace("pkgid = " + pkgid);
+
+			pkgcnstknStr = reader.readString(CodePoint.PKGCNSTKN_LEN);
+			if (SanityManager.DEBUG) 
+				trace("pkgcnstkn = " + pkgcnstknStr);
+
+			secnumber = reader.readNetworkShort();
+			if (SanityManager.DEBUG) 
+				trace("secnumber = " + secnumber);
+		}
+		// Note: This string  is parsed by DRDAStatement.buildDB2CursorName()
+		return rdbnam + " " + rdbcolid + " " + pkgid + " " + secnumber + " " + pkgcnstknStr;
+	}
+
+	/**
+	 * Parse SQLSTT Dss
+	 * @exception DRDAProtocolException
+	 */
+	private String parseSQLSTTDss() throws DRDAProtocolException
+	{
+		correlationID = reader.readDssHeader();
+		int codePoint = reader.readLengthAndCodePoint();
+		String strVal = parseEncodedString();
+		if (SanityManager.DEBUG) 
+			trace("SQL Statement = " + strVal);
+		return strVal;
+	}
+
+	/**
+	 * Parse an encoded data string from the Application Requester
+	 *
+	 * @return string value
+	 * @exception DRDAProtocolException
+	 */
+	private String parseEncodedString() throws DRDAProtocolException
+	{
+		if (sqlamLevel < 7)
+			return parseVCMorVCS();
+		else
+			return parseNOCMorNOCS();
+	}
+
+	/**
+	 * Parse variable character mixed byte or variable character single byte
+	 * Format
+	 *  I2 - VCM Length
+	 *  N bytes - VCM value
+	 *  I2 - VCS Length
+	 *  N bytes - VCS value 
+	 * Only 1 of VCM length or VCS length can be non-zero
+	 *
+	 * @return string value
+	 */
+	private String parseVCMorVCS() throws DRDAProtocolException
+	{
+		String strVal = null;
+		int vcm_length = reader.readNetworkShort();
+		if (vcm_length > 0)
+			strVal = parseCcsidMBC(vcm_length);
+		int vcs_length = reader.readNetworkShort();
+		if (vcs_length > 0)
+		{
+			if (strVal != null)
+				agentError ("Both VCM and VCS have lengths > 0");
+			strVal = parseCcsidSBC(vcs_length);
+		}
+		return strVal;
+	}
+	/**
+	 * Parse nullable character mixed byte or nullable character single byte
+	 * Format
+	 *  1 byte - null indicator
+	 *  I4 - mixed character length
+	 *  N bytes - mixed character string
+	 *  1 byte - null indicator
+	 *  I4 - single character length
+	 *  N bytes - single character length string
+	 *
+	 * @return string value
+	 * @exception DRDAProtocolException
+	 */
+	private String parseNOCMorNOCS() throws DRDAProtocolException
+	{
+		byte nocm_nullByte = reader.readByte();
+		String strVal = null;
+		int length;
+		if (nocm_nullByte != NULL_VALUE)
+		{
+			length = reader.readNetworkInt();
+			strVal = parseCcsidMBC(length);
+		}
+		byte nocs_nullByte = reader.readByte();
+		if (nocs_nullByte != NULL_VALUE)
+		{
+			if (strVal != null)
+				agentError("Both CM and CS are non null");
+			length = reader.readNetworkInt();
+			strVal = parseCcsidSBC(length);
+		}
+		return strVal;
+	}
+	/**
+	 * Parse mixed character string
+	 * 
+	 * @return string value
+	 * @exception DRDAProtocolException
+	 */
+	private String parseCcsidMBC(int length) throws DRDAProtocolException
+	{
+		String strVal = null;
+		DRDAStatement  currentStatement;
+
+		currentStatement = database.getCurrentStatement();
+		if (currentStatement == null)
+		{
+			currentStatement = database.getDefaultStatement();
+			currentStatement.initialize();
+		}
+		String ccsidMBCEncoding = currentStatement.ccsidMBCEncoding;
+
+		if (length == 0)
+			return null;
+		byte [] byteStr = reader.readBytes(length);
+		if (ccsidMBCEncoding != null)
+		{
+			try {
+				strVal = new String(byteStr, 0, length, ccsidMBCEncoding);
+			} catch (UnsupportedEncodingException e) {
+				agentError("Unsupported encoding " + ccsidMBCEncoding +
+					"in parseCcsidMBC");
+			}
+		}
+		else
+			agentError("Attempt to decode mixed byte string without CCSID being set");
+		return strVal;
+	}
+	/**
+	 * Parse single byte character string
+	 * 
+	 * @return string value
+	 * @exception DRDAProtocolException
+	 */
+	private String parseCcsidSBC(int length) throws DRDAProtocolException
+	{
+		String strVal = null;
+		String ccsidSBCEncoding = database.getCurrentStatement().ccsidSBCEncoding;
+		if (length == 0)
+			return null;
+		byte [] byteStr = reader.readBytes(length);
+		if (ccsidSBCEncoding != null)
+		{
+			try {
+				strVal = new String(byteStr, 0, length, ccsidSBCEncoding);
+			} catch (UnsupportedEncodingException e) {
+				agentError("Unsupported encoding " + ccsidSBCEncoding +
+					"in parseCcsidSBC");
+			}
+		}
+		else
+			agentError("Attempt to decode single byte string without CCSID being set");
+		return strVal;
+	}
+	/**
+	 * Parse CLSQRY
+	 * Instance Variables
+	 *  RDBNAM - relational database name - optional
+	 *  PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required
+	 *  QRYINSID - Query Instance Identifier - required - level 7
+	 *  MONITOR - Monitor events - optional.
+	 *
+	 * @return DRDAstatement being closed
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private DRDAStatement parseCLSQRY() throws DRDAProtocolException, SQLException
+	{
+		String pkgnamcsn = null;
+		reader.markCollection();
+		long qryinsid = 0;
+		boolean gotQryinsid = false;
+
+		int codePoint = reader.getCodePoint();
+		while (codePoint != -1)
+		{
+			switch (codePoint)
+			{
+				// optional
+				case CodePoint.RDBNAM:
+					setDatabase(CodePoint.CLSQRY);
+					break;
+					// required
+				case CodePoint.PKGNAMCSN:
+					pkgnamcsn = parsePKGNAMCSN();
+					break;
+				case CodePoint.QRYINSID:
+					qryinsid = reader.readNetworkLong();
+					gotQryinsid = true;
+					break;
+				// optional
+				case CodePoint.MONITOR:
+					parseMONITOR();
+					break;
+				default:
+					invalidCodePoint(codePoint);
+			}
+			codePoint = reader.getCodePoint();
+		}
+		// check for required variables
+		if (pkgnamcsn == null)
+			missingCodePoint(CodePoint.PKGNAMCSN);
+		if (sqlamLevel >= MGRLVL_7 && !gotQryinsid)
+			missingCodePoint(CodePoint.QRYINSID);
+
+		DRDAStatement stmt = database.getDRDAStatement(pkgnamcsn);
+		if (stmt == null)
+		{
+			//XXX should really throw a SQL Exception here
+			invalidValue(CodePoint.PKGNAMCSN);
+		}
+
+		if (stmt.wasExplicitlyClosed())
+		{
+			// JCC still sends a CLSQRY even though we have
+			// implicitly closed the resultSet.
+			// Then complains if we send the writeQRYNOPRM
+			// So for now don't send it
+			// Also metadata calls seem to get bound to the same
+			// PGKNAMCSN, so even for explicit closes we have
+			// to ignore.
+			//writeQRYNOPRM(CodePoint.SVRCOD_ERROR);
+			pkgnamcsn = null;
+		}
+
+		stmt.CLSQRY();
+	   
+		return stmt;
+	}
+
+	/**
+	 * Parse MONITOR
+	 * DRDA spec says this is optional.  Since we
+	 * don't currently support it, we just ignore.
+	 */
+	private void parseMONITOR() 
+		throws DRDAProtocolException
+	{
+
+		// Just ignore it.
+		reader.skipBytes();
+		return;
+
+	}
+
+	private void writeSQLCARDs(SQLException e, boolean reuseCorrID, int updateCount)
+									throws DRDAProtocolException
+	{
+		writeSQLCARDs(e, reuseCorrID, updateCount, false);
+	}
+
+	private void writeSQLCARDs(SQLException e, boolean reuseCorrID, int updateCount, boolean sendSQLERRRM)
+									throws DRDAProtocolException
+	{
+
+		int severity = CodePoint.SVRCOD_INFO;
+		if (e == null)
+		{
+			writeSQLCARD(reuseCorrID, e,severity, updateCount, 0);
+			return;
+		}
+
+		// instead of writing a chain of sql error or warning, we send the first one, this is
+		// jcc/db2 limitation, see beetle 4629
+
+		// If it is a real SQL Error write a SQLERRRM first
+		severity = getExceptionSeverity(e);
+		if (sendSQLERRRM || (severity > CodePoint.SVRCOD_ERROR))
+		{
+			writeSQLERRRM(severity);
+			reuseCorrID = true;
+		}
+		writeSQLCARD(reuseCorrID, e,severity, updateCount, 0);
+	}
+
+	private int getSqlCode(int severity)
+	{
+		if (severity == CodePoint.SVRCOD_WARNING)		// warning
+			return 100;		//CLI likes it
+		else if (severity == CodePoint.SVRCOD_INFO)             
+			return 0;
+		else
+			return -1;
+	}
+
+	private void writeSQLCARD(boolean reuseCorrID, SQLException e,int severity, 
+		int updateCount, long rowCount ) throws DRDAProtocolException
+	{
+		writer.createDssObject(reuseCorrID);
+		writer.startDdm(CodePoint.SQLCARD);
+		writeSQLCAGRP(e, getSqlCode(severity), updateCount, rowCount);
+		writer.endDdmAndDss();
+
+		// If we have a shutdown exception, restart the server.
+		if (e != null) {
+			String sqlState = e.getSQLState();
+			if (sqlState.regionMatches(0,
+			  SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN, 0, 5)) {
+			// then we're here because of a shutdown exception;
+			// "clean up" by restarting the server.
+				try {
+					server.startDB2j();
+				} catch (Exception restart)
+				// any error messages should have already been printed,
+				// so we ignore this exception here.
+				{}
+			}
+		}
+
+	}
+
+	/**
+	 * Write a null SQLCARD as an object
+	 *
+ 	 * @exception DRDAProtocolException
+	 */
+	private void writeNullSQLCARDobject()
+		throws DRDAProtocolException
+	{
+		writer.createDssObject();
+		writer.startDdm(CodePoint.SQLCARD);
+		writeSQLCAGRP(null, 0, 0, 0);
+		writer.endDdmAndDss();
+	}
+	/**
+	 * Write SQLERRRM
+	 *
+	 * Instance Variables
+	 * 	SVRCOD - Severity Code - required
+ 	 *
+	 * @param	severity	severity of error
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void writeSQLERRRM(int severity) throws DRDAProtocolException
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.SQLERRRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, severity);
+		writer.endDdmAndDss ();
+
+	}
+	/**
+	 * Translate from Cloudscape exception severity to SVRCOD
+	 *
+	 * @param e SQLException
+	 */
+	private int getExceptionSeverity (SQLException e)
+	{
+		int severity= CodePoint.SVRCOD_INFO;
+
+		if (e == null)
+			return severity;
+
+		int ec = e.getErrorCode();
+		switch (ec)
+		{
+			case ExceptionSeverity.STATEMENT_SEVERITY:
+			case ExceptionSeverity.TRANSACTION_SEVERITY:
+				severity = CodePoint.SVRCOD_ERROR;
+				break;
+			case ExceptionSeverity.WARNING_SEVERITY:
+				severity = CodePoint.SVRCOD_WARNING;
+				break;
+			case ExceptionSeverity.SESSION_SEVERITY:
+			case ExceptionSeverity.DATABASE_SEVERITY:
+			case ExceptionSeverity.SYSTEM_SEVERITY:
+				severity = CodePoint.SVRCOD_SESDMG;
+				break;
+			default:
+				String sqlState = e.getSQLState();
+				if (sqlState != null && sqlState.startsWith("01"))		// warning
+					severity = CodePoint.SVRCOD_WARNING;
+				else
+					severity = CodePoint.SVRCOD_ERROR;
+		}
+
+		return severity;
+
+	}
+	/**
+	 * Write SQLCAGRP
+	 *
+	 * SQLCAGRP : FDOCA EARLY GROUP
+	 * SQL Communcations Area Group Description
+	 *
+	 * FORMAT FOR SQLAM <= 6
+	 *   SQLCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLSTATE; DRDA TYPE FCS; ENVLID 0x30; Length Override 5
+	 *   SQLERRPROC; DRDA TYPE FCS; ENVLID 0x30; Length Override 8
+	 *   SQLCAXGRP; DRDA TYPE N-GDA; ENVLID 0x52; Length Override 0
+	 *
+	 * FORMAT FOR SQLAM >= 7
+	 *   SQLCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLSTATE; DRDA TYPE FCS; ENVLID 0x30; Length Override 5
+	 *   SQLERRPROC; DRDA TYPE FCS; ENVLID 0x30; Length Override 8
+	 *   SQLCAXGRP; DRDA TYPE N-GDA; ENVLID 0x52; Length Override 0
+	 *   SQLDIAGGRP; DRDA TYPE N-GDA; ENVLID 0x56; Length Override 0
+	 *
+	 * @param e 	SQLException encountered
+	 * @param sqlcode	sqlcode
+	 * 
+	 * @exception DRDAProtocolException
+	 */
+	private void writeSQLCAGRP(SQLException e, int sqlcode, int updateCount,
+			long rowCount) throws DRDAProtocolException
+	{
+		String sqlerrmc;
+		String sqlState;
+		String severeExceptionInfo = null;
+		SQLException nextException = null;
+
+		if (rowCount < 0 && updateCount < 0)
+		{
+			writer.writeByte(CodePoint.NULLDATA);
+			return;
+		}
+		if (e == null)
+		{
+			sqlerrmc = null;
+			sqlState = "     "; // set to 5 blanks when no error
+		}
+		else {
+			if (sqlcode < 0)
+			{
+				if (SanityManager.DEBUG && server.debugOutput) 
+				{
+					trace("handle SQLException here");
+					trace("reason is: "+e.getMessage());
+					trace("SQLState is: "+e.getSQLState());
+					trace("vendorCode is: "+e.getErrorCode());
+					trace("nextException is: "+e.getNextException());
+					server.consoleExceptionPrint(e);
+					trace("wrapping SQLException into SQLCARD...");
+				}
+			}
+			sqlState = e.getSQLState();
+			if (e instanceof EmbedSQLException)
+			{
+				EmbedSQLException ce = (EmbedSQLException) e;
+				boolean severeException = (ce.getErrorCode() >=  ExceptionSeverity.SESSION_SEVERITY);
+				/* we need messageId to retrieve the localized message, just using
+				 * sqlstate may not be easy, because it is the messageId that we
+				 * used as key in the property file, for many sqlstates, they are
+				 * just the first 5 characters of the corresponding messageId.
+				 * We append messageId as the last element of sqlerrmc.  We can't
+				 * send messageId in the place of sqlstate because jcc expects only
+				 * 5 chars for sqlstate.
+				 */
+				sqlerrmc = "";
+				byte[] sep = {20};	// use it as separator of sqlerrmc tokens
+				byte[] errSep = {20, 20, 20};  // mark between exceptions
+				String separator = new String(sep);
+				String errSeparator = new String(errSep); 
+				String dbname = null;
+				if (database != null)
+					dbname = database.dbName;
+				
+				do {
+					String messageId = ce.getMessageId();
+					
+					// arguments are variable part of a message
+					Object[] args = ce.getArguments();
+					for (int i = 0; args != null &&  i < args.length; i++)
+						sqlerrmc += args[i].toString() + separator;
+					
+					// Severe exceptions need to be logged in the error log
+					// also log location and non-localized message will be
+					// returned to client as appended arguments
+					if (severeException)	
+					{
+						if (severeExceptionInfo == null)
+							severeExceptionInfo = "";
+						severeExceptionInfo += ce.getMessage() + separator;
+						println2Log(dbname, session.drdaID, ce.getMessage());
+					}
+					sqlerrmc += messageId; 	//append MessageId
+				
+					e = ce.getNextException();
+					if (e != null) {
+						if (e instanceof EmbedSQLException) {
+							ce = (EmbedSQLException)e;
+							sqlerrmc += errSeparator + ce.getSQLState() + ":";
+						}
+						else {
+							sqlerrmc += errSeparator + e.getSQLState() + ":";
+							ce = null;
+						}
+					}
+					else
+						ce = null;
+				} while (ce != null);
+						
+				if (severeExceptionInfo != null)
+				{
+					severeExceptionInfo += "(" + "server log:" +
+						server.getErrorLogLocation() + ")" ;
+					sqlerrmc += separator + severeExceptionInfo;
+				}
+			}
+			else
+				sqlerrmc = e.getMessage();
+		}
+
+		// Truncate the sqlerrmc to a length that the client can support.
+		int maxlen = (sqlerrmc == null) ? -1 : Math.min(sqlerrmc.length(),
+				appRequester.supportedMessageParamLength());
+		if ((maxlen >= 0) && (sqlerrmc.length() > maxlen))
+		// have to truncate so the client can handle it.
+			sqlerrmc = sqlerrmc.substring(0, maxlen);
+
+		//null indicator
+		writer.writeByte(0);
+
+		// SQLCODE
+		writer.writeInt(sqlcode);
+
+		// SQLSTATE
+		writer.writeString(sqlState);
+
+		// SQLERRPROC
+		writer.writeString(server.prdId);
+
+		// SQLCAXGRP
+		writeSQLCAXGRP(updateCount, rowCount, sqlerrmc, nextException);
+	}
+	/**
+	 * Write SQLCAXGRP
+	 *
+	 * SQLCAXGRP : EARLY FDOCA GROUP
+	 * SQL Communications Area Exceptions Group Description
+	 *
+	 * FORMAT FOR SQLAM <= 6
+	 *   SQLRDBNME; DRDA TYPE FCS; ENVLID 0x30; Length Override 18
+	 *   SQLERRD1; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD2; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD3; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD4; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD5; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD6; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLWARN0; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN1; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN2; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN3; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN4; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN5; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN6; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN7; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN8; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN9; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARNA; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70
+	 *   SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70
+	 *
+	 * FORMAT FOR SQLAM >= 7
+	 *   SQLERRD1; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD2; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD3; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD4; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD5; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLERRD6; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLWARN0; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN1; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN2; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN3; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN4; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN5; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN6; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN7; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN8; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARN9; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLWARNA; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
+	 *   SQLRDBNAME; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+	 *   SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70
+	 *   SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70
+	 * @param e 	SQLException encountered
+	 * @param sqlcode	sqlcode
+	 * 
+	 * @exception DRDAProtocolException
+	 */
+	private void writeSQLCAXGRP(int updateCount,  long rowCount, String sqlerrmc,
+				SQLException nextException) throws DRDAProtocolException
+	{
+		writer.writeByte(0);		// SQLCAXGRP INDICATOR
+		if (sqlamLevel < 7)
+		{
+			writeRDBNAM(database.dbName);
+			writeSQLCAERRWARN(updateCount, rowCount);
+		}
+		else
+		{
+			// SQL ERRD1 - D6, WARN0-WARNA (35 bytes)
+			writeSQLCAERRWARN(updateCount, rowCount);
+			writer.writeShort(0);  //CCC on Win does not take RDBNAME
+		}
+		writeVCMorVCS(sqlerrmc);
+		if (sqlamLevel >=7)
+			writeSQLDIAGGRP(nextException);
+	}
+
+	/**
+	 * Write the ERR and WARN part of the SQLCA
+	 *
+	 * @param updateCount
+	 * @param rowCount 
+	 */
+	private void writeSQLCAERRWARN(int updateCount, long rowCount) 
+	{
+		// SQL ERRD1 - ERRD2 - row Count
+		writer.writeInt((int)((rowCount>>>32))); 
+		writer.writeInt((int)(rowCount & 0x0000000ffffffffL));
+		// SQL ERRD3 - updateCount
+		writer.writeInt(updateCount);
+		// SQL ERRD4 - D6 (12 bytes)
+		byte[] byteArray = new byte[1];
+		byteArray[0] = 0;
+		writer.writeScalarPaddedBytes(byteArray, 12, (byte) 0);
+		// WARN0-WARNA (11 bytes)
+		byteArray[0] = ' ';  //CLI tests need this to be blank
+		writer.writeScalarPaddedBytes(byteArray, 11, (byte) ' ');
+	}
+
+	/**
+ 	 * Write SQLDIAGGRP: SQL Diagnostics Group Description - Identity 0xD1
+	 * Nullable Group
+	 * SQLDIAGSTT; DRDA TYPE N-GDA; ENVLID 0xD3; Length Override 0
+	 * SQLDIAGCN;  DRFA TYPE N-RLO; ENVLID 0xF6; Length Override 0
+	 * SQLDIAGCI;  DRDA TYPE N-RLO; ENVLID 0xF5; Length Override 0
+	 */
+	private void writeSQLDIAGGRP(SQLException nextException) 
+		throws DRDAProtocolException
+	{
+		writer.writeByte(CodePoint.NULLDATA);
+		return;
+
+		/**
+		 * TODO: Enable the following code when JCC can support SQLDIAGGRP
+		 * for all SQLCARD accesses. Commented out for now.
+		 */
+		/*
+		if (nextException == null)
+		{
+			writer.writeByte(CodePoint.NULLDATA);
+			return;
+		}
+
+		writeSQLDIAGSTT();
+		writeSQLDIAGCI(nextException);
+		writeSQLDIAGCN();
+		*/
+	}
+
+	/*
+	 * writeSQLDIAGSTT: Write NULLDATA for now
+	 */
+	private void writeSQLDIAGSTT()
+		throws DRDAProtocolException
+	{
+		writer.writeByte(CodePoint.NULLDATA);
+		return;
+	}
+
+	/**
+	 * writeSQLDIAGCI: SQL Diagnostics Condition Information Array - Identity 0xF5
+	 * SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 * SQLDCIROW; ROW LID 0xE5; ELEMENT TAKEN 0(all); REP FACTOR 0(all)
+	 */
+	private void writeSQLDIAGCI(SQLException nextException)
+		throws DRDAProtocolException
+	{
+		SQLException se = nextException;
+		long rowNum = 1;
+
+		/* Write the number of next exceptions to expect */
+		writeSQLNUMROW(se);
+
+		while (se != null)
+		{
+			String sqlState = se.getSQLState();
+			int sqlCode = getSqlCode(getExceptionSeverity(se));
+			String sqlerrmc = "";
+			byte[] sep = {20};	// use it as separator of sqlerrmc tokens
+			String separator = new String(sep);
+				
+			// arguments are variable part of a message
+			Object[] args = ((EmbedSQLException)se).getArguments();
+			for (int i = 0; args != null &&  i < args.length; i++)
+				sqlerrmc += args[i].toString() + separator;
+
+			String dbname = null;
+			if (database != null)
+				dbname = database.dbName;
+
+			writeSQLDCROW(rowNum++, sqlCode, sqlState, dbname, sqlerrmc);
+
+			se = se.getNextException();
+		}
+			
+		writer.writeByte(CodePoint.NULLDATA);
+		return;
+	}
+
+	/**
+	 * writeSQLNUMROW: Writes SQLNUMROW : FDOCA EARLY ROW
+	 * SQL Number of Elements Row Description
+	 * FORMAT FOR SQLAM LEVELS
+	 * SQLNUMGRP; GROUP LID 0x58; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 */
+	private void writeSQLNUMROW(SQLException nextException)
+		 throws DRDAProtocolException
+	{
+		writeSQLNUMGRP(nextException);
+	}
+
+	/**
+	 * writeSQLNUMGRP: Writes SQLNUMGRP : FDOCA EARLY GROUP
+	 * SQL Number of Elements Group Description
+	 * FORMAT FOR ALL SQLAM LEVELS
+	 * SQLNUM; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 */
+	private void writeSQLNUMGRP(SQLException nextException)
+		 throws DRDAProtocolException
+	{
+		int i=0;
+		SQLException se;
+
+		/* Count the number of chained exceptions to be sent */
+		for (se = nextException; se != null; se = se.getNextException()) i++;
+		writer.writeInt(i);
+	}
+
+	/**
+	 * writeSQLDCROW: SQL Diagnostics Condition Row - Identity 0xE5
+	 * SQLDCGRP; GROUP LID 0xD5; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 */
+	private void writeSQLDCROW(long rowNum, int sqlCode, String sqlState, String dbname,
+		 String sqlerrmc) throws DRDAProtocolException
+	{
+		writeSQLDCGRP(rowNum, sqlCode, sqlState, dbname, sqlerrmc);
+	}
+
+	/**
+	 * writeSQLDCGRP: SQL Diagnostics Condition Group Description
+	 * 
+	 * SQLDCCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCSTATE; DRDA TYPE FCS; ENVLID Ox30; Lengeh Override 5
+	 * SQLDCREASON; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCLINEN; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCROWN; DRDA TYPE FD; ENVLID 0x0E; Lengeh Override 31
+	 * SQLDCER01; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCER02; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCER03; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCER04; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCPART; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCPPOP; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 * SQLDCMSGID; DRDA TYPE FCS; ENVLID 0x30; Length Override 10
+	 * SQLDCMDE; DRDA TYPE FCS; ENVLID 0x30; Length Override 8
+	 * SQLDCPMOD; DRDA TYPE FCS; ENVLID 0x30; Length Override 5
+	 * SQLDCRDB; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+	 * SQLDCTOKS; DRDA TYPE N-RLO; ENVLID 0xF7; Length Override 0
+	 * SQLDCMSG_m; DRDA TYPE NVMC; ENVLID 0x3F; Length Override 32672
+	 * SQLDCMSG_S; DRDA TYPE NVCS; ENVLID 0x33; Length Override 32672
+	 * SQLDCCOLN_m; DRDA TYPE NVCM ; ENVLID 0x3F; Length Override 255
+	 * SQLDCCOLN_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255
+	 * SQLDCCURN_m; DRDA TYPE NVCM; ENVLID 0x3F; Length Override 255
+	 * SQLDCCURN_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255
+	 * SQLDCPNAM_m; DRDA TYPE NVCM; ENVLID 0x3F; Length Override 255
+	 * SQLDCPNAM_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255
+	 * SQLDCXGRP; DRDA TYPE N-GDA; ENVLID 0xD3; Length Override 1
+	 */
+	private void writeSQLDCGRP(long rowNum, int sqlCode, String sqlState, String dbname,
+		 String sqlerrmc) throws DRDAProtocolException
+	{
+		// SQLDCCODE
+		writer.writeInt(sqlCode);
+
+		// SQLDCSTATE
+		writer.writeString(sqlState);
+
+
+		writer.writeInt(0);						// REASON_CODE
+		writer.writeInt(0);						// LINE_NUMBER
+		writer.writeLong(rowNum);				// ROW_NUMBER
+
+		byte[] byteArray = new byte[1];
+		writer.writeScalarPaddedBytes(byteArray, 47, (byte) 0);
+
+		writer.writeShort(0);					// CCC on Win does not take RDBNAME
+		writer.writeByte(CodePoint.NULLDATA);	// MESSAGE_TOKENS
+		writer.writeLDString(sqlerrmc);			// MESSAGE_TEXT
+
+		writeVCMorVCS(null);					// COLUMN_NAME
+		writeVCMorVCS(null);					// PARAMETER_NAME
+		writeVCMorVCS(null);					// EXTENDED_NAME
+		writer.writeByte(CodePoint.NULLDATA);	// SQLDCXGRP
+	}
+
+	/*
+	 * writeSQLDIAGCN: Write NULLDATA for now
+	 */
+	private void writeSQLDIAGCN()
+		throws DRDAProtocolException
+	{
+		writer.writeByte(CodePoint.NULLDATA);
+		return;
+	}
+
+	/** 
+	 * Write SQLDARD
+	 *
+	 * SQLDARD : FDOCA EARLY ARRAY
+	 * SQL Descriptor Area Row Description with SQL Communications Area
+	 *
+	 * FORMAT FOR SQLAM <= 6
+	 *   SQLCARD; ROW LID 0x64; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 *   SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 *   SQLDAROW; ROW LID 0x60; ELEMENT TAKEN 0(all); REP FACTOR 0(all)
+	 *
+	 * FORMAT FOR SQLAM >= 7
+	 *   SQLCARD; ROW LID 0x64; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 *   SQLDHROW; ROW LID 0xE0; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 *   SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1
+	 *
+	 * @param ps prepared statement
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeSQLDARD(DRDAStatement stmt, boolean rtnOutput, SQLException e) throws DRDAProtocolException, SQLException
+	{
+		PreparedStatement ps = stmt.getPreparedStatement();
+		ResultSetMetaData rsmeta = ps.getMetaData();
+		EmbedParameterSetMetaData pmeta = ((EmbedPreparedStatement) ps).getEmbedParameterSetMetaData();
+		int numElems = 0;
+		if (e == null || e instanceof SQLWarning)
+		{
+			if (rtnOutput && (rsmeta != null))
+				numElems = rsmeta.getColumnCount();
+			else if ((! rtnOutput) && (pmeta != null))
+				numElems = pmeta.getParameterCount();
+		}
+
+		writer.createDssObject(false);
+
+		// all went well we will just write a null SQLCA
+		writer.startDdm(CodePoint.SQLDARD);
+		writeSQLCAGRP(e, getSqlCode(getExceptionSeverity(e)), 0, 0);
+
+		if (sqlamLevel >= MGRLVL_7)
+			writeSQLDHROW (stmt);
+
+		//SQLNUMROW
+		if (SanityManager.DEBUG) 
+			trace("num Elements = " + numElems);
+		writer.writeShort(numElems);
+
+		for (int i=0; i < numElems; i++)
+			writeSQLDAGRP (rsmeta, pmeta, i, rtnOutput);
+		writer.endDdmAndDss();
+
+	}
+	/**
+	 * Write QRYDSC - Query Answer Set Description
+	 *
+	 * @param stmt			associated statement
+	 * @param FDODSConly	simply the FDODSC, without the wrap
+	 *
+	 * Instance Variables
+	 *   SQLDTAGRP - required
+	 * 
+	 * Only 84 columns can be sent in a single QRYDSC.  If there are more columns
+	 * they must be sent in subsequent QRYDSC.
+	 * If the QRYDSC will not fit into the current block, as many columns as can
+	 * fit are sent and then the remaining are sent in the following blocks.
+	 * @param stmt DRDAStatement we are working on
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeQRYDSC(DRDAStatement stmt, boolean FDODSConly)
+		throws DRDAProtocolException, SQLException
+	{
+
+		ResultSet rs = null;
+		ResultSetMetaData rsmeta = null;
+		EmbedParameterSetMetaData pmeta = null;
+		if (!stmt.needsToSendParamData)
+			rs = stmt.getResultSet();
+		if (rs == null)		// this is a CallableStatement, use parameter meta data
+			pmeta = ((EmbedPreparedStatement) stmt.ps).getEmbedParameterSetMetaData();
+		else
+			rsmeta = rs.getMetaData();
+
+	    int  numCols = (rsmeta != null ? rsmeta.getColumnCount() : pmeta.getParameterCount());
+		int numGroups = 1;
+		int colStart = 1;
+		int colEnd = numCols;
+		int blksize = stmt.getBlksize() > 0 ? stmt.getBlksize() : CodePoint.QRYBLKSZ_MAX;
+
+		// check for remaining space in current query block
+		// Need to mod with blksize so remaining doesn't go negative. 4868
+		int remaining = blksize - (writer.getOffset()  % blksize) - (3 + 
+				FdocaConstants.SQLCADTA_SQLDTARD_RLO_SIZE);
+
+
+		// calcuate how may columns can be sent in the current query block
+		int firstcols = remaining/FdocaConstants.SQLDTAGRP_COL_DSC_SIZE;
+
+		// check if it doesn't all fit into the first block and 
+		//	under FdocaConstants.MAX_VARS_IN_NGDA
+		if (firstcols < numCols || numCols > FdocaConstants.MAX_VARS_IN_NGDA)
+		{
+			// we are limited to FdocaConstants.MAX_VARS_IN_NGDA
+			if (firstcols > FdocaConstants.MAX_VARS_IN_NGDA)
+			{
+				if (SanityManager.DEBUG)
+					SanityManager.ASSERT(numCols > FdocaConstants.MAX_VARS_IN_NGDA,
+						"Number of columns " + numCols + 
+						" is less than MAX_VARS_IN_NGDA");
+				numGroups = numCols/FdocaConstants.MAX_VARS_IN_NGDA;
+				// some left over
+				if (FdocaConstants.MAX_VARS_IN_NGDA * numGroups < numCols)
+					numGroups++;
+				colEnd = FdocaConstants.MAX_VARS_IN_NGDA;
+			}
+			else
+			{
+				colEnd = firstcols;
+				numGroups += (numCols-firstcols)/FdocaConstants.MAX_VARS_IN_NGDA;
+				if (FdocaConstants.MAX_VARS_IN_NGDA * numGroups < numCols)
+					numGroups++;
+			}
+		}
+
+		if (! FDODSConly)
+		{
+			writer.createDssObject();
+			writer.startDdm(CodePoint.QRYDSC);
+		}
+
+		for (int i = 0; i < numGroups; i++)
+		{
+			writeSQLDTAGRP(stmt, rsmeta, pmeta, colStart, colEnd, 
+							(i == 0 ? true : false));
+			colStart = colEnd + 1;
+			// 4868 - Limit range to MAX_VARS_IN_NGDA (used to have extra col)
+			colEnd = colEnd + FdocaConstants.MAX_VARS_IN_NGDA;
+			if (colEnd > numCols)
+				colEnd = numCols;
+		}
+		writer.writeBytes(FdocaConstants.SQLCADTA_SQLDTARD_RLO);
+		if (! FDODSConly)
+			writer.endDdmAndDss();
+	}
+	/**
+	 * Write SQLDTAGRP
+	 * SQLDAGRP : Late FDOCA GROUP
+	 * SQL Data Value Group Descriptor
+	 *  LENGTH - length of the SQLDTAGRP
+	 *  TRIPLET_TYPE - NGDA for first, CPT for following
+	 *  ID - SQLDTAGRP_LID for first, NULL_LID for following
+	 *  For each column
+	 *    DRDA TYPE 
+	 *	  LENGTH OVERRIDE
+	 *	    For numeric/decimal types
+	 *		  PRECISON
+	 *		  SCALE
+	 *	    otherwise
+	 *		  LENGTH or DISPLAY_WIDTH
+	 *
+	 * @param stmt		drda statement
+	 * @param rsmeta	resultset meta data
+	 * @param pmeta		parameter meta data for CallableStatement
+	 * @param colStart	starting column for group to send
+	 * @param colEnd	end column to send
+	 * @param first		is this the first group
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeSQLDTAGRP(DRDAStatement stmt, ResultSetMetaData rsmeta, 
+								EmbedParameterSetMetaData pmeta,
+								int colStart, int colEnd, boolean first)
+		throws DRDAProtocolException, SQLException
+	{
+
+		int length =  (FdocaConstants.SQLDTAGRP_COL_DSC_SIZE * 
+					((colEnd+1) - colStart)) + 3;
+		writer.writeByte(length);
+		if (first)
+		{
+
+			writer.writeByte(FdocaConstants.NGDA_TRIPLET_TYPE);
+			writer.writeByte(FdocaConstants.SQLDTAGRP_LID);
+		}
+		else
+		{
+			//continued
+			writer.writeByte(FdocaConstants.CPT_TRIPLET_TYPE);
+			writer.writeByte(FdocaConstants.NULL_LID);
+
+		}
+
+						   
+
+		boolean hasRs = (rsmeta != null);	//  if don't have result, then we look at parameter meta
+
+		for (int i = colStart; i <= colEnd; i++)
+		{
+			boolean nullable = (hasRs ? (rsmeta.isNullable(i) == rsmeta.columnNullable) :
+												 (pmeta.isNullable(i) == JDBC30Translation.PARAMETER_NULLABLE));
+			int colType = (hasRs ? rsmeta.getColumnType(i) : pmeta.getParameterType(i));
+			int[] outlen = {-1};
+			int drdaType = (hasRs ?FdocaConstants.mapJdbcTypeToDrdaType(colType,nullable,outlen): 
+								stmt.getParamDRDAType(i));
+
+			boolean isDecimal = ((drdaType | 1) == FdocaConstants.DRDA_TYPE_NDECIMAL);
+			int precision = 0, scale = 0;
+			if (hasRs)
+			{
+				precision = rsmeta.getPrecision(i);
+				scale = rsmeta.getScale(i);
+				stmt.setRsDRDAType(i,drdaType);			
+				stmt.setRsPrecision(i, precision);
+				stmt.setRsScale(i,scale);
+			}
+
+			else if (isDecimal)
+			{
+				if (stmt.isOutputParam(i))
+					((CallableStatement) stmt.ps).registerOutParameter(i,Types.DECIMAL);
+				precision = pmeta.getPrecision(i);
+				scale = pmeta.getScale(i);
+
+			}
+
+			if (SanityManager.DEBUG)
+				trace("jdbcType=" + colType + "  \tdrdaType=" + Integer.toHexString(drdaType));
+
+			// Length or precision and scale for decimal values.
+			writer.writeByte(drdaType);
+			if (isDecimal)
+			{
+				writer.writeByte(precision);
+				writer.writeByte(scale);
+			}
+			else if (outlen[0] != -1)
+				writer.writeShort(outlen[0]);
+			else if (hasRs)
+				writer.writeShort(rsmeta.getColumnDisplaySize(i));
+			else
+				writer.writeShort(stmt.getParamLen(i));
+		}
+	}
+
+
+
+	//pass PreparedStatement here so we can send correct holdability on the wire for jdk1.3 and higher
+	//For jdk1.3, we provide hold cursor support through reflection.
+	private void writeSQLDHROW (DRDAStatement stmt) throws DRDAProtocolException,SQLException
+	{
+		ResultSet rs = null;
+		EmbedStatement rsstmt;
+		if (!stmt.needsToSendParamData)
+			rs = stmt.getResultSet();
+		
+		if (rs != null)
+			rsstmt = (EmbedStatement) rs.getStatement();
+		else
+			rsstmt = (EmbedStatement) stmt.getPreparedStatement();
+
+		if (JVMInfo.JDK_ID < 2) //write null indicator for SQLDHROW because there is no holdability support prior to jdk1.3
+		{
+			writer.writeByte(CodePoint.NULLDATA);
+			return;
+		}
+
+		writer.writeByte(0);		// SQLDHROW INDICATOR
+
+		//SQLDHOLD
+		writer.writeShort(rsstmt.getResultSetHoldability());
+		
+		//SQLDRETURN
+		writer.writeShort(0);
+		//SQLDSCROLL
+		writer.writeShort(0);
+		//SQLDSENSITIVE
+		writer.writeShort(0);
+		//SQLDFCODE
+		writer.writeShort(0);
+		//SQLDKEYTYPE
+		writer.writeShort(0);
+		//SQLRDBNAME
+		writer.writeShort(0);	//CCC on Windows somehow does not take any dbname
+		//SQLDSCHEMA
+		writeVCMorVCS(null);
+
+	}
+
+	/**
+	 * Write QRYDTA - Query Answer Set Data
+	 *  Contains some or all of the answer set data resulting from a query
+	 *  returns true if there is more data, false if we reached the end
+	 * Instance Variables
+	 *   Byte string
+	 *
+	 * @param stmt	DRDA statement we are processing
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeQRYDTA (DRDAStatement stmt) 
+		throws DRDAProtocolException, SQLException
+	{
+		boolean getMoreData = true;
+		boolean sentExtData = false;
+		int startOffset = writer.getOffset();
+		writer.createDssObject();
+
+		if (SanityManager.DEBUG) 
+			trace("Write QRYDTA");
+		writer.startDdm(CodePoint.QRYDTA);
+		
+		while(getMoreData)
+		{			
+			sentExtData = false;
+			getMoreData = writeFDODTA(stmt);
+
+			if (stmt.getExtDtaObjects() != null)
+			{
+				writer.endDdm();
+				writeEXTDTA(stmt);
+				getMoreData=false;
+				sentExtData = true;
+			}
+
+			// if we don't have enough room for a row of the 
+			// last row's size, don't try to cram it in.
+			// It would get split up but it is not very efficient.
+			if (getMoreData == true)
+			{
+				int endOffset = writer.getOffset();
+				int rowsize = endOffset- startOffset;
+				if ((stmt.getBlksize() - endOffset ) < rowsize)
+					getMoreData = false;
+
+			}
+
+		}
+		// If we sent extDta we will rely on
+		// writeScalarStream to end the dss with the proper chaining.
+		// otherwise end it here.
+		if (! sentExtData)
+			writer.endDdmAndDss();
+
+		if( (!stmt.hasdata()) &&
+			stmt.getQryclsimp() != CodePoint.QRYCLSIMP_NO &&
+			stmt.getQryprctyp() != CodePoint.LMTBLKPRC)
+			stmt.rsClose();
+		
+	}
+
+	private boolean writeFDODTA (DRDAStatement stmt) 
+		throws DRDAProtocolException, SQLException
+	{
+		boolean hasdata = false;
+		int blksize = stmt.getBlksize() > 0 ? stmt.getBlksize() : CodePoint.QRYBLKSZ_MAX;
+		long rowCount = 0;
+		ResultSet rs =null;
+		boolean moreData = (stmt.getQryprctyp()
+							== CodePoint.LMTBLKPRC);
+		int  numCols;
+
+		if (!stmt.needsToSendParamData)
+		{
+			rs = stmt.getResultSet();
+		}
+
+		if (rs != null)
+		{
+			numCols = stmt.getNumRsCols();					
+			if (stmt.getScrollType() != 0)
+				hasdata = positionCursor(stmt, rs);
+			else
+				hasdata = rs.next();
+
+		}
+		else	// it's for a CallableStatement
+		{
+			hasdata = stmt.hasOutputParams();
+			numCols = stmt.getNumParams();
+		}
+
+
+		do {
+			if (!hasdata)
+			{
+				doneData(stmt, rs);
+				moreData = false;
+				return moreData;
+			}
+			
+			// Send ResultSet warnings if there are any
+			SQLWarning sqlw = (rs != null)? rs.getWarnings(): null;
+			if (sqlw == null)
+				writeSQLCAGRP(null, 0, -1, -1);
+			else
+				writeSQLCAGRP(sqlw, sqlw.getErrorCode(), 1, -1);
+
+			// if we were asked not to return data, mark QRYDTA null; do not
+			// return yet, need to make rowCount right
+			boolean noRetrieveRS = (rs != null && !stmt.getQryrtndta());
+			if (noRetrieveRS)
+				writer.writeByte(0xFF);  //QRYDTA null indicator: IS NULL
+			else
+				writer.writeByte(0);  //QRYDTA null indicator: not null
+
+			for (int i = 1; i <= numCols; i++)
+			{
+				if (noRetrieveRS)
+					break;
+
+				int drdaType;
+				int ndrdaType;
+				int precision;
+				int scale;
+
+				Object val = null;
+				boolean valNull;
+				if (rs != null)
+				{
+					drdaType =   stmt.getRsDRDAType(i) & 0xff;
+					precision = stmt.getRsPrecision(i);
+					scale = stmt.getRsScale(i);
+					ndrdaType = drdaType | 1;
+
+					if (SanityManager.DEBUG)
+						trace("!!drdaType = " + java.lang.Integer.toHexString(drdaType) + 
+					 			 "precision = " + precision +" scale = " + scale);
+					switch (ndrdaType)
+					{
+						case FdocaConstants.DRDA_TYPE_NLOBBYTES:
+							writeFdocaVal(i,rs.getBlob(i),drdaType,
+										  precision,scale,rs.wasNull(),stmt);
+							break;
+						case  FdocaConstants.DRDA_TYPE_NLOBCMIXED:
+							writeFdocaVal(i,rs.getClob(i),drdaType,
+										  precision,scale,rs.wasNull(),stmt);
+							break;
+						case FdocaConstants.DRDA_TYPE_NINTEGER:
+							int ival = rs.getInt(i);
+							valNull = rs.wasNull();
+							if (SanityManager.DEBUG)
+								trace("====== writing int: "+ ival + " is null: " + valNull);
+							writeNullability(drdaType,valNull);
+							if (! valNull)
+								writer.writeInt(ival);
+							break;
+						case FdocaConstants.DRDA_TYPE_NSMALL:
+							short sval = rs.getShort(i);
+							valNull = rs.wasNull();
+							if (SanityManager.DEBUG)
+								trace("====== writing small: "+ sval + " is null: " + valNull);
+							writeNullability(drdaType,valNull);
+							if (! valNull)
+								writer.writeShort(sval);
+							break;
+						case FdocaConstants.DRDA_TYPE_NINTEGER8:
+							long lval = rs.getLong(i);
+							valNull = rs.wasNull();
+							if (SanityManager.DEBUG)
+								trace("====== writing long: "+ lval + " is null: " + valNull);
+							writeNullability(drdaType,valNull);
+							if (! valNull)
+								writer.writeLong(lval);
+							break;
+						case FdocaConstants.DRDA_TYPE_NFLOAT4:
+							float fval = rs.getFloat(i);
+							valNull = rs.wasNull();
+							if (SanityManager.DEBUG)
+								trace("====== writing float: "+ fval + " is null: " + valNull);
+							writeNullability(drdaType,valNull);
+							if (! valNull)
+								writer.writeFloat(fval);
+							break;
+						case FdocaConstants.DRDA_TYPE_NFLOAT8:
+							double dval = rs.getDouble(i);
+							valNull = rs.wasNull();
+							if (SanityManager.DEBUG)
+								trace("====== writing double: "+ dval + " is null: " + valNull);
+							writeNullability(drdaType,valNull);
+							if (! valNull)
+								writer.writeDouble(dval);
+							break;
+						case FdocaConstants.DRDA_TYPE_NCHAR:
+						case FdocaConstants.DRDA_TYPE_NVARCHAR:
+						case FdocaConstants.DRDA_TYPE_NVARMIX:
+						case FdocaConstants.DRDA_TYPE_NLONG:
+						case FdocaConstants.DRDA_TYPE_NLONGMIX:
+							String valStr = rs.getString(i);
+							if (SanityManager.DEBUG)
+								trace("====== writing char/varchar/mix :"+ valStr + ":");
+							writeFdocaVal(i, valStr, drdaType,
+										  precision,scale,rs.wasNull(),stmt);
+							break;
+						default:
+							writeFdocaVal(i, rs.getObject(i),drdaType,
+										  precision,scale,rs.wasNull(),stmt);
+					}
+				}
+				else
+				{
+					drdaType =   stmt.getParamDRDAType(i) & 0xff;
+					precision = stmt.getParamPrecision(i);
+					scale = stmt.getParamScale(i);
+					ndrdaType = drdaType | 1;
+					
+					if (stmt.isOutputParam(i)) {
+						if (SanityManager.DEBUG)
+							trace("***getting Object "+i);
+						val = ((CallableStatement) stmt.ps).getObject(i);
+						valNull = (val == null);
+						writeFdocaVal(i,val,drdaType,precision, scale, valNull,stmt);
+					}
+					else
+						writeFdocaVal(i,null,drdaType,precision,scale,true,stmt);
+
+				}
+			}
+			// does all this fit in one QRYDTA
+			if (writer.getOffset() >= blksize)
+			{
+				splitQRYDTA(stmt, blksize);
+				moreData = false;
+			}
+
+			if (rs == null)
+				return moreData;
+
+			//get the next row
+			rowCount++;
+			if (rowCount < stmt.getQryrowset())
+			{
+				hasdata = rs.next();
+			}
+			/*(1) scrollable we return at most a row set; OR (2) no retrieve data
+			 */
+			else if (stmt.getScrollType() != 0 || noRetrieveRS)
+				moreData=false;
+
+		} while (hasdata && rowCount < stmt.getQryrowset());
+
+		// add rowCount to statement row count
+		// for non scrollable cursors
+		if (stmt.getScrollType() == 0)
+			stmt.rowCount += rowCount;
+
+		if (!hasdata)
+		{
+			doneData(stmt, rs);
+			moreData=false;
+		}
+
+		if (stmt.getScrollType() == 0)
+			stmt.setHasdata(hasdata);
+		return moreData;
+	}
+	/**
+	 * Split QRYDTA into blksize chunks
+	 *
+	 * @param stmt DRDA statment
+	 * @param blksize size of query block
+	 * 
+	 * @exception SQLException, DRDAProtocolException
+	 */
+	private void splitQRYDTA(DRDAStatement stmt, int blksize) throws SQLException, 
+			DRDAProtocolException
+	{
+		// make copy of extra data
+		byte [] temp = writer.copyDataToEnd(blksize);
+		// truncate to end of blocksize
+		writer.setOffset(blksize);
+		int remain = temp.length;
+		int start = 0;
+		int dataLen = blksize - 10; //DSS header + QRYDTA and length
+		while (remain > 0)
+		{
+			// finish off query block and send
+			writer.endDdmAndDss();
+			send();
+			// read CNTQRY - not sure why JCC sends this
+			correlationID = reader.readDssHeader();
+			int codePoint = reader.readLengthAndCodePoint();
+			DRDAStatement contstmt = parseCNTQRY();
+			if (stmt != contstmt)
+				agentError("continued query stmt not the same");
+			// start a new query block for the next row
+			writer.createDssObject();
+			writer.startDdm(CodePoint.QRYDTA);
+			// write out remaining data
+			if (remain > blksize)
+			{
+				writer.writeBytes(temp, start, dataLen);
+				remain -= dataLen; //DSS header + QRYDTA and length
+				start += dataLen;
+			}
+			else
+			{
+				writer.writeBytes(temp, start, remain);
+				remain = 0;
+			}
+		}
+	}
+	/**
+	 * Done data
+	 * Send SQLCARD for the end of the data
+	 * 
+	 * @param stmt DRDA statement
+	 * @param rs Result set
+	 * @exception DRDAProtocolException,SQLException
+	 */
+	private void doneData(DRDAStatement stmt, ResultSet rs) 
+			throws DRDAProtocolException, SQLException
+	{
+		if (SanityManager.DEBUG) 
+			trace("*****NO MORE DATA!!");
+		int blksize = stmt.getBlksize() > 0 ? stmt.getBlksize() : CodePoint.QRYBLKSZ_MAX;
+		if (rs != null)
+		{
+			if (stmt.getScrollType() != 0)
+			{
+				// for scrollable cursors - calculate the row count
+				// since we may not have gone through each row
+				rs.last();
+				stmt.rowCount  = rs.getRow();
+				//reposition after last
+				rs.afterLast();
+			}
+			else  // non-scrollable cursor
+			{
+				// for QRYCLSIMP_YES or SERVER_CHOICE close the rs
+				int qryclsimp = stmt.getQryclsimp();
+				if (qryclsimp != CodePoint.QRYCLSIMP_NO &&
+					//For LMTBLKPRC, we reach the end early, but cursor should
+					//not be closed prematurely.
+					stmt.getQryprctyp()
+										!= CodePoint.LMTBLKPRC)
+				{
+					stmt.rsClose();
+					stmt.rsSuspend();
+				}
+			 
+			}
+		}
+
+		// For scrollable cursor's QRYSCRAFT, when we reach here, DRDA spec says sqlstate
+		// is 00000, sqlcode is not mentioned.  But DB2 CLI code expects sqlcode to be 0.
+		// We return sqlcode 0 in this case, as the DB2 server does.
+		boolean isQRYSCRAFT = (stmt.getQryscrorn() == CodePoint.QRYSCRAFT);
+
+		// sqlstate 02000 for end of data.
+		// RESOLVE: Need statics for sqlcodes.
+		writeSQLCAGRP(new SQLException("End of Data", (isQRYSCRAFT ? "00000" : "02000")),
+							(isQRYSCRAFT ? 0 : 100), 0, stmt.rowCount);
+
+		writer.writeByte(CodePoint.NULLDATA);
+		// does all this fit in one QRYDTA
+		if (writer.getOffset() >= blksize)
+		{
+			splitQRYDTA(stmt, blksize);
+		}
+	}
+	/**
+	 * Position cursor for insensitive scrollable cursors
+	 *
+	 * @param stmt	DRDA statement 
+	 * @param rs	Result set
+	 */
+	private boolean positionCursor(DRDAStatement stmt, ResultSet rs) 
+		throws SQLException, DRDAProtocolException
+	{
+		boolean retval = false;
+		switch (stmt.getQryscrorn())
+		{
+			case CodePoint.QRYSCRREL:
+				//we aren't on a row - go to first row
+				//JCC seems to use relative 1 to get to the first row
+				//JDBC doesn't allow you to use relative unless you are on
+				//a valid row so we cheat here.
+				if (rs.isBeforeFirst() || rs.isAfterLast())
+					retval = rs.first();
+				else
+					retval = rs.relative((int)stmt.getQryrownbr());
+				break;
+			case CodePoint.QRYSCRABS:
+				// JCC uses an absolute value of 0 which is not allowed in JDBC
+				// We translate it into beforeFirst which seems to work.
+				if (stmt.getQryrownbr() == 0)
+				{
+					rs.beforeFirst();
+					retval = false;
+				}
+				else
+				{
+					retval = rs.absolute((int)stmt.getQryrownbr());
+				}
+				break;
+			case CodePoint.QRYSCRAFT:
+				rs.afterLast();
+				retval = false;
+				break;
+			case CodePoint.QRYSCRBEF:
+				rs.beforeFirst();
+				retval = false;
+				break;
+			default:      
+				agentError("Invalid value for cursor orientation "+ stmt.getQryscrorn());
+		}
+		return retval;
+	}
+	/**
+	 * Write SQLDAGRP
+	 * SQLDAGRP : EARLY FDOCA GROUP
+	 * SQL Data Area Group Description
+	 *
+	 * FORMAT FOR SQLAM <= 6
+	 *   SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLLENGTH; DRDA TYPE I4; ENVLID 0x02; Length Override 4
+	 *   SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2
+	 *   SQLNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30
+	 *   SQLNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30
+	 *   SQLLABEL_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30
+	 *   SQLLABEL_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30
+	 *   SQLCOMMENTS_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 254
+	 *   SQLCOMMENTS_m; DRDA TYPE VCS; ENVLID 0x32; Length Override 254
+	 *
+	 * FORMAT FOR SQLAM == 6
+	 *   SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLLENGTH; DRDA TYPE I8; ENVLID 0x16; Length Override 8
+	 *   SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2
+	 *   SQLNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30
+	 *   SQLNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30
+	 *   SQLLABEL_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30
+	 *   SQLLABEL_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30
+	 *   SQLCOMMENTS_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 254
+	 *   SQLCOMMENTS_m; DRDA TYPE VCS; ENVLID 0x32; Length Override 254
+	 *   SQLUDTGRP; DRDA TYPE N-GDA; ENVLID 0x51; Length Override 0
+	 *
+	 * FORMAT FOR SQLAM >= 7
+	 *   SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLLENGTH; DRDA TYPE I8; ENVLID 0x16; Length Override 8
+	 *   SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+	 *   SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2
+	 *   SQLDOPTGRP; DRDA TYPE N-GDA; ENVLID 0xD2; Length Override 0
+	 *
+	 * @param rsmeta	resultset meta data
+	 * @param pmeta		parameter meta data
+	 * @param elemNum	column number we are returning (in case of result set), or,
+	 *					parameter number (in case of parameter)
+	 * @param rtnOutput	whether this is for a result set	
+	 *
+	 * @exception DRDAProtocolException, SQLException
+	 */
+	private void writeSQLDAGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int elemNum, boolean rtnOutput)
+		throws DRDAProtocolException, SQLException
+	{
+		//jdbc uses offset of 1
+
+		int jdbcElemNum = elemNum +1;
+		// length to be retreived as output parameter
+		int[]  outlen = {-1};  
+
+		int elemType = rtnOutput ? rsmeta.getColumnType(jdbcElemNum) : pmeta.getParameterType(jdbcElemNum);
+
+		int precision = rtnOutput ? rsmeta.getPrecision(jdbcElemNum) : pmeta.getPrecision(jdbcElemNum);
+		if (precision > FdocaConstants.NUMERIC_MAX_PRECISION)
+			precision = FdocaConstants.NUMERIC_MAX_PRECISION;
+
+		// 2-byte precision
+		writer.writeShort(precision);
+		// 2-byte scale
+		int scale = (rtnOutput ? rsmeta.getScale(jdbcElemNum) : pmeta.getScale(jdbcElemNum));
+		writer.writeShort(scale);
+
+		boolean nullable = rtnOutput ? (rsmeta.isNullable(jdbcElemNum) ==
+										ResultSetMetaData.columnNullable) : 
+			(pmeta.isNullable(jdbcElemNum) == JDBC30Translation.PARAMETER_NULLABLE);
+		
+		int sqlType = SQLTypes.mapJdbcTypeToDB2SqlType(elemType,
+													   nullable,
+													   outlen);
+		
+		if (outlen[0] == -1) //some types not set
+		{
+			switch (elemType)
+			{
+				case Types.DECIMAL:
+				case Types.NUMERIC:
+					scale = rtnOutput ? rsmeta.getScale(jdbcElemNum) : pmeta.getScale(jdbcElemNum);
+					outlen[0] = ((precision <<8) | (scale <<0));
+					if (SanityManager.DEBUG) 
+						trace("\n\nprecision =" +precision +
+						  " scale =" + scale);
+					break;
+				default:
+					outlen[0] = Math.min(FdocaConstants.LONGVARCHAR_MAX_LEN,
+										(rtnOutput ? rsmeta.getColumnDisplaySize(jdbcElemNum) :
+												pmeta.getPrecision(jdbcElemNum)));
+			}
+		}
+
+		switch (elemType)
+		{
+			case Types.BINARY:
+			case Types.VARBINARY:
+			case Types.LONGVARBINARY:
+			case Types.BLOB:			//for CLI describe to be correct
+			case Types.CLOB:
+				outlen[0] = (rtnOutput ? rsmeta.getPrecision(jdbcElemNum) :
+											pmeta.getPrecision(jdbcElemNum));
+		}
+
+		if (SanityManager.DEBUG) 
+			trace("SQLDAGRP len =" + java.lang.Integer.toHexString(outlen[0]) + "for type:" + elemType);
+
+	   // 8 or 4 byte sqllength
+		if (sqlamLevel >= MGRLVL_6)
+			writer.writeLong(outlen[0]);
+		else
+			writer.writeInt(outlen[0]);
+
+
+		String typeName = rtnOutput ? rsmeta.getColumnTypeName(jdbcElemNum) :
+										pmeta.getParameterTypeName(jdbcElemNum);
+		if (SanityManager.DEBUG) 
+			trace("jdbcType =" + typeName + "  sqlType =" + sqlType + "len =" +outlen[0]);
+
+		writer.writeShort(sqlType);
+
+		// CCSID
+		// CCSID should be 0 for Binary Types.
+		
+		if (elemType == java.sql.Types.CHAR ||
+			elemType == java.sql.Types.VARCHAR
+			|| elemType == java.sql.Types.LONGVARCHAR
+			|| elemType == java.sql.Types.CLOB)
+			writer.writeScalar2Bytes(1208);
+		else
+			writer.writeScalar2Bytes(0);
+
+		if (sqlamLevel < MGRLVL_7) 
+		{
+
+			//SQLName
+			writeVCMorVCS(rtnOutput ? rsmeta.getColumnName(jdbcElemNum) : null);
+			//SQLLabel
+			writeVCMorVCS(null);
+			//SQLComments
+			writeVCMorVCS(null);
+
+			if (sqlamLevel == MGRLVL_6)
+				writeSQLUDTGRP(rsmeta, pmeta, jdbcElemNum, rtnOutput);
+		}
+		else
+		{
+			writeSQLDOPTGRP(rsmeta, pmeta, jdbcElemNum, rtnOutput);
+		}
+
+	}
+
+	/**
+	 * Write variable character mixed byte or single byte
+	 * The preference is to write mixed byte if it is defined for the server,
+	 * since that is our default and we don't allow it to be changed, we always
+	 * write mixed byte.
+	 * 
+	 * @param s	string to write
+	 * @exception DRDAProtocolException
+	 */
+	private void writeVCMorVCS(String s)
+		throws DRDAProtocolException
+	{
+		//Write only VCM and 0 length for VCS
+
+		if (s == null)
+		{
+			writer.writeShort(0);
+			writer.writeShort(0);
+			return;
+		}
+
+		// VCM
+		writer.writeLDString(s);
+		// VCS
+		writer.writeShort(0);
+	}
+
+  
+	private void writeSQLUDTGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int jdbcElemNum, boolean rtnOutput)
+		throws DRDAProtocolException,SQLException
+	{
+		writer.writeByte(CodePoint.NULLDATA);
+
+	}
+
+	private void writeSQLDOPTGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int jdbcElemNum, boolean rtnOutput)
+		throws DRDAProtocolException,SQLException
+	{
+
+		writer.writeByte(0);
+		//SQLUNAMED
+		writer.writeShort(0);
+		//SQLName
+		writeVCMorVCS(rtnOutput ? rsmeta.getColumnName(jdbcElemNum) : null);
+		//SQLLabel
+		writeVCMorVCS(null);
+		//SQLComments
+		writeVCMorVCS(null);
+		//SQLDUDTGRP 
+		writeSQLUDTGRP(rsmeta, pmeta, jdbcElemNum, rtnOutput);
+		//SQLDXGRP
+		writeSQLDXGRP(rsmeta, pmeta, jdbcElemNum, rtnOutput);
+	}
+
+
+	private void writeSQLDXGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int jdbcElemNum, boolean rtnOutput)
+		throws DRDAProtocolException,SQLException
+	{
+		// Null indicator indicates we have data
+		writer.writeByte(0);
+		//   SQLXKEYMEM; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+		// Hard to get primary key info. Send 0 for now
+		writer.writeShort(0);
+		//   SQLXUPDATEABLE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+		writer.writeShort(rtnOutput ? rsmeta.isWritable(jdbcElemNum) : false);
+
+		//   SQLXGENERATED; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+		if (rtnOutput && rsmeta.isAutoIncrement(jdbcElemNum)) 
+			writer.writeShort(2);
+		else
+			writer.writeShort(0);
+
+		//   SQLXPARMMODE; DRDA TYPE I2; ENVLID 0x04; Length Override 2
+		if (pmeta != null && !rtnOutput)
+		{
+			int mode = pmeta.getParameterMode(jdbcElemNum);
+			if (mode ==  JDBC30Translation.PARAMETER_MODE_UNKNOWN)
+			{
+				// For old style callable statements. We assume in/out if it
+				// is an output parameter.
+				int type =  DRDAStatement.getOutputParameterTypeFromClassName(
+																			  pmeta.getParameterClassName(jdbcElemNum));
+				if (type != DRDAStatement.NOT_OUTPUT_PARAM)
+					mode = JDBC30Translation.PARAMETER_MODE_IN_OUT;
+			}
+			writer.writeShort(mode);
+		}
+		else
+		{
+			writer.writeShort(0);
+		}
+	
+		//   SQLXRDBNAM; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+		// JCC uses this as the catalog name so we will send null.
+		writer.writeShort(0);
+
+		//   SQLXCORNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255
+		//   SQLXCORNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+		writeVCMorVCS(null);
+
+		//   SQLXBASENAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255
+		//   SQLXBASENAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+		writeVCMorVCS(rtnOutput ? rsmeta.getTableName(jdbcElemNum) : null);
+
+		//   SQLXSCHEMA_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255
+		//   SQLXSCHEMA_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+		writeVCMorVCS(rtnOutput ? rsmeta.getSchemaName(jdbcElemNum): null);
+
+
+		//   SQLXNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255
+		//   SQLXNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+		writeVCMorVCS(rtnOutput ? rsmeta.getColumnName(jdbcElemNum): null);
+		
+	}
+
+	
+	/**
+	 * Send data to application requester
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void send() throws DRDAProtocolException
+	{
+		//check if there is data to send
+		if (writer.getOffset() == 0)
+			return;
+		if (SanityManager.DEBUG) trace("Sending data");
+		try {
+			writer.flush();
+		} catch (IOException ioe) {
+			markCommunicationsFailure("flush","","","");
+		}
+	}
+
+  /**
+   * Write Fdoca Value to client 
+   * @param index     Index of column being returned
+   * @param val       Value to write to client
+   * @param drdaType  FD:OCA DRDA Type from FdocaConstants
+   * @param precision Precision
+   * @param stmt       Statement being processed
+   *
+   * @exception DRDAProtocolException  
+   * @exception SQLException
+   *
+   * @see FdocaConstants
+   */
+
+	protected void writeFdocaVal(int index, Object val, int drdaType,
+								 int precision, int scale, boolean valNull,
+								 
+								 DRDAStatement stmt) throws DRDAProtocolException, SQLException
+	{
+		writeNullability(drdaType,valNull);
+
+		if (! valNull)
+		{
+			int ndrdaType = drdaType | 1;
+			long valLength = 0;
+			switch (ndrdaType)
+			{
+			case FdocaConstants.DRDA_TYPE_NSMALL:
+ 					// DB2 does not have a BOOLEAN java.sql.bit type,
+					// so we need to send it as a small
+ 					if (val instanceof Boolean)
+ 					{
+ 						writer.writeShort(((Boolean) val).booleanValue());
+ 					}
+ 					else if (val instanceof Short)
+ 						writer.writeShort(((Short) val).shortValue());
+ 					else if (val instanceof Byte)
+ 						writer.writeShort(((Byte) val).byteValue());
+					else
+ 						writer.writeShort(((Integer) val).shortValue());
+					break;
+				case  FdocaConstants.DRDA_TYPE_NINTEGER:
+					writer.writeInt(((Integer) val).intValue());
+					break;
+				case FdocaConstants.DRDA_TYPE_NINTEGER8:
+					writer.writeLong(((Long) val).longValue());
+					break;
+				case FdocaConstants.DRDA_TYPE_NFLOAT4:
+					writer.writeFloat(((Float) val).floatValue());
+					break;
+				case FdocaConstants.DRDA_TYPE_NFLOAT8:
+					writer.writeDouble(((Double) val).doubleValue());
+					break;
+				case FdocaConstants.DRDA_TYPE_NDECIMAL:
+					if (precision == 0)
+						precision = FdocaConstants.NUMERIC_DEFAULT_PRECISION;
+					BigDecimal bd = (java.math.BigDecimal) val;
+					writer.writeBigDecimal(bd,precision,scale);
+					break;
+				case FdocaConstants.DRDA_TYPE_NDATE:
+					writer.writeString(((java.sql.Date) val).toString());
+					break;
+				case FdocaConstants.DRDA_TYPE_NTIME:
+					writer.writeString(((java.sql.Time) val).toString());
+					break;
+				case FdocaConstants.DRDA_TYPE_NTIMESTAMP:
+					// we need to send it in a slightly different format, and pad it
+					// up to or truncate it into 26 chars
+					String ts1 = ((java.sql.Timestamp) val).toString();
+					String ts2 = ts1.replace(' ','-').replace(':','.');
+					int tsLen = ts2.length();
+					if (tsLen < 26)
+					{
+						for (int i = 0; i < 26-tsLen; i++)
+							ts2 += "0";
+					}
+					else if (tsLen > 26)
+						ts2 = ts2.substring(0,26);
+					writer.writeString(ts2);
+					break;
+				case FdocaConstants.DRDA_TYPE_NCHAR:
+					writer.writeString(((String) val).toString());
+					break;
+				case FdocaConstants.DRDA_TYPE_NVARCHAR:
+				case FdocaConstants.DRDA_TYPE_NVARMIX:
+				case FdocaConstants.DRDA_TYPE_NLONG:
+				case FdocaConstants.DRDA_TYPE_NLONGMIX:
+					//WriteLDString and generate warning if truncated
+					// which will be picked up by checkWarning()
+					writer.writeLDString(val.toString(), index);
+					break;
+				case FdocaConstants.DRDA_TYPE_NLOBBYTES:
+					// do not send EXTDTA for lob of length 0, beetle 5967
+					valLength = ((Blob) val).length();
+					if (valLength > 0)
+						stmt.addExtDtaObject(val, index);
+					writer.writeExtendedLength (valLength);
+					break;
+				case FdocaConstants.DRDA_TYPE_NLOBCMIXED:
+					valLength = ((Clob) val).length();
+					// do not send EXTDTA for lob of length 0, beetle 5967
+					if (valLength > 0) 
+						stmt.addExtDtaObject(val,index);
+					writer.writeExtendedLength(valLength);
+					break;
+				case  FdocaConstants.DRDA_TYPE_NFIXBYTE:
+					writer.writeBytes((byte[]) val);
+					break;
+				case FdocaConstants.DRDA_TYPE_NVARBYTE:
+				case FdocaConstants.DRDA_TYPE_NLONGVARBYTE:
+						writer.writeLDBytes((byte[]) val, index);
+					break;
+				default:
+					if (SanityManager.DEBUG) 
+						trace("ndrdaType is: "+ndrdaType);
+					writer.writeLDString(val.toString(), index);
+			}
+		}
+	}
+
+	/**
+	 * write nullability if this is a nullable drdatype and FDOCA null
+	 * value if appropriate
+	 * @param drdaType      FDOCA type
+	 * @param valNull       true if this is a null value. False otherwise
+	 * 
+	 **/
+	private void writeNullability(int drdaType, boolean valNull)
+	{
+		if(FdocaConstants.isNullable(drdaType))
+		{
+			if (valNull)
+				writer.writeByte(FdocaConstants.NULL_DATA);
+			else
+			{
+				writer.writeByte(FdocaConstants.INDICATOR_NULLABLE);
+			}
+		}
+		
+	}
+
+	/**
+	 * Methods to keep track of required codepoints
+	 */
+	/**
+	 * Copy a list of required code points to template for checking
+	 *
+	 * @param req list of required codepoints
+	 */
+	private void copyToRequired(int [] req)
+	{
+		currentRequiredLength = req.length;
+		if (currentRequiredLength > required.length)
+			required = new int[currentRequiredLength];
+		for (int i = 0; i < req.length; i++)
+			required[i] = req[i];
+	}
+	/**
+	 * Remove codepoint from required list
+ 	 *
+	 * @param codePoint - code point to be removed
+	 */
+	private void removeFromRequired(int codePoint)
+	{
+		for (int i = 0; i < currentRequiredLength; i++)
+			if (required[i] == codePoint)
+				required[i] = 0;
+
+	}
+	/**
+	 * Check whether we have seen all the required code points
+	 *
+	 * @param codePoint code point for which list of code points is required
+	 */
+	private void checkRequired(int codePoint) throws DRDAProtocolException
+	{
+		int firstMissing = 0;
+		for (int i = 0; i < currentRequiredLength; i++)
+		{
+			if (required[i] != 0)
+			{
+				firstMissing = required[i];
+				break;
+			}
+		}
+		if (firstMissing != 0)
+			missingCodePoint(firstMissing);
+	}
+	/**
+	 * Error routines
+	 */
+	/**
+	 * Seen too many of this code point
+	 *
+	 * @param codePoint  code point which has been duplicated
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void tooMany(int codePoint) throws DRDAProtocolException
+	{
+		throwSyntaxrm(CodePoint.SYNERRCD_TOO_MANY, codePoint);
+	}
+	/**
+	 * Object too big
+	 *
+	 * @param codePoint  code point with too big object
+	 * @exception DRDAProtocolException
+	 */
+	private void tooBig(int codePoint) throws DRDAProtocolException
+	{
+		throwSyntaxrm(CodePoint.SYNERRCD_TOO_BIG, codePoint);
+	}
+	/**
+	 * Object length not allowed
+	 *
+	 * @param codePoint  code point with bad object length
+	 * @exception DRDAProtocolException
+	 */
+	private void badObjectLength(int codePoint) throws DRDAProtocolException
+	{
+		throwSyntaxrm(CodePoint.SYNERRCD_OBJ_LEN_NOT_ALLOWED, codePoint);
+	}
+	/**
+	 * RDB not found
+	 *
+	 * @param rdbnam  name of database
+	 * @exception DRDAProtocolException
+	 */
+	private void rdbNotFound(String rdbnam) throws DRDAProtocolException
+	{
+		Object[] oa = {rdbnam};
+		throw new
+			DRDAProtocolException(DRDAProtocolException.DRDA_Proto_RDBNFNRM,
+								  this,0,
+								  DRDAProtocolException.NO_ASSOC_ERRCD, oa);
+	}
+	/**
+	 * Invalid value for this code point
+	 *
+	 * @param codePoint  code point value
+	 * @exception DRDAProtocolException
+	 */
+	private void invalidValue(int codePoint) throws DRDAProtocolException
+	{
+		throwSyntaxrm(CodePoint.SYNERRCD_REQ_VAL_NOT_FOUND, codePoint);
+	}
+	/**
+	 * Invalid codepoint for this command
+	 *
+	 * @param codePoint code point value
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void invalidCodePoint(int codePoint) throws DRDAProtocolException
+	{
+		throwSyntaxrm(CodePoint.SYNERRCD_INVALID_CP_FOR_CMD, codePoint);
+	}
+	/**
+	 * Don't support this code point
+	 *
+	 * @param codePoint  code point value
+	 * @exception DRDAProtocolException
+	 */
+	private void codePointNotSupported(int codePoint) throws DRDAProtocolException
+	{
+		throw new
+			DRDAProtocolException(DRDAProtocolException.DRDA_Proto_CMDNSPRM,
+								  this,codePoint,
+								  DRDAProtocolException.NO_ASSOC_ERRCD);
+	}
+	/**
+	 * Don't support this value
+	 *
+	 * @param codePoint  code point value
+	 * @exception DRDAProtocolException
+	 */
+	private void valueNotSupported(int codePoint) throws DRDAProtocolException
+	{
+		throw new
+			DRDAProtocolException(DRDAProtocolException.DRDA_Proto_VALNSPRM,
+								  this,codePoint,
+								  DRDAProtocolException.NO_ASSOC_ERRCD);
+	}
+	/**
+	 * Verify that the code point is the required code point
+	 *
+	 * @param codePoint code point we have
+	 * @param reqCodePoint code point required at this time
+ 	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void verifyRequiredObject(int codePoint, int reqCodePoint)
+		throws DRDAProtocolException
+	{
+		if (codePoint != reqCodePoint )
+		{
+			throwSyntaxrm(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND,codePoint);
+		}
+	}
+	/**
+	 * Verify that the code point is in the right order
+	 *
+	 * @param codePoint code point we have
+	 * @param reqCodePoint code point required at this time
+ 	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void verifyInOrderACCSEC_SECCHK(int codePoint, int reqCodePoint)
+		throws DRDAProtocolException
+	{
+		if (codePoint != reqCodePoint )
+		{
+			throw
+			    new DRDAProtocolException(DRDAProtocolException.DRDA_Proto_PRCCNVRM,
+										  this, codePoint,
+										  CodePoint.PRCCNVCD_ACCSEC_SECCHK_WRONG_STATE);
+		}
+	}
+
+	/**
+	 * Database name given under code point doesn't match previous database names
+	 *
+	 * @param codepoint codepoint where the mismatch occurred
+ 	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void rdbnamMismatch(int codePoint)
+		throws DRDAProtocolException
+	{
+		throw new DRDAProtocolException(DRDAProtocolException.DRDA_Proto_PRCCNVRM,
+										  this, codePoint,
+										  CodePoint.PRCCNVCD_RDBNAM_MISMATCH);
+	}
+	/**
+	 * Close the current session
+	 */
+	private void closeSession()
+	{
+		if (session == null)
+			return;
+		server.removeFromSessionTable(session.connNum);
+		try {
+			session.close();
+		} catch (SQLException se)
+		{
+			// If something went wrong closing down the session.
+			// Print an error to the console and close this 
+			//thread. (6013)
+			sendUnexpectedException(se);
+			close();
+		}
+		finally {
+			session = null;
+			database = null;
+			appRequester=null;
+			sockis = null;
+			sockos=null;
+			databaseAccessException=null;
+		}
+	}
+
+	/**
+	 * Handle Exceptions - write error protocol if appropriate and close session
+	 *	or thread as appropriate
+	 */
+	private void handleException(Exception e)
+	{
+		String dbname = null;
+		if (database != null)
+			dbname = database.dbName;
+		
+		// protocol error - write error message and close session
+		if (e instanceof DRDAProtocolException)
+		{
+			try
+			{
+				DRDAProtocolException de = (DRDAProtocolException) e;
+				println2Log(dbname,session.drdaID, 
+							e.getMessage());
+				server.consoleExceptionPrintTrace(e);
+				reader.clearBuffer();
+				de.write(writer);
+				send();
+				closeSession();
+				close();
+			}
+			catch (DRDAProtocolException ioe)
+			{
+				// There may be an IO exception in the write.
+				println2Log(dbname,session.drdaID, 
+							e.getMessage());
+				server.consoleExceptionPrintTrace(ioe);
+				closeSession();
+				close();
+			}
+		}
+		else
+		{
+			// something unexpected happened so let's kill this thread
+			sendUnexpectedException(e);
+
+			server.consoleExceptionPrintTrace(e);
+			closeSession();
+			close();
+		}
+	}
+	
+
+	/**
+	 * Send unpexpected error to the client
+	 * @param e Exception to be sent
+	 */
+	private void sendUnexpectedException(Exception e)
+	{
+
+		DRDAProtocolException unExpDe;
+		String dbname = null;
+		try {
+			if (database != null)
+				dbname = database.dbName;
+			println2Log(dbname,session.drdaID, e.getMessage());
+			server.consoleExceptionPrintTrace(e);
+			unExpDe = DRDAProtocolException.newAgentError(this,
+														  CodePoint.SVRCOD_PRMDMG,  
+														  dbname, e.getMessage());
+		
+			reader.clearBuffer();
+			unExpDe.write(writer);
+			send();
+		}
+		catch (DRDAProtocolException nde) 
+		{
+			// we can't tell the client, but we tried.
+		}
+		
+	}
+
+
+	/**
+	 * Test if DRDA connection thread is closed
+	 *
+	 * @return true if close; false otherwise
+	 */
+	private boolean closed()
+	{
+		synchronized (closeSync)
+		{
+			return close;
+		}
+	}
+	/**
+	 * Get whether connections are logged
+	 *
+	 * @return true if connections are being logged; false otherwise
+	 */
+	private boolean getLogConnections()
+	{
+		synchronized(logConnectionsSync) {
+			return logConnections;
+		}
+	}
+	/**
+	 * Get time slice value for length of time to work on a session
+	 *
+	 * @return time slice
+	 */
+	private long getTimeSlice()
+	{
+		synchronized(timeSliceSync) {
+			return timeSlice;
+		}
+	}
+	/**
+	 * Send string to console
+	 *
+	 * @param value - value to print on console
+	 */
+	protected  void trace(String value)
+	{
+		if (SanityManager.DEBUG && server.debugOutput == true)
+			server.consoleMessage(value);
+	}
+
+	/***
+	 * Show runtime memory
+	 *
+	 ***/
+	public static void showmem() {
+		Runtime rt = null;
+		Date d = null;
+		rt = Runtime.getRuntime();
+		rt.gc();
+		d = new Date();
+		System.out.println("total memory: "
+						   + rt.totalMemory()
+						   + " free: "
+						   + rt.freeMemory()
+						   + " " + d.toString());
+
+	}
+
+	/**
+	 * convert byte array to a Hex string
+	 * 
+	 * @param buf buffer to  convert
+	 * @return hex string representation of byte array
+	 */
+	private String convertToHexString(byte [] buf)
+	{
+		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();
+	}
+	/**
+	 * check that the given typdefnam is acceptable
+	 * 
+	 * @param typdefnam 
+ 	 *
+ 	 * @exception DRDAProtocolException
+	 */
+	private void checkValidTypDefNam(String typdefnam)
+		throws DRDAProtocolException
+	{
+		if (typdefnam.equals("QTDSQL370"))
+			return;
+		if (typdefnam.equals("QTDSQL400"))
+			return;
+		if (typdefnam.equals("QTDSQLX86"))
+			return;
+		if (typdefnam.equals("QTDSQLASC"))
+			return;
+		if (typdefnam.equals("QTDSQLVAX"))
+			return;
+		if (typdefnam.equals("QTDSQLJVM"))
+			return;
+		invalidValue(CodePoint.TYPDEFNAM);
+	}
+	/**
+	 * Check that the length is equal to the required length for this codepoint
+	 *
+	 * @param codepoint	codepoint we are checking
+	 * @param reqlen	required length
+	 * 
+ 	 * @exception DRDAProtocolException
+	 */
+	private void checkLength(int codepoint, int reqlen)
+		throws DRDAProtocolException
+	{
+		long len = reader.getDdmLength();
+		if (len < reqlen)
+			badObjectLength(codepoint);
+		else if (len > reqlen)
+			tooBig(codepoint);
+	}
+	/**
+	 * Read and check a boolean value
+	 * 
+	 * @param codepoint codePoint to be used in error reporting
+	 * @return true or false depending on boolean value read
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private boolean readBoolean(int codepoint) throws DRDAProtocolException
+	{
+		checkLength(codepoint, 1);
+		int val = reader.readByte();
+		if (val == CodePoint.TRUE)
+			return true;
+		else if (val == CodePoint.FALSE)
+			return false;
+		else
+			invalidValue(codepoint);
+		return false;	//to shut the compiler up
+	}
+	/**
+	 * Add a database to the current session
+	 *
+	 */
+	private void addDatabase(String dbname)
+	{
+		Database db = new Database(dbname);
+		session.addDatabase(db);
+		session.database = db;
+		database = db;
+	}
+	/**
+	 * Set the current database
+	 * 
+	 * @param codePoint 	codepoint we are processing
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void setDatabase(int codePoint) throws DRDAProtocolException
+	{
+		String rdbnam = parseRDBNAM();
+		// using same database so we are done
+		if (database != null && database.dbName.equals(rdbnam))
+			return;
+		Database d = session.getDatabase(rdbnam);
+		if (d == null)
+			rdbnamMismatch(codePoint);
+		else
+			database = d;
+		session.database = d;
+	}
+	/**
+	 * Write ENDUOWRM
+	 * Instance Variables
+	 *  SVCOD - severity code - WARNING - required
+	 *  UOWDSP - Unit of Work Disposition - required
+	 *  RDBNAM - Relational Database name - optional
+	 *  SRVDGN - Server Diagnostics information - optional
+	 *
+	 * @param opType - operation type 1 - commit, 2 -rollback
+	 */
+	private void writeENDUOWRM(int opType)
+	{
+		writer.createDssReply();
+		writer.startDdm(CodePoint.ENDUOWRM);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD, CodePoint.SVRCOD_WARNING);
+		writer.writeScalar1Byte(CodePoint.UOWDSP, opType);
+    	writer.endDdmAndDss();
+	}
+
+  void writeEXTDTA (DRDAStatement stmt) throws SQLException, DRDAProtocolException
+  {
+
+	  ArrayList extdtaValues = stmt.getExtDtaObjects();
+    // build the EXTDTA data, if necessary
+    if (extdtaValues == null) 
+		return;
+	boolean chainFlag, chainedWithSameCorrelator;
+	boolean writeNullByte = false;
+
+	for (int i = 0; i < extdtaValues.size(); i++) {
+        // is this the last EXTDTA to be built?
+        if (i != extdtaValues.size() - 1) { // no
+			chainFlag = true;
+			chainedWithSameCorrelator = true;
+        }
+        else { // yes
+			chainFlag = false; //last blob DSS stream itself is NOT chained with the NEXT DSS
+			chainedWithSameCorrelator = false;
+        }
+
+		
+		if (sqlamLevel >= MGRLVL_7)
+			if (stmt.isExtDtaValueNullable(i))
+				writeNullByte = true;
+		
+		Object o  = extdtaValues.get(i);
+        if (o instanceof Blob) {
+			Blob b = (Blob) o;
+			long blobLength = b.length();
+			writer.writeScalarStream (chainFlag,
+									  chainedWithSameCorrelator,
+									  CodePoint.EXTDTA,
+									  (int) Math.min(blobLength,
+													 Integer.MAX_VALUE),
+									  b.getBinaryStream (),
+									  writeNullByte);
+			
+		}
+		else if (o instanceof  Clob) {
+			Clob c = (Clob) o;
+			long[] outlen = {-1};
+			ByteArrayInputStream  unicodeStream =
+				convertClobToUnicodeStream(c, outlen);
+			writer.writeScalarStream (chainFlag,
+									  chainedWithSameCorrelator,
+									  CodePoint.EXTDTA,
+									  (int) Math.min(outlen[0],
+													 Integer.MAX_VALUE),		 
+									  unicodeStream,
+									  writeNullByte);
+		}
+		else if (o instanceof  byte[]) {
+			byte[] b = (byte []) o;
+			writer.writeScalarStream (chainFlag,
+									  chainedWithSameCorrelator,
+									  CodePoint.EXTDTA,
+									  (int) b.length,
+									  new ByteArrayInputStream(b),
+									  writeNullByte);
+		}
+	}
+	// reset extdtaValues after sending
+	stmt.clearExtDtaObjects();
+
+  }
+
+
+
+	private  java.io.ByteArrayInputStream  
+		convertClobToUnicodeStream (
+								Clob c,
+								long outlen[]) throws SQLException
+	{
+		java.io.Reader characterStream = c.getCharacterStream();
+		// Extract all the characters and write into a StringWriter.
+		java.io.StringWriter sw = new java.io.StringWriter ();
+		try {
+			int read = characterStream.read();
+			while (read != -1) {
+				sw.write(read);
+				read = characterStream.read();
+			}
+    }
+		catch (java.io.IOException e) {
+			throw new SQLException (e.getMessage());
+		}
+
+		// Extract the String from the StringWriter and extract the UTF-8 bytes.
+		String string = sw.toString();
+
+		byte[] utf8Bytes = null;
+		try {
+			utf8Bytes = string.getBytes("UTF-8");
+		}
+		catch (java.io.UnsupportedEncodingException e) {
+			throw new SQLException (e.getMessage());
+    }
+
+		// Create a new ByteArrayInputStream based on the bytes.
+
+		outlen[0]= utf8Bytes.length;
+		return new java.io.ByteArrayInputStream (utf8Bytes);
+		}
+
+	/**
+	 * Check SQLWarning and write SQLCARD as needed.
+	 * 
+	 * @param conn 		connection to check
+	 * @param stmt 		statement to check
+	 * @param rs 		result set to check
+	 * @param reuseCorrID 	whether send SQLCARD using previous correlation ID
+	 * @param updateCount 	update count to include in SQLCARD
+	 * @param alwaysSend 	whether always send SQLCARD regardless of
+	 *						the existance of warnings
+	 * @param sendWarn 	whether to send any warnings or not. 
+	 *
+	 * @exception DRDAProtocolException
+	 */
+	private void checkWarning(Connection conn, Statement stmt, ResultSet rs,
+						  boolean reuseCorrID, int updateCount, boolean alwaysSend, boolean sendWarn)
+		throws DRDAProtocolException, SQLException
+	{
+		// instead of writing a chain of sql warning, we send the first one, this is
+		// jcc/db2 limitation, see beetle 4629
+		SQLWarning warning = null;
+		SQLWarning reportWarning = null;
+		try
+		{
+			if (stmt != null)
+			{
+				warning = stmt.getWarnings();
+				if (warning != null)
+				{
+					stmt.clearWarnings();
+					reportWarning = warning;
+				}
+			}
+			if (rs != null)
+			{
+				warning = rs.getWarnings();
+				if (warning != null)
+				{
+					rs.clearWarnings();
+					if (reportWarning == null)
+						reportWarning = warning;
+				}
+			}
+			if (conn != null)
+			{
+				warning = conn.getWarnings();
+				if (warning != null)
+				{
+					conn.clearWarnings();
+					if (reportWarning == null)
+						reportWarning = warning;
+				}
+			}
+			
+		}
+		catch (SQLException se)
+		{
+			if (SanityManager.DEBUG) 
+				trace("got SQLException while trying to get warnings.");
+		}
+
+
+		if ((alwaysSend || reportWarning != null) && sendWarn)
+			writeSQLCARDs(reportWarning, reuseCorrID, updateCount);
+	}
+
+
+	protected String buildRuntimeInfo(String indent, LocalizedResource localLangUtil )
+	{
+		String s ="";
+		if (session == null)
+			return s;
+		else
+			s += session.buildRuntimeInfo("", localLangUtil);
+		s += "\n";
+		return s;
+	}
+}
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolException.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,401 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+/*
+
+/**
+	DRDAProtocolException is the root of all protocol exceptions that are 
+	handled in a standard fashion by the DRDA AS.
+	If a protocol error message needs to send more than 
+	SVRCOD, an ERRCD and CODPNT arg it should be subclassed
+
+	@author marsden
+*/
+
+package org.apache.derby.impl.drda;
+import java.util.Hashtable;
+
+public class DRDAProtocolException extends Exception
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+	
+	/* Static values, used in constructor if there is no associated 
+	   Error Code or the codepoint argument.
+	*/
+	
+	protected static final int NO_ASSOC_ERRCD = 0;
+	protected static final int NO_CODPNT_ARG  = 0;
+
+	
+	private DRDAConnThread agent;
+
+	// request correlation id
+	private int correlationID;
+	
+	// correlation token
+	private byte[] crrtkn;
+
+	//Codepoint arg
+	private int codpntArg;
+
+	private DRDAProtocolExceptionInfo exceptionInfo;
+
+	// CodePoint of this error
+	private int errorCodePoint;
+	
+	// Severity Code
+	private int svrcod;
+	
+	// error code (e.g. SYNERRCD)
+	private int errcd;
+	
+	// messageid for logging errors.
+	private String  messageid;
+
+	// database name
+	private String rdbnam;
+	
+	// database diagnostic information
+	private String srvdgn;
+
+	// message arguments
+	private Object [] messageArgs;
+	
+	
+	private static Hashtable errorInfoTable;
+	
+	protected static String DRDA_Proto_CMDCHKRM=	"DRDA_Proto_CMDCHKRM";
+	protected static String DRDA_Proto_CMDNSPRM=	"DRDA_Proto_CMDNSPRM";
+	protected static String DRDA_Proto_DTAMCHRM=	"DRDA_Proto_DTAMCHRM";
+
+	protected static String DRDA_Proto_OBJNSPRM =	"DRDA_Proto_OBJNSPRM";
+	protected static String DRDA_Proto_PKGBNARM=	"DRDA_Proto_PKGBNARM";
+	protected static String DRDA_Proto_PRCCNVRM=   "DRDA_Proto_PRCCNVRM";
+	protected static String DRDA_Proto_PRMNSRM =   "DRDA_Proto_PRMNSPRM";
+
+	protected static String DRDA_Proto_SYNTAXRM=   "DRDA_Proto_SYNTAXRM";
+	protected static String DRDA_Proto_VALNSPRM=   "DRDA_Proto_VALNSPRM";
+	protected static String DRDA_Proto_MGRLVLRM=   "DRDA_Proto_MGRLVLRM";
+	protected static String DRDA_Proto_RDBNFNRM=   "DRDA_Proto_RDBNFNRM";
+
+	protected static String DRDA_Disconnect=	   "DRDA_Disconnect";
+	protected static String DRDA_AgentError=	   "DRDA_AgentError";
+
+	static {
+	/* Create the errorInfoTable
+	   The Hashtable is keyed on messageid and holds 
+	   DRDAProtocolExceptionInfo for each of our messages.
+	*/
+	
+	errorInfoTable = new Hashtable();
+	
+	errorInfoTable.put(
+			   DRDA_Proto_CMDCHKRM,
+			   new  DRDAProtocolExceptionInfo(
+							  CodePoint.CMDCHKRM,
+							  CodePoint.SVRCOD_ERROR,
+							  NO_ASSOC_ERRCD,
+							  false));
+
+	errorInfoTable.put(
+			   DRDA_Proto_CMDNSPRM,
+			   new  DRDAProtocolExceptionInfo(
+							  CodePoint.CMDNSPRM,
+							  CodePoint.SVRCOD_ERROR,
+							  NO_ASSOC_ERRCD,
+							  true));
+	errorInfoTable.put(
+			   DRDA_Proto_DTAMCHRM,
+			   new  DRDAProtocolExceptionInfo(
+							  CodePoint.DTAMCHRM,
+							  CodePoint.SVRCOD_ERROR,
+							  NO_ASSOC_ERRCD,
+							  false));
+	errorInfoTable.put(
+			   DRDA_Proto_OBJNSPRM,
+			   new  DRDAProtocolExceptionInfo(
+							  CodePoint.OBJNSPRM,
+							  CodePoint.SVRCOD_ERROR,
+							  NO_ASSOC_ERRCD,
+							  true));
+		
+	errorInfoTable.put(
+					   DRDA_Proto_PKGBNARM,
+					   new  DRDAProtocolExceptionInfo(
+							   CodePoint.PKGBNARM,
+							   CodePoint.SVRCOD_ERROR,
+							   NO_ASSOC_ERRCD,
+							   false));
+			   
+	errorInfoTable.put(DRDA_Proto_PRCCNVRM,
+			   new DRDAProtocolExceptionInfo(
+							 CodePoint.PRCCNVRM,
+							 CodePoint.SVRCOD_ERROR,
+							 CodePoint.PRCCNVCD,
+							 false));
+
+	errorInfoTable.put(DRDA_Proto_SYNTAXRM,
+			   new DRDAProtocolExceptionInfo(
+							 CodePoint.SYNTAXRM,
+							 CodePoint.SVRCOD_ERROR,
+							 CodePoint.SYNERRCD,
+							 true));
+
+	errorInfoTable.put(DRDA_Proto_VALNSPRM,
+			   new DRDAProtocolExceptionInfo(
+							 CodePoint.VALNSPRM,
+							 CodePoint.SVRCOD_ERROR,
+							 NO_ASSOC_ERRCD,
+							 true));
+
+	errorInfoTable.put(DRDA_Proto_MGRLVLRM,
+			   new DRDAProtocolExceptionInfo(
+							 CodePoint.MGRLVLRM,
+							 CodePoint.SVRCOD_ERROR,
+							 NO_ASSOC_ERRCD,
+							 false));
+
+	errorInfoTable.put(DRDA_Proto_RDBNFNRM,
+			   new DRDAProtocolExceptionInfo(
+							 CodePoint.RDBNFNRM,
+							 CodePoint.SVRCOD_ERROR,
+							 NO_ASSOC_ERRCD,
+							 false));
+
+			   
+	errorInfoTable.put(DRDA_Disconnect,
+			   new DRDAProtocolExceptionInfo(
+							 0,
+							 0,
+							 NO_ASSOC_ERRCD,
+							 false));
+
+	errorInfoTable.put(DRDA_AgentError,
+			   new DRDAProtocolExceptionInfo(
+							 0,
+							 0,
+							 NO_ASSOC_ERRCD,
+							 false));
+
+	}
+		
+	
+	/**  Create a new Protocol exception 
+	 *
+	 * @param agent		DRDAConnThread  that threw this exception
+	 *
+	 * @param cpArg		CODPNT value  to pass to send
+	 *
+	 *
+	 * @param msgid		  The messageid for this message. (needs to be
+	 * integrated into logging mechanism)
+	 *
+	 * @param args		   Argments for the message in an Object[]
+	 *
+	 */
+	
+	protected DRDAProtocolException(String msgid,
+									DRDAConnThread agent, 
+									int cpArg, 
+									int errCdArg, Object []args)
+						
+	{
+		
+		boolean agentError = false;
+
+		exceptionInfo = 
+			(DRDAProtocolExceptionInfo) errorInfoTable.get(msgid);
+				
+		if (agent != null)
+		{
+			this.correlationID = agent.getCorrelationID();
+			this.crrtkn = agent.getCrrtkn();
+		}
+
+		this.codpntArg= cpArg;
+		this.errorCodePoint = exceptionInfo.errorCodePoint;
+		this.errcd = errCdArg;
+		this.messageid = msgid;
+
+		String msg;
+		if (msgid.equals(DRDA_AgentError))
+		{
+			this.svrcod = ((Integer)args[0]).intValue();
+			this.rdbnam = (String)args[1];
+			msg = "Execution failed because of Permant Agent Error: SVRCOD = " +
+				java.lang.Integer.toHexString(this.svrcod) +
+				"; RDBNAM = "+ rdbnam;
+			agentError = true;
+		}
+		else if (msgid.equals(DRDA_Proto_RDBNFNRM))
+		{
+			this.svrcod = exceptionInfo.svrcod;
+			this.rdbnam = (String)args[0];
+			msg = "Execution failed because of Distributed Protocol Error:  " 
+				+ messageid +
+				"; RDBNAM = "+ rdbnam;
+		}
+		else
+		{
+			this.svrcod = exceptionInfo.svrcod;
+			msg = "Execution failed because of a Distributed Protocol Error:  " 
+				+ messageid +
+				"; CODPNT arg  = " + java.lang.Integer.toHexString(cpArg)  +
+				"; Error Code Value = " + java.lang.Integer.toHexString(errCdArg);
+		}
+		
+		
+		if (!agentError && args != null)
+		{
+			messageArgs = args;
+			for (int i = 0; i < args.length; i++)
+			{
+				//args contain managers and manager levels display in hex
+				if (msgid.equals(DRDA_Proto_MGRLVLRM))
+					msg += "," + 
+						java.lang.Integer.toHexString(((Integer)args[i]).intValue());
+				else
+					msg += "," + args[i];
+				
+			}
+		}
+
+
+		// for now dump all errors except disconnects to console		
+		// and log
+		if (!isDisconnectException())
+		{
+			DRDAConnThread.println2Log(agent.getDbName(),
+								   agent.getSession().drdaID, 
+								   msg);
+			DB2jServerImpl s = agent.getServer();
+			s.consoleMessage(msg);
+			this.printStackTrace(s.logWriter);
+		}
+	}
+	
+	// Constructor with no additional args
+	protected DRDAProtocolException(String msgid,
+									DRDAConnThread agent, 
+									int cpArg, 
+									int errCdArg)
+	{
+		this(msgid,agent,  cpArg, errCdArg, (Object []) null);
+	}
+
+
+	protected static DRDAProtocolException newDisconnectException(DRDAConnThread
+																  agent,Object[] args)
+	{
+		return new DRDAProtocolException(DRDA_Disconnect,
+										 agent,
+										 NO_CODPNT_ARG,
+										 NO_ASSOC_ERRCD,
+										 args);
+		
+	}
+	
+	protected static DRDAProtocolException newAgentError(DRDAConnThread agent,
+		int svrcod, String rdbnam, String srvdgn)
+	{
+		System.out.println("agent" + agent);
+		Object[] oa = {new Integer(svrcod), rdbnam, srvdgn};
+		return new DRDAProtocolException(DRDA_AgentError,
+										agent,
+										NO_CODPNT_ARG,
+										NO_ASSOC_ERRCD,
+										oa);
+	}
+	
+	protected final byte[] getCrrtkn()
+	{
+		return crrtkn;
+	}
+	
+	protected final int getCodpntArg()
+	{
+		return codpntArg;
+	}
+	
+	protected final int getErrorCodePoint()
+	{
+		return errorCodePoint;
+	}
+	
+	protected final int getSvrcod()
+	{
+		return  svrcod;
+	}
+	
+	protected final int getErrcd()
+	{
+		return  errcd;
+	}
+	
+	protected final String getMessageid()
+	{
+		return  messageid;
+	}
+	
+	
+	protected final boolean isDisconnectException()
+	{
+		return (errorCodePoint == 0);
+	}
+	
+	/** write will write the Error information to the buffer.
+	 * Most errors will write only the codepoint and svrcod 
+	 * Where appropriate the codepoint specific error code and
+	 * codePoint of origin will be written
+	 *
+	 * @param writer  The DDMWriter for the agent.
+	 */
+	
+	protected void write(DDMWriter writer)
+	{
+		//Writing Protocol Error
+		writer.createDssReply();
+		writer.startDdm(errorCodePoint);
+		writer.writeScalar2Bytes(CodePoint.SVRCOD,svrcod);
+		if (exceptionInfo.sendsCodpntArg)
+			writer.writeScalar2Bytes(CodePoint.CODPNT,codpntArg);
+		if (exceptionInfo.errCdCodePoint !=  NO_ASSOC_ERRCD)
+			writer.writeScalar1Byte(exceptionInfo.errCdCodePoint,
+									errcd);
+		if (rdbnam != null && agent != null)
+		{
+			try {
+				agent.writeRDBNAM(rdbnam);
+			} catch (DRDAProtocolException e) {} //ignore exceptions while processing
+		}
+		// for MGRLVLRM, need to write out the manager levels
+		if (errorCodePoint == CodePoint.MGRLVLRM)
+		{
+			writer.startDdm(CodePoint.MGRLVLLS);
+			for (int i = 0; i < messageArgs.length ; i += 2)
+			{
+				writer.writeNetworkShort(((Integer)messageArgs[i]).intValue());
+				writer.writeNetworkShort(((Integer)messageArgs[i+1]).intValue());
+			}
+			writer.endDdm();
+		}
+		writer.endDdmAndDss();
+	}
+}
+
+
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolExceptionInfo.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAProtocolExceptionInfo.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,65 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+public class DRDAProtocolExceptionInfo {
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+
+    private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+    
+    /*
+      Holds static information about the protocol error
+      to put in the Hash Table
+    */
+    // The Codepoint of the error (e.g CodePoint.SYTNAXRM)
+    protected int errorCodePoint;	   
+    
+    // Severity Code
+    protected int svrcod;
+    
+    // The CodePoint describing the errCD (e.g. CodePint.SYNERRCD)
+    protected int errCdCodePoint ;
+    
+    // Sends an originating Codepoint
+    protected boolean sendsCodpntArg;
+	
+    protected DRDAProtocolExceptionInfo(int errorCodePoint, int svrcod,  
+					int errCdCodePoint,
+					boolean sendsCodpntArg)
+    {
+	this.errorCodePoint = errorCodePoint;
+	this.svrcod = svrcod;
+	this.errCdCodePoint = errCdCodePoint;
+	this.sendsCodpntArg = sendsCodpntArg;
+    }
+    
+    
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAResultSet.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,495 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2003, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.lang.reflect.*;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.sql.ResultSetMetaData;
+import java.sql.Types;
+import java.sql.SQLException;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.apache.derby.iapi.reference.JDBC30Translation;
+import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.impl.jdbc.EmbedResultSet;
+import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.impl.jdbc.EmbedSQLException;
+import org.apache.derby.iapi.reference.SQLState;
+
+/**
+	DRDAResultSet holds result set information
+*/
+class DRDAResultSet
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2003_2004;
+
+	// resultSet states are NOT_OPENED and SUSPENDED
+	protected static final int NOT_OPENED = 1;
+	protected static final int SUSPENDED = 2;
+
+	boolean explicitlyClosed = false;
+
+	int state;
+	protected boolean hasdata = true;
+	protected int[] rsLens;				// result length for each column
+	private int[] rsDRDATypes;			// DRDA Types of the result set columns
+	private int[] rsPrecision;         // result precision for Decimal types
+	private int[] rsScale;              // result sale for Decimal types
+
+	protected int [] outovr_drdaType;	// Output override DRDA type and length
+
+	protected int withHoldCursor;			// hold cursor after commit attribute
+	protected int scrollType;			// Sensitive or Insensitive scroll attribute
+	protected int concurType;			// Concurency type
+	protected long rowCount;			// Number of rows we have processed
+	private ResultSet rs;              // Current ResultSet
+
+	protected int blksize;				// Query block size
+	protected int maxblkext;			// Maximum number of extra blocks
+	protected int outovropt;			// Output Override option
+	protected int qryclsimp;            // Implicit Query Close Setting
+	protected boolean qryrelscr;		// Query relative scrolling
+	protected long qryrownbr;			// Query row number
+	protected boolean qryrfrtbl;		// Query refresh answer set table
+	protected int qryscrorn;			// Query scroll orientation
+	protected boolean qryrowsns;		// Query row sensitivity
+	protected boolean qryblkrst;		// Query block reset
+	protected boolean qryrtndta;		// Query returns data
+	protected int qryrowset;			// Query row set
+	private   int qryprctyp;			// Protocol type
+	private   boolean gotPrctyp;		// save the result, for performance
+	protected int rtnextdta;			// Return of EXTDTA option
+	protected int nbrrow;			   // number of fetch or insert rows
+	protected byte [] rslsetflg;		// Result Set Flags
+
+	private ArrayList  extDtaObjects;  // Arraylist of Blobs and Clobs 
+	                                   // Return Values to 
+		                               // send with extdta objects.
+	
+	private ArrayList rsExtPositions;
+
+	protected String pkgcnstknStr;               // Unique consistency token for ResultSet 0
+
+
+
+	protected DRDAResultSet(ResultSet rs) throws SQLException
+	{
+		setResultSet(rs);
+		state = NOT_OPENED;
+	}
+
+	protected DRDAResultSet()
+	{
+		state = NOT_OPENED;
+	}
+
+	/**
+ 	 * Set result set and initialize type array.
+	 *
+	 * @param value
+	 * 
+	 */
+
+	protected void setResultSet(ResultSet value) throws SQLException
+	{
+		int numCols;
+		rs = value;
+		gotPrctyp = false;
+		if (value != null)
+		{
+		    numCols= rs.getMetaData().getColumnCount();
+			rsDRDATypes = new int[numCols];
+		}
+		explicitlyClosed = false;
+	}
+
+
+	/**
+	 * set consistency token for this resultSet
+	 *
+	 */
+	protected void setPkgcnstknStr(String pkgcnstknStr)
+	{
+		this.pkgcnstknStr = pkgcnstknStr;
+	}
+
+
+	/**
+	 * 
+	 *  @return the underlying java.sql.ResultSet
+	 */
+	protected ResultSet getResultSet()
+	{
+		return rs;
+	}
+
+	/** 
+	 * Set ResultSet DRDA DataTypes
+	 * @param drddaTypes for columns.
+	 **/
+	protected void setRsDRDATypes(int [] value)
+	{
+		rsDRDATypes = value;
+
+	}
+
+	/**
+	 *@return ResultSet DRDA DataTypes
+	 **/
+
+	protected int[] getRsDRDATypes()
+	{
+		// use the given override if it is present
+		if (outovr_drdaType != null)
+			return outovr_drdaType;
+		return rsDRDATypes;
+	}
+
+	/**
+	 * set resultset/out parameter precision
+	 *
+	 * @param index - starting with 1
+	 * @param precision
+	 */
+	protected void setRsPrecision(int index, int precision)
+	{
+		if (rsPrecision == null)
+			rsPrecision = new int[rsDRDATypes.length];
+		rsPrecision[index -1] = precision;
+	}
+
+	/**
+	 * get resultset /out paramter precision
+	 * @param index -starting with 1
+	 * @return precision of column
+	 */
+	protected int getRsPrecision(int index)
+	{
+		if (rsPrecision == null)
+			return 0;
+		return rsPrecision[index-1];
+	}
+
+	/**
+	 * set resultset/out parameter scale
+	 *
+	 * @param index - starting with 1
+	 * @param scale
+	 */
+	protected void setRsScale(int index, int scale)
+	{
+		if (rsScale == null)
+			rsScale = new int[rsDRDATypes.length];
+		rsScale[index-1] = scale;
+	}
+
+	/**
+	 * get resultset /out paramter scale
+	 * @param index -starting with 1
+	 * @return scale of column
+	 */
+	protected int  getRsScale(int index)
+	{
+		if (rsScale == null)
+			return 0;
+		
+		return rsScale[index -1];
+	}
+	
+	
+	/**
+	 * set resultset/out parameter DRDAType
+	 *
+	 * @param index - starting with 1
+	 * @param type
+	 */
+	protected  void setRsDRDAType(int index, int type)
+	{
+		rsDRDATypes[index -1] =  type;
+		
+	}
+	
+	/**
+	 * get  resultset/out parameter DRDAType
+	 *
+	 * @param index - starting with 1
+	 * @return  DRDA Type of column
+	 */
+	protected int getRsDRDAType(int index)
+	{
+		return rsDRDATypes[index -1];
+	}
+	
+
+	/**
+	 * set resultset DRDA Len
+	 *
+	 * @param index - starting with 1
+	 * @param value
+	 */
+	protected  void setRsLen(int index, int value)
+	{
+		if (rsLens == null)
+			rsLens = new int[rsDRDATypes.length];
+		rsLens[index -1] = value;
+		
+	}
+	
+	/**
+	 * get  resultset  DRDALen
+	 * @param index - starting with 1
+	 * @return  length of column value
+	 */
+	protected int getRsLen(int index)
+	{
+		return rsLens[index -1];
+	}
+	
+
+	/**
+	 * Add extDtaObject
+	 * @param o - object to  add
+	 */
+	protected void  addExtDtaObject (Object o, int jdbcIndex )
+	{
+		if (extDtaObjects == null)
+			extDtaObjects = new java.util.ArrayList();
+		extDtaObjects.add (o);
+
+		if (rsExtPositions == null)
+			rsExtPositions = new java.util.ArrayList();
+		
+		// need to record the 0 based position so subtract 1
+		rsExtPositions.add (new Integer(jdbcIndex -1 ));
+
+	}
+
+
+	/**
+	 * Clear externalized lob objects in current result set
+	 */
+	protected void  clearExtDtaObjects ()
+	{
+		if (extDtaObjects != null)
+			extDtaObjects.clear();
+		if (rsExtPositions != null)
+			rsExtPositions.clear();
+		
+	}
+	
+	/*
+	 * Is lob object nullable
+	 * @param index - offset starting with 0
+	 * @return true if object is nullable
+	 */
+	protected boolean isExtDtaValueNullable(int index)
+	{
+		if ((rsExtPositions == null) || 
+			rsExtPositions.get(index) == null)
+			return false;
+		
+
+		int colnum = ((Integer) rsExtPositions.get(index)).intValue();
+		
+		if (FdocaConstants.isNullable((getRsDRDATypes())[colnum]))
+			return true;
+		else 
+			return false;
+	}
+	
+
+	/**
+	 * Get the extData Objects
+	 *
+	 *  @return ArrayList with extdta
+	 */
+	protected ArrayList getExtDtaObjects()
+	{
+		return extDtaObjects;
+	}
+
+	/**
+	 * Set the extData Objects
+	 *
+	 *  @return ArrayList with extdta
+	 */
+	protected void  setExtDtaObjects(ArrayList a)
+	{
+		extDtaObjects =a;
+	}
+	
+	
+	/** Clean up statements and resultSet
+	 * 
+	 */
+	protected void close()  throws SQLException
+	{
+		if (rs != null)
+			rs.close();
+		rs = null;
+		gotPrctyp = false;
+		outovr_drdaType = null;
+		scrollType = 0;
+		concurType = 0;
+		rowCount = 0;
+		rsLens = null;
+		rsDRDATypes = null;
+		rsPrecision = null;
+		rsScale = null;
+		extDtaObjects = null;
+		rsExtPositions = null;
+		state=NOT_OPENED;
+		hasdata = true;
+	}
+
+
+	/**
+	 * Explicitly close the result set by CLSQRY
+	 * needed to check for double close.
+	 */
+	protected void CLSQRY()
+	{
+		explicitlyClosed = true;
+	}
+
+	/* 
+	 * @return whether CLSQRY has been called on the
+	 *         current result set.
+	 */
+	protected boolean wasExplicitlyClosed()
+	{
+		return explicitlyClosed;
+	}
+
+
+	/****
+	 * Check to see if the result set for this statement
+	 * has at least one column that is BLOB/CLOB.
+	 * @return True if the result has at least one blob/clob
+	 *  column; false otherwise.
+	 ****/
+ 
+	private boolean hasLobColumns()	throws SQLException
+	{
+		ResultSetMetaData rsmd = rs.getMetaData();
+		int ncols = rsmd.getColumnCount();
+		for (int i = 1; i <= ncols; i++)
+		{
+			int type = rsmd.getColumnType(i);
+			if (type == Types.BLOB || type == Types.CLOB)
+				return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Get the cursor name for the ResultSet
+	 */
+	public String getResultSetCursorName() throws SQLException
+	{
+
+		if (rs != null)
+			return rs.getCursorName();
+		else 
+			return null;
+	}
+
+	protected int getQryprctyp()
+		throws SQLException
+	{
+		if (!gotPrctyp && qryprctyp == CodePoint.LMTBLKPRC)
+		{
+			gotPrctyp = true;
+			if (rs == null || ((EmbedResultSet) rs).isForUpdate() ||
+				/* for now we are not supporting LOB under LMTBLKPRC.  drda spec only
+				 * disallows LOB under LMTBLKPRC if OUTOVR is also for ANY CNTQRY reply.
+				 * To support LOB, QRYDTA protocols for LOB will need to be changed.
+				 */
+				hasLobColumns())
+			{
+				qryprctyp = CodePoint.FIXROWPRC;
+			}
+		}
+		return qryprctyp;
+	}
+
+	protected void setQryprctyp(int qryprctyp)
+	{
+		this.qryprctyp = qryprctyp;
+	}
+
+	/**
+	 * is ResultSet closed
+	 * @return whether the resultSet  is closed
+	 */
+	protected boolean isClosed()
+	{
+		return (state == NOT_OPENED);
+	}
+
+	/**
+	 * Set state to SUSPENDED (result set is opened)
+	 */
+	protected void suspend()
+	{
+		state = SUSPENDED;
+	}
+
+
+	protected String toDebugString(String indent)
+	{
+		String s = indent + "***** DRDASResultSet toDebugString ******\n";
+		s += indent + "State:" + getStateString(state)+ "\n";
+		s += indent + "pkgcnstknStr: {" +pkgcnstknStr  + "}\n"; 
+		s += indent + "cursor Name: ";
+		String cursorName = null;
+		try {
+			if (rs != null)
+				cursorName = rs.getCursorName();
+		}
+		catch (SQLException se )
+		{
+			cursorName = "invalid rs";
+		}
+		s += indent + cursorName + "\n";
+		   
+		return s;
+	}
+
+
+	private String getStateString( int i )
+	{
+		switch (i)
+		{
+			case NOT_OPENED:
+				return "NOT_OPENED";
+			case SUSPENDED:
+				return "SUSPENDED";
+			default:
+				return "UNKNOWN_STATE";
+		}
+
+	}
+}
+	
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,1475 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.lang.reflect.*;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.sql.SQLException;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.Enumeration;
+
+import org.apache.derby.iapi.reference.JDBC30Translation;
+import org.apache.derby.iapi.services.info.JVMInfo;
+import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.impl.jdbc.EmbedConnection;
+import org.apache.derby.impl.jdbc.EmbedResultSet;
+import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
+import org.apache.derby.impl.jdbc.EmbedCallableStatement;
+import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.impl.jdbc.EmbedSQLException;
+import org.apache.derby.iapi.sql.execute.ExecutionContext;
+import org.apache.derby.iapi.reference.SQLState;
+
+import org.apache.derby.iapi.util.StringUtil;
+
+import java.math.BigInteger;
+import java.io.UnsupportedEncodingException;
+import java.util.Hashtable;
+
+/**
+	DRDAStatement stores information about the statement being executed
+*/
+class DRDAStatement
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+
+
+	protected String typDefNam;		//TYPDEFNAM for this statement
+	protected int byteOrder;		//deduced from typDefNam, save String comparisons
+	protected int ccsidSBC;			//CCSID for single byte characters
+	protected int ccsidDBC;			//CCSID for double byte characters
+	protected int ccsidMBC;			//CCSID for mixed byte characters
+	protected String ccsidSBCEncoding;	//Java encoding for CCSIDSBC
+	protected String ccsidDBCEncoding;	//Java encoding for CCSIDDBC
+	protected String ccsidMBCEncoding;	//Java encoding for CCSIDMBC
+
+	protected Database database;		// Database this statement is created for
+	private   String pkgnamcsn;         // Package name/section # and  consistency token
+	protected String pkgcnstknStr;       // Consistency token for the first result set
+ 	protected String pkgid;              // package id
+ 	protected String sectionNumber;      // section number
+	protected int withHoldCursor = -1;	 // hold cursor after commit attribute.
+	protected int isolationLevel;         //JCC isolation level for Statement
+	protected String cursorName;
+	protected int scrollType;			// Sensitive or Insensitive scroll attribute
+	protected int concurType;			// Concurency type
+	protected long rowCount;			// Number of rows we have processed
+	protected byte [] rslsetflg;		// Result Set Flags
+	protected int maxrslcnt;			// Maximum Result set count
+	protected PreparedStatement ps;     // Prepared statement
+	protected boolean isCall;
+	protected String procName;			// callable statement's method name
+	private   int[] outputTypes;		// jdbc type for output parameter or NOT_OUTPUT_PARAM
+	                                    // if not an output parameter.
+	protected static int NOT_OUTPUT_PARAM = -100000;
+	protected boolean outputExpected;	// expect output from a callable statement
+	private Statement stmt;				// SQL statement
+
+
+	private DRDAResultSet currentDrdaRs;  // Current ResultSet
+	private Hashtable resultSetTable;     // Hashtable with resultsets            
+	private ArrayList resultSetKeyList;  // ordered list of hash keys
+	private int numResultSets = 0;  
+
+	// State for parameter data
+	protected  Vector cliParamDrdaTypes = new Vector();
+	protected Vector cliParamLens = new Vector();
+	protected ArrayList cliParamExtPositions = null;
+
+	// Query options  sent on EXCSQLSTT
+	// These the default for ResultSets created for this statement.
+	// These can be overriden by OPNQRY or CNTQRY,
+	protected int nbrrow;			// number of fetch or insert rows
+	protected int qryrowset;			// Query row set
+	protected int blksize;				// Query block size
+	protected int maxblkext;			// Maximum number of extra blocks
+	protected int outovropt;			// Output Override option
+	protected int qryclsimp;            // Implicit Query Close Setting
+	protected boolean qryrfrtbl;		// Query refresh answer set table
+	private int qryprctyp = CodePoint.QRYBLKCTL_DEFAULT;   // Protocol type
+	
+	
+
+	boolean needsToSendParamData = false;
+	boolean explicitlyPrepared = false;    //Prepared with PRPSQLSTT (reusable) 
+
+	// constructor
+	/**
+	 * DRDAStatement constructor
+	 *
+	 * @param database
+	 * 
+	 */
+	protected DRDAStatement (Database database) 
+	{
+		this.database = database;
+		setTypDefValues();
+		this.currentDrdaRs = new DRDAResultSet();
+	}
+
+	/**
+	 * set TypDef values
+	 *
+	 */
+	protected void setTypDefValues()
+	{
+		// initialize statement values to current database values
+		this.typDefNam = database.typDefNam;
+		this.byteOrder = database.byteOrder;
+		this.ccsidSBC = database.ccsidSBC;
+		this.ccsidDBC = database.ccsidDBC;
+		this.ccsidMBC = database.ccsidMBC;
+		this.ccsidSBCEncoding = database.ccsidSBCEncoding;
+		this.ccsidDBCEncoding = database.ccsidDBCEncoding;
+		this.ccsidMBCEncoding = database.ccsidMBCEncoding;
+	}
+	/**
+	 * Set database
+	 *
+	 * @param database
+	 */
+	protected void setDatabase(Database database)
+	{
+		this.database = database;
+		setTypDefValues();
+	}
+	/**
+	 * Set statement
+	 *
+	 * @param conn	Connection
+	 * @exception SQLException
+	 */
+	protected void setStatement(Connection conn)
+		throws SQLException
+	{
+		stmt = conn.createStatement();
+		//beetle 3849 -  see  prepareStatement for details
+		if (cursorName != null)
+			stmt.setCursorName(cursorName);
+	}
+	/**
+	 * Get the statement
+	 *
+	 * @return statement
+	 * @exception SQLException
+	 */
+	protected Statement getStatement() 
+		throws SQLException
+	{
+		return stmt;
+	}
+
+	/**Set resultSet defaults to match 
+	 * the statement defaults sent on EXCSQLSTT
+	 * This might be overridden on OPNQRY or CNTQRY
+	 **/
+
+	protected void setRsDefaultOptions(DRDAResultSet drs)
+	{
+		drs.nbrrow = nbrrow;
+ 		drs.qryrowset = qryrowset;
+ 		drs.blksize = blksize;
+ 		drs.maxblkext = maxblkext;
+ 		drs.outovropt = outovropt;
+ 		drs.rslsetflg = rslsetflg;
+		drs.scrollType = scrollType;
+		drs.concurType = concurType;
+		drs.setQryprctyp(qryprctyp);
+		drs.qryrowset = qryrowset;
+	}
+
+	/**
+	 * Set result set options to default for statement
+	 */
+	protected void setRsDefaultOptions()
+	{
+		setRsDefaultOptions(currentDrdaRs);
+	}
+
+	/**
+	 * Get the extData Objects
+	 *
+	 *  @return ArrayList with extdta
+	 */
+	protected ArrayList getExtDtaObjects()
+	{
+		return currentDrdaRs.getExtDtaObjects();
+	}
+
+	/**
+	 * Set the extData Objects
+	 *
+	 *  @return ArrayList with extdta
+	 */
+	protected void  setExtDtaObjects(ArrayList a)
+	{
+		currentDrdaRs.setExtDtaObjects(a);
+	}
+	
+   	/**
+	 * Add extDtaObject
+	 * @param o - object to  add
+	 * @param jdbcIndex - jdbc index for parameter
+	 */
+	protected void  addExtDtaObject (Object o, int jdbcIndex )
+	{
+		currentDrdaRs.addExtDtaObject(o,jdbcIndex);
+	}
+
+	
+	/**
+	 * Clear externalized lob objects in current result set
+	 */
+	protected void  clearExtDtaObjects ()
+	{
+		currentDrdaRs.clearExtDtaObjects();
+	}
+
+
+	/*
+	 * Is lob object nullable
+	 * @param index - offset starting with 0
+	 * @return true if object is nullable
+	 */
+	protected boolean isExtDtaValueNullable(int index)
+	{
+		return currentDrdaRs.isExtDtaValueNullable(index);
+	}
+	
+
+	/**
+	 * Set query options sent on OPNQRY
+	 */
+	protected void setOPNQRYOptions(int blksize, int qryblkctl,
+								  int maxblkext, int outovropt,int qryrowset,int qryclsimpl)
+	{
+		currentDrdaRs.blksize = blksize;
+		currentDrdaRs.setQryprctyp(qryblkctl);
+		currentDrdaRs.maxblkext = maxblkext;
+		currentDrdaRs.outovropt = outovropt;
+		currentDrdaRs.qryrowset = qryrowset;
+		currentDrdaRs.qryclsimp = qryclsimp;
+	}
+
+	/*
+	 * Set query options sent on CNTQRY
+	 */
+	protected void setQueryOptions(int blksize, boolean qryrelscr, 
+									long qryrownbr,
+									boolean qryfrtbl,int nbrrow,int maxblkext,
+									int qryscrorn, boolean qryrowsns,
+									boolean qryblkrst,
+									boolean qryrtndta,int qryrowset,
+									int rtnextdta)
+	{
+		currentDrdaRs.blksize = blksize;
+		currentDrdaRs.qryrelscr = qryrelscr;
+		currentDrdaRs.qryrownbr = qryrownbr;
+		currentDrdaRs.qryrfrtbl = qryrfrtbl;
+		currentDrdaRs.nbrrow = nbrrow;
+		currentDrdaRs.maxblkext = maxblkext;
+		currentDrdaRs.qryscrorn = qryscrorn;
+		currentDrdaRs.qryrowsns = qryrowsns;
+		currentDrdaRs.qryblkrst = qryblkrst;
+		currentDrdaRs.qryrtndta = qryrtndta;
+		currentDrdaRs.qryrowset = qryrowset;
+		currentDrdaRs.rtnextdta = rtnextdta;
+	}
+
+
+
+	protected void setQryprctyp(int qryprctyp)
+	{
+		this.qryprctyp = qryprctyp;
+		currentDrdaRs.setQryprctyp(qryprctyp);
+	}
+
+	protected int  getQryprctyp()
+		throws SQLException
+	{
+		return currentDrdaRs.getQryprctyp();
+	}
+
+	protected void setQryrownbr(long qryrownbr)
+	{
+		currentDrdaRs.qryrownbr = qryrownbr;
+	}
+
+	protected long  getQryrownbr()
+	{
+		return currentDrdaRs.qryrownbr;
+	}
+
+
+	protected int  getQryrowset()
+	{
+		return currentDrdaRs.qryrowset;
+	}
+
+	
+	protected int getBlksize()
+	{
+		return currentDrdaRs.blksize;
+	}
+
+	protected void setQryrtndta(boolean qryrtndta)
+	{
+		currentDrdaRs.qryrtndta = qryrtndta;
+	}
+
+	protected boolean  getQryrtndta()
+	{
+		return currentDrdaRs.qryrtndta;
+	}
+
+
+	protected void setQryscrorn(int qryscrorn)
+	{
+		currentDrdaRs.qryscrorn = qryscrorn;
+	}
+
+	protected int  getQryscrorn()
+	{
+		return currentDrdaRs.qryscrorn;
+	}
+
+	protected void getQryclsimp(int value)
+	{
+		currentDrdaRs.qryclsimp = value;
+	}
+
+	protected int  getQryclsimp()
+	{
+		return currentDrdaRs.qryclsimp;
+	}
+
+	protected void setScrollType(int scrollType)
+	{
+		currentDrdaRs.scrollType = scrollType;
+	}
+
+	protected int  getScrollType()
+	{
+		return currentDrdaRs.scrollType;
+	}
+
+
+	protected void setConcurType(int scrollType)
+	{
+		currentDrdaRs.concurType = scrollType;
+	}
+
+	protected int  getConcurType()
+	{
+		return currentDrdaRs.concurType;
+	}
+
+	protected void 	setOutovr_drdaType(int[] outovr_drdaType) 
+	{
+	   currentDrdaRs.outovr_drdaType = outovr_drdaType;
+	}
+
+
+	protected int[] 	getOutovr_drdaType() 
+	{
+		return currentDrdaRs.outovr_drdaType;
+	}
+	
+	protected boolean hasdata()
+	{
+		return currentDrdaRs.hasdata;
+	}
+	
+	protected void  setHasdata(boolean hasdata)
+	{
+		currentDrdaRs.hasdata = hasdata;
+	}
+
+	/**
+	 * Initialize for reuse
+	 */
+	protected void initialize() 
+	{
+		setTypDefValues();
+	}
+
+
+	protected PreparedStatement explicitPrepare(String sqlStmt) throws SQLException
+	{
+		explicitlyPrepared = true;
+		return prepare(sqlStmt);
+	}
+
+	protected boolean wasExplicitlyPrepared()
+	{
+		return explicitlyPrepared;
+	}
+
+	/**
+	 * Create a prepared statement
+	 *
+	 * @param sqlStmt - SQL statement
+	 *
+	 * @exception SQLException
+	 */
+	protected PreparedStatement prepare(String sqlStmt)   throws SQLException
+	{
+		// save current prepare iso level
+		int saveIsolationLevel = -1;
+		boolean isolationSet = false;
+		if (pkgnamcsn !=null)
+		{
+			saveIsolationLevel = database.getPrepareIsolation();
+			database.setPrepareIsolation(isolationLevel);
+			isolationSet = true;
+		}
+		
+		if (isCallableSQL(sqlStmt))
+		{
+			isCall = true;
+			ps = database.getConnection().prepareCall(sqlStmt);
+			setupCallableStatementParams((CallableStatement)ps);
+			if (isolationSet)
+				database.setPrepareIsolation(saveIsolationLevel);
+			return ps;
+		}
+		parsePkgidToFindHoldability();
+		if (withHoldCursor == JDBC30Translation.CLOSE_CURSORS_AT_COMMIT) {
+			if (JVMInfo.JDK_ID == 2) {//need to use reflection for holdability for jdk 1.3
+				//prepareStatement takes 4 parameters
+				Class[] PREP_STMT_PARAM = { String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE };
+				Object[] PREP_STMT_ARG = { sqlStmt, new Integer(scrollType),
+				new Integer(concurType), new Integer(JDBC30Translation.CLOSE_CURSORS_AT_COMMIT)};
+				try {
+					//create a prepared statement with close cursor at commit using reflection.
+					Method sh = database.getConnection().getClass().getMethod("prepareStatement", PREP_STMT_PARAM);
+					ps = (PreparedStatement) (sh.invoke(database.getConnection(), PREP_STMT_ARG));
+				} catch (InvocationTargetException itex) {
+					Throwable e = itex.getTargetException();
+					//prepareStatement can only throw SQLExcepton
+					if (e instanceof SQLException)
+					{
+						throw (SQLException) e;
+					}
+					else
+						throw Util.javaException(e);
+				}
+				catch (Exception e) {
+					// invoke can throw IllegalAccessException or 
+					// IllegalArgumentException, but these should not 
+					// occur from this code. Just in case we will throw it
+					throw Util.javaException(e);
+				}
+			} else if (JVMInfo.JDK_ID >= 4) 
+				ps = ((EmbedConnection)(database.getConnection())).prepareStatement(sqlStmt, scrollType, concurType, withHoldCursor);
+			else //no holdability change support for jdk 12 and less
+				ps = database.getConnection().prepareStatement(sqlStmt);
+		} else if (scrollType != 0)
+			ps = database.getConnection().prepareStatement(sqlStmt, scrollType, concurType);
+		else
+			ps = database.getConnection().prepareStatement(sqlStmt);
+      
+		// beetle 3849  -  Need to change the cursor name to what
+		// JCC thinks it will be, since there is no way in the 
+		// protocol to communicate the actual cursor name.  JCC keeps 
+		// a mapping from the client cursor names to the DB2 style cursor names
+		if (cursorName != null)//cursorName not null means we are dealing with dynamic pacakges
+			ps.setCursorName(cursorName);
+		if (isolationSet)
+			database.setPrepareIsolation(saveIsolationLevel);
+				return ps;
+	}
+
+	/**
+	 * Get prepared statement
+	 *
+	 * @return prepared statement
+	 */
+	protected PreparedStatement getPreparedStatement() 
+	{
+		return ps;
+	}
+
+
+	/**
+	 * Executes the prepared statement and populates the resultSetTable.
+	 * Access to the various resultSets is then possible by using
+	 * setCurrentDrdaResultSet(String pkgnamcsn)  to set the current
+	 * resultSet and then calling getResultSet() or the other access 
+	 * methods to get resultset data.
+	 *
+	 * @ return true if the execution has resultSets
+	 */
+	protected boolean execute() throws SQLException
+	{
+		boolean hasResultSet = ps.execute();
+
+		// java.sql.Statement says any result sets that are opened
+		// when the statement is re-executed must be closed; this
+		// is handled by the call to "ps.execute()" above--but we
+		// also have to reset our 'numResultSets' counter, since
+		// all previously opened result sets are now invalid.
+		numResultSets = 0;
+
+		ResultSet rs = null;
+		boolean isCallable = (ps instanceof java.sql.CallableStatement);
+		if (isCallable)
+			needsToSendParamData = true;
+
+		do {
+			rs = ps.getResultSet();
+			if (rs !=null)
+			{
+				addResultSet(rs);
+				hasResultSet = true;
+			}
+			// For normal selects we are done, but procedures might
+			// have more resultSets
+		}while (isCallable && ((EmbedPreparedStatement) ps).getMoreResults(JDBC30Translation.KEEP_CURRENT_RESULT));
+
+		return hasResultSet;
+
+	}
+	
+	/**
+	 * clear out type data for parameters.
+	 * Unfortunately we currently overload the resultSet type info
+	 * rsDRDATypes et al with parameter info.
+	 * RESOLVE: Need to separate this
+	 */
+   protected void finishParams()
+	{
+		needsToSendParamData = false;
+	}
+
+	/**
+	 * Set the pkgid sec num for this statement and the 
+	 * consistency token that will be used for the first resultSet.
+	 * For dyamic packages The package name is encoded as follows
+	 * SYS(S/L)(H/N)xyy 
+	 * where 'S' represents Small package and 'L' large 
+	 *                      (ignored by cloudscape) 
+	 * Where 'H' represents WITH HOLD, and 'N' represents NO WITH HOLD. 
+	 *                      (May be overridden by SQLATTR for WITH
+	 *                       HOLD")
+	 *
+	 * Where 'www' is the package iteration (ignored by cloudcape)
+	 * Where 'x' is the isolation level: 0=NC, 1=UR, 2=CS, 3=RS, 4=RR 
+	 * Where 'yy' is the package iteration 00 through FF 
+	 * Where 'zz' is unique for each platform
+	 * Happilly, these values correspond precisely to the internal cloudscape
+	 * isolation levels  in ExecutionContext.java
+	 * x   Isolation Level                                           
+	 * --  ---------------------
+	 * 0   NC  (java.sql.Connection.TRANSACTION_NONE)
+	 * 1   UR  (java.sql.Connection.TRANACTION_READ_UNCOMMITTED)
+	 * 2   CS  (java.sql.Connection.TRANSACTION_READ_COMMITTED)
+	 * 3   RS  (java.sql.Connection.TRANSACTION_REPEATABLE_READ)
+	 * 4   RR  (java.sql.Connection.TRANSACTION_SERIALIZABLE)
+	 * 
+	 * static packages have preset isolation levels 
+	 * (see getStaticPackageIsolation)
+	 * @param pkgnamcsn  package id section number and token from the client
+	 */
+	protected void setPkgnamcsn(String pkgnamcsn)
+	{
+		this.pkgnamcsn =  pkgnamcsn;
+		// Store the consistency string for the first ResultSet.
+		// this will be used to calculate consistency strings for the 
+		// other result sets.
+		StringTokenizer st = new StringTokenizer(pkgnamcsn);
+		st.nextToken();   // rdbnam (disregard)
+		st.nextToken();   // rdbcolid (disregard)
+		pkgid = st.nextToken();   // pkgid
+
+		if (isDynamicPkgid(pkgid))
+		{
+			isolationLevel = Integer.parseInt(pkgid.substring(5,6));
+			
+			
+			/*
+			 *   generate DB2-style cursorname
+			 *   example value : SQL_CURSN200C1
+			 *   where 
+			 *      SQL_CUR is db2 cursor name prefix;
+			 *      S - Small package , L -Large package
+			 *      N - normal cursor, H - hold cursor 
+			 *      200 - package id as sent by jcc 
+			 *      C - tack-on code for cursors
+			 *      1 - section number sent by jcc		 
+			 */
+			
+			
+
+			// cursor name
+			// trim the SYS off the pkgid so it wont' be in the cursor name
+			String shortPkgid = pkgid.substring(pkgid.length() -5 , pkgid.length());
+			sectionNumber = st.nextToken() ;
+			this.cursorName = "SQL_CUR" +  shortPkgid + "C" + sectionNumber ;
+		}
+		else // static package
+		{
+			isolationLevel = getStaticPackageIsolation(pkgid);
+		}
+
+		this.pkgcnstknStr = st.nextToken();
+
+	}
+
+
+	/**
+	 * get the isolation level for a static package.
+	 * @param pkgid - Package identifier string (e.g. SYSSTAT)
+	 * @return isolation
+	 */
+	private int getStaticPackageIsolation(String pkgid)
+	{
+		// SYSSTAT is used for metadata. and is the only static package used
+		// for JCC. Other static packages will need to be supported for 
+		// CCC. Maybe a static hash table would then be in order.
+		if (pkgid.equals("SYSSTAT"))
+			return ExecutionContext.READ_UNCOMMITTED_ISOLATION_LEVEL;
+		else
+			return ExecutionContext.UNSPECIFIED_ISOLATION_LEVEL;
+	}
+
+	/**
+	 * Get pkgnamcsn
+	 *
+	 * @return pkgnamcsn
+	 */
+	protected String getPkgnamcsn() 
+	{
+		return pkgnamcsn;
+
+	}
+	/**
+	 * Get result set
+	 *
+	 * @return result set
+	 */
+	protected ResultSet getResultSet() 
+	{
+		return currentDrdaRs.getResultSet();
+	}
+
+	
+	/** 
+	 * Just get the resultset. Don't set it to current
+	 * Assumes resultSet rsnum exists.
+	 *
+	 * @param rsnum - resultSetNumber starting with 0
+	 * @return  The result set in the order it was retrieved
+	 *         
+	 *          with getMoreResults()
+	 **/
+	private  ResultSet getResultSet(int rsNum)  
+	{
+		if (rsNum == 0)
+			return currentDrdaRs.getResultSet();
+		else
+		{
+			String key = (String) resultSetKeyList.get(rsNum);
+			return ((DRDAResultSet) (resultSetTable.get( key))).getResultSet();
+		}
+	}
+
+	/**
+ 	 * Set result set
+	 *
+	 * @param value
+	 */
+	protected void setResultSet(ResultSet value) throws SQLException
+	{
+		if (currentDrdaRs.getResultSet() == null)
+			numResultSets = 1;
+		currentDrdaRs.setResultSet(value);
+		setRsDefaultOptions(currentDrdaRs);
+	}
+
+	/**
+ 	 * Set currentDrdaResultSet 
+	 *
+	 * @param rsNum   The result set number starting with 0
+	 *                 
+	 */
+	protected void setCurrentDrdaResultSet(int rsNum)
+	{
+		String consistToken = getResultSetPkgcnstknStr(rsNum);
+		if (currentDrdaRs.pkgcnstknStr == consistToken)
+			return;
+		currentDrdaRs = getDrdaResultSet(consistToken);
+
+	}
+
+	/**
+ 	 * Set currentDrdaResultSet 
+	 *
+	 * @String pkgnamcsn  The pkgid section number and unique resultset
+	 *                    consistency token
+	 *                 
+	 */
+	protected void setCurrentDrdaResultSet(String pkgnamcsn)
+	{
+		String consistToken = extractPkgcnstknStr(pkgnamcsn);
+		DRDAResultSet newDrdaRs = getDrdaResultSet(consistToken);
+		if (newDrdaRs != null)
+			currentDrdaRs = newDrdaRs;
+	}
+
+
+	/*
+	 * get DRDAResultSet by consistency token
+	 *
+	 */
+	private DRDAResultSet getDrdaResultSet(String consistToken)
+	{
+		if ( resultSetTable   == null || 
+			 (currentDrdaRs != null &&
+			  currentDrdaRs.pkgcnstknStr == consistToken ))
+		{
+			return currentDrdaRs;
+		}
+		else
+		{
+			return (DRDAResultSet) (resultSetTable.get(consistToken));
+		}
+	}
+	
+
+	/*
+	 * get DRDAResultSet by result set number
+	 *
+	 */
+	private DRDAResultSet getDrdaResultSet(int rsNum)
+	{
+		String consistToken = getResultSetPkgcnstknStr(rsNum);
+		return getDrdaResultSet(consistToken);
+	}
+
+
+	/*
+	 *  get consistency token from pkgnamcsn
+	 */
+	private String extractPkgcnstknStr(String pkgnamcsn)
+	{
+		StringTokenizer st = new StringTokenizer(pkgnamcsn);
+		st.nextToken();   // rdbnam (disregard)
+		st.nextToken();   // rdbcolid (disregard)
+		pkgid = st.nextToken();           // pkgid
+		sectionNumber = st.nextToken() ;  // secno
+		return st.nextToken();
+	}
+
+	/** Add a new resultSet to this statement.
+	 * Set as the current result set if  there is not an 
+	 * existing current resultset.
+	 * @param value - ResultSet to add
+	 * @return    Consistency token  for this resultSet
+	 *            For a single resultSet that is the same as the statement's 
+	 *            For multiple resultSets just the consistency token is changed 
+	 */
+	protected String  addResultSet(ResultSet value) throws SQLException
+	{
+
+		DRDAResultSet newDrdaRs = null;
+
+		int rsNum = numResultSets;
+		String newRsPkgcnstknStr = calculateResultSetPkgcnstknStr(rsNum);
+
+		if (rsNum == 0)
+			newDrdaRs = currentDrdaRs;
+
+		else
+		{
+			newDrdaRs = new DRDAResultSet();
+
+			// Multiple resultSets we neeed to setup the hash table
+			if (resultSetTable == null)
+			{
+				// If hashtable doesn't exist, create it and store resultSet 0
+				// before we store our new resultSet.
+				// For just a single resultSet we don't ever create the Hashtable.
+				resultSetTable = new Hashtable();
+				resultSetTable.put(pkgcnstknStr,currentDrdaRs);
+				resultSetKeyList = new ArrayList();
+				resultSetKeyList.add(0,pkgcnstknStr);
+			}
+
+			resultSetTable.put(newRsPkgcnstknStr,newDrdaRs);
+			resultSetKeyList.add(rsNum, newRsPkgcnstknStr);
+		}
+
+		newDrdaRs.setResultSet(value);
+		newDrdaRs.setPkgcnstknStr(newRsPkgcnstknStr);
+		setRsDefaultOptions(newDrdaRs);
+		newDrdaRs.suspend();
+		numResultSets++;
+		return newRsPkgcnstknStr;
+	}
+
+	/**
+	 *
+	 * @return 	number of result sets
+	 */
+	protected int getNumResultSets()
+	{
+		return numResultSets;
+	}
+	
+	
+	/**
+	 * @param rsNum result set starting with 0
+	 * @return  consistency token (key) for the result set	 
+	 */
+	protected String getResultSetPkgcnstknStr(int rsNum)
+	{
+		if (rsNum == 0)
+			return pkgcnstknStr;
+		else 
+			return (String) resultSetKeyList.get(rsNum);			   
+	}
+
+
+	/** 
+	 * Set ResultSet DRDA DataTypes
+	 * @param drddaTypes for columns.
+	 **/
+	protected void setRsDRDATypes(int [] value)
+	{
+		currentDrdaRs.setRsDRDATypes(value);
+	}
+
+	/**
+	 *@return ResultSet DRDA DataTypes
+	 **/
+
+	protected int[] getRsDRDATypes()
+	{
+		return currentDrdaRs.getRsDRDATypes();
+
+	}
+
+
+	/** 
+	 * Set ResultSet DRDA DataTypes Lengths
+	 * @param drddaTypes for columns.
+	 **/
+	protected void setRsLens(int [] value)
+	{
+		currentDrdaRs.rsLens = value;
+
+	}
+
+	/**
+	 *@return ResultSet DRDA DataTypes Lengths
+	 **/
+
+	protected int[] getRsLens()
+	{
+		return currentDrdaRs.rsLens;
+	}
+
+	/**
+	 *  Close the current resultSet
+	 */
+	protected void rsClose() throws SQLException
+	{
+		if (currentDrdaRs.getResultSet() == null) 
+			return;
+
+		currentDrdaRs.close();
+		needsToSendParamData = false;		
+		numResultSets--;
+	}
+
+	/**
+	 * Explicitly close the result set by CLSQRY
+	 * needed to check for double close.
+	 */
+	protected void CLSQRY()
+	{
+		currentDrdaRs.CLSQRY();
+	}
+
+	/* 
+	 * @return whether CLSQRY has been called on the
+	 *         current result set.
+	 */
+	protected boolean wasExplicitlyClosed()
+	{
+		return currentDrdaRs.wasExplicitlyClosed();
+	}
+
+	/** Clean up statements and resultSet
+	 * 
+	 */
+	protected void close()  throws SQLException
+	{
+		
+		if (ps != null)
+			ps.close();
+		if (stmt != null)
+			stmt.close();
+		rsClose();
+		resultSetTable = null;
+		resultSetKeyList = null;
+		numResultSets = 0;
+		ps = null;
+		stmt = null;
+		scrollType = 0;
+		concurType = 0;
+		withHoldCursor = -1;
+		rowCount = 0;
+		rslsetflg = null;
+		maxrslcnt = 0;
+		procName = null;
+		outputTypes = null;
+		outputExpected = false;
+		isCall = false;
+		explicitlyPrepared = false;
+		cliParamDrdaTypes = null;
+		cliParamLens = null;
+		cliParamExtPositions = null;
+
+	}	
+
+	/**
+	 * is Statement closed
+	 * @return whether the statement is closed
+	 */
+	protected boolean rsIsClosed()
+	{
+		return currentDrdaRs.isClosed();
+	}
+	
+	/**
+	 * Set state to SUSPENDED (result set is opened)
+	 */
+	protected void rsSuspend()
+	{
+		currentDrdaRs.suspend();
+	}
+
+
+	/**
+	 * set resultset/out parameter precision
+	 *
+	 * @param index - starting with 1
+	 * @param precision
+	 */
+	protected void setRsPrecision(int index, int precision)
+	{
+		currentDrdaRs.setRsPrecision(index,precision);
+	}
+
+	/**
+	 * get resultset /out paramter precision
+	 * @param index -starting with 1
+	 * @return precision of column
+	 */
+	protected int getRsPrecision(int index)
+	{
+		return currentDrdaRs.getRsPrecision(index);
+	}
+
+	/**
+	 * set resultset/out parameter scale
+	 *
+	 * @param index - starting with 1
+	 * @param scale
+	 */
+	protected void setRsScale(int index, int scale)
+	{
+		currentDrdaRs.setRsScale(index, scale);
+	}
+
+	/**
+	 * get resultset /out paramter scale
+	 * @param index -starting with 1
+	 * @return scale of column
+	 */
+	protected int  getRsScale(int index)
+	{
+		return currentDrdaRs.getRsScale(index);
+	}
+	
+
+	/**
+	 * set result  DRDAType
+	 *
+	 * @param index - starting with 1
+	 * @param type
+	 */
+	protected  void setRsDRDAType(int index, int type)
+	{
+		currentDrdaRs.setRsDRDAType(index,type);
+		
+	}
+
+	
+	/**
+	 * get parameter DRDAType
+	 *
+	 * @param index - starting with 1
+	 * @return  DRDA Type of column
+	 */
+	protected int getParamDRDAType(int index)
+	{
+		
+		return ((Byte)cliParamDrdaTypes.get(index -1)).intValue();
+	}
+
+
+	/**
+	 * set param  DRDAType
+	 *
+	 * @param index - starting with 1
+	 * @param type
+	 */
+	protected  void setParamDRDAType(int index, byte type)
+	{
+		cliParamDrdaTypes.addElement(new Byte(type));
+		
+	}
+	/**
+	 * returns drda length of parameter as sent by client.
+	 * @param index
+	 * @return data length
+
+	 */
+
+	protected int getParamLen(int index)
+	{
+		return ((Integer) cliParamLens.elementAt(index -1)).intValue();
+	}
+	/**
+	 *  get parameter precision or DB2 max (31)
+	 *
+	 *  @param index parameter index starting with 1
+	 *
+	 *  @return  precision
+	 */
+	protected int getParamPrecision(int index) throws SQLException
+	{
+		if (ps != null && ps instanceof CallableStatement)
+		{
+			EmbedParameterSetMetaData pmeta = 	((EmbedCallableStatement)
+											 ps).getEmbedParameterSetMetaData();
+			return Math.min(pmeta.getPrecision(index),
+							FdocaConstants.NUMERIC_MAX_PRECISION);
+
+		}
+		else 
+			return -1;
+	}
+	
+	/**
+	 *  get parameter scale or DB2 max (31)
+	 *
+	 *  @param index parameter index starting with 1
+	 *
+	 *  @return  scale
+	 */
+	protected int getParamScale(int index) throws SQLException
+	{
+		if (ps != null && ps instanceof CallableStatement)
+		{
+			EmbedParameterSetMetaData pmeta = 	((EmbedCallableStatement)
+											 ps).getEmbedParameterSetMetaData();
+			return Math.min(pmeta.getScale(index),FdocaConstants.NUMERIC_MAX_PRECISION);
+		}
+		else 
+			return -1;
+	}
+
+	/**
+	 * save parameter len sent by client
+	 * @param index parameter index starting with 1
+	 * @param value  length of data value
+	 *
+	 */
+	protected void  setParamLen(int index, int value)
+	{
+		cliParamLens.add(index -1, new Integer(value));
+	}
+
+	/**
+	 * get the number of parameters for this statement
+	 * 
+	 * @return number of parameters
+	 */
+	protected int getNumParams()
+	{
+		if (cliParamDrdaTypes != null)
+			return cliParamDrdaTypes.size();
+		else
+			return 0;
+	}
+	   
+	/** 
+	 * get the number of result set columns for the current resultSet
+	 * 
+	 * @return number of columns
+	 */
+
+	protected int getNumRsCols()
+	{
+		int[] rsDrdaTypes = currentDrdaRs.getRsDRDATypes();
+		if (rsDrdaTypes != null)
+			return rsDrdaTypes.length;
+		else 
+			return 0;
+	}
+
+	/**
+	 * get  resultset/out parameter DRDAType
+	 *
+	 * @param index - starting with 1
+	 * @return  DRDA Type of column
+	 */
+	protected int getRsDRDAType(int index)
+	{
+		return currentDrdaRs.getRsDRDAType(index);
+	}
+
+	/**
+	 * get resultset/out parameter DRDALen
+	 * @param index starting with 1
+	 * 
+	 * @return length of drda data
+	 */
+	 
+	protected int getRsLen(int index)
+	{
+		return currentDrdaRs.getRsLen(index);
+	}
+
+	/**
+	 * set resultset column data length
+	 * @param index starting with 1
+	 * @value length
+	 */
+	protected void  setRsLen(int index, int value)
+	{
+		currentDrdaRs.setRsLen(index,value);
+	}
+
+	/**
+	 * return whether this is a procedure
+	 * 
+	 * @return true if procName is not null 
+	 * RESOLVE: (should we check for isCall or is this good enough)
+	 */ 
+	public  boolean isProcedure()
+	{
+		return (procName != null);
+	}
+
+
+	/**
+	 * @param rsNum  - result set # starting with 0 
+	 */
+	public String getResultSetCursorName(int rsNum) throws SQLException
+	{
+		ResultSet rs = getResultSet(rsNum);
+		return rs.getCursorName();			
+
+	}
+
+
+	protected String toDebugString(String indent)
+	{
+		ResultSet rs = currentDrdaRs.getResultSet();
+		
+		String s ="";
+		if (ps == null) 
+			s += indent + ps;
+		else
+		{
+			s += indent + pkgid + sectionNumber ;
+			s += "\t" + ((EmbedPreparedStatement) ps).getSQLText();
+		}
+		return s;
+	}
+
+	/**  For a single result set, just echo the consistency token that the client sent us.
+	 * For subsequent resultSets, just subtract the resultset number from
+	 * the consistency token and that will differentiate the result sets.
+	 * This seems to be what DB2 does
+	 * @param rsNum  - result set # starting with 0
+	 * 
+	 * @return  Consistency token for result set
+	 */
+
+	protected String calculateResultSetPkgcnstknStr(int rsNum)
+	{	
+		String consistToken = pkgcnstknStr;
+
+		if (rsNum == 0 || pkgcnstknStr == null)
+			return consistToken;
+		else
+		{
+			try {
+				BigInteger  consistTokenBi = 
+					new BigInteger(consistToken.getBytes(DB2jServerImpl.DEFAULT_ENCODING));
+				BigInteger rsNumBi = BigInteger.valueOf(rsNum);
+				consistTokenBi = consistTokenBi.subtract(rsNumBi);
+				consistToken = new String(consistTokenBi.toByteArray(),DB2jServerImpl.DEFAULT_ENCODING);
+			}
+			catch (UnsupportedEncodingException e)
+			{// Default encoding always supported
+			}
+		}
+		return consistToken;
+	}
+
+	protected boolean isCallableStatement()
+	{
+		return isCall;
+	}
+
+	private boolean isCallableSQL(String sql)
+	{
+		java.util.StringTokenizer tokenizer = new java.util.StringTokenizer
+			(sql, "\t\n\r\f=? (");
+		 String firstToken = tokenizer.nextToken();
+		 if (StringUtil.SQLEqualsIgnoreCase(firstToken, 
+											"call")) // captures CALL...and ?=CALL...
+			 return true;
+		 return false;
+				 
+	}
+
+	private void setupCallableStatementParams(CallableStatement cs) throws SQLException
+	{
+		EmbedParameterSetMetaData pmeta = 	((EmbedCallableStatement) cs).getEmbedParameterSetMetaData();
+		int numElems = pmeta.getParameterCount();
+
+		for ( int i = 0; i < numElems; i ++)
+		{
+			boolean outputFlag = false;
+			
+			int parameterMode = pmeta.getParameterMode(i + 1);
+			int parameterType = pmeta.getParameterType(i + 1);
+
+			switch (parameterMode) {
+				case JDBC30Translation.PARAMETER_MODE_IN:
+					break;
+				case JDBC30Translation.PARAMETER_MODE_OUT:
+				case JDBC30Translation.PARAMETER_MODE_IN_OUT:
+					outputFlag = true;
+					break;
+				case JDBC30Translation.PARAMETER_MODE_UNKNOWN:
+					// It's only unknown if array
+					String objectType = pmeta.getParameterClassName(i+1);
+					parameterType =
+						getOutputParameterTypeFromClassName(objectType);
+					if (parameterType  != NOT_OUTPUT_PARAM)
+						outputFlag = true;
+			}
+
+			if (outputFlag)
+			{
+				if (outputTypes == null) //not initialized yet, since previously none output
+				{
+					outputTypes = new int[numElems];
+					for (int j = 0; j < numElems; j++)
+						outputTypes[j] = NOT_OUTPUT_PARAM;  //default init value
+				}
+				// save the output type so we can register when we parse
+				// the SQLDTA
+				outputTypes[i] = parameterType;
+			}
+			
+		}
+	}
+
+
+
+	/** 
+		Given an object class  name get the paramameter type if the 
+		parameter mode is unknown.
+		
+		Arrays except for byte arrrays are assumed to be output parameters
+		TINYINT output parameters are going to be broken because there
+		is no way to differentiate them from binary input parameters.
+		@param objectName Class name of object being evaluated.
+		indicating if this an output parameter
+		@return type from java.sql.Types
+	**/
+	
+	protected static int getOutputParameterTypeFromClassName(String
+																	objectName)
+	{
+		
+		if (objectName.endsWith("[]"))
+		{
+					// For byte[] we are going to assume it is input.
+			// For TINYINT output params you gotta use 
+			//  object Integer[] or use a procedure				   
+					if (objectName.equals("byte[]"))
+					{
+						return NOT_OUTPUT_PARAM;
+							
+							//isOutParam[offset] = false;
+							//return java.sql.Types.VARBINARY;
+					}
+					
+					// Known arrays are output parameters
+					// otherwise we pass it's a JAVA_OBJECT
+					if (objectName.equals("java.lang.Byte[]"))
+						return java.sql.Types.TINYINT;
+					
+					if (objectName.equals("byte[][]"))
+						return java.sql.Types.VARBINARY;
+					if (objectName.equals("java.lang.String[]"))
+						return java.sql.Types.VARCHAR; 
+					if (objectName.equals("int[]") || 
+						objectName.equals("java.lang.Integer[]"))
+						return java.sql.Types.INTEGER;
+					else if (objectName.equals("long[]")
+							 || objectName.equals("java.lang.Long[]"))
+						return java.sql.Types.BIGINT;
+					else if (objectName.equals("java.math.BigDecimal[]"))
+						return java.sql.Types.NUMERIC;
+					else if (objectName.equals("boolean[]")  || 
+							 objectName.equals("java.lang.Boolean[]"))
+						return java.sql.Types.BIT;
+					else if (objectName.equals("short[]"))
+						return java.sql.Types.SMALLINT;
+					else if (objectName.equals("float[]") ||
+							 objectName.equals("java.lang.Float[]"))
+						return java.sql.Types.REAL;
+					else if (objectName.equals("double[]") ||
+							 objectName.equals("java.lang.Double[]"))
+						return java.sql.Types.DOUBLE;
+					else if (objectName.equals("java.sql.Date[]"))
+						return java.sql.Types.DATE;
+					else if (objectName.equals("java.sql.Time[]"))
+						return java.sql.Types.TIME;
+					else if (objectName.equals("java.sql.Timestamp[]"))
+						return java.sql.Types.TIMESTAMP;
+		}
+		// Not one of the ones we know. This must be a JAVA_OBJECT
+		return NOT_OUTPUT_PARAM;
+		//isOutParam[offset] = false;				
+		//return java.sql.Types.JAVA_OBJECT;
+
+	}
+	
+	
+	public void registerAllOutParams() throws SQLException
+	{
+		if (isCall && (outputTypes != null))
+			for (int i = 1; i <= outputTypes.length; i ++)
+				registerOutParam(i);
+		
+	}
+	
+	public void registerOutParam(int paramNum) throws SQLException
+	{
+		CallableStatement cs;
+		if (isOutputParam(paramNum))
+		{
+			cs = (CallableStatement) ps;
+			cs.registerOutParameter(paramNum, getOutputParamType(paramNum));
+		}
+	}
+
+	protected boolean hasOutputParams()
+	{
+		return (outputTypes != null);
+	}
+
+	/**
+	 * is  parameter an ouput parameter
+	 * @param paramNum parameter number starting with 1.
+	 * return true if this is an output parameter.
+	 */
+	boolean isOutputParam(int paramNum)
+	{
+		if (outputTypes != null)
+			return (outputTypes[paramNum - 1] != NOT_OUTPUT_PARAM);
+		return false;
+		
+	}
+	/** 
+	 * get type for output parameter. 
+	 *
+	 * @param paramNum - parameter number starting with 1
+	 * @return jdbcType or NOT_OUTPUT_PARAM if this is not an output parameter
+	 */
+	int getOutputParamType(int paramNum)
+	{
+		if (outputTypes != null)
+			return (outputTypes[ paramNum - 1 ]);
+		return NOT_OUTPUT_PARAM;
+	}
+
+	private boolean isDynamicPkgid(String pkgid)
+	{
+		char size = pkgid.charAt(3);
+		
+		//  separate attribute used for holdability in 5.1.60
+		// this is just for checking that it is a dynamic package
+		char holdability = pkgid.charAt(4); 			                                    
+		return (pkgid.substring(0,3).equals("SYS") && (size == 'S' ||
+													   size == 'L')
+				&& (holdability == 'H' || holdability == 'N'));
+		
+	}
+
+   
+	private  void parsePkgidToFindHoldability()
+	{
+		if (withHoldCursor != -1)
+			return;
+		//First, check if holdability was passed as a SQL attribute "WITH HOLD" for this prepare. If yes, then withHoldCursor
+		//should not get overwritten by holdability from package name and that is why the check for -1
+		if (isDynamicPkgid(pkgid))
+		{
+			if(pkgid.charAt(4) == 'N')
+				withHoldCursor = JDBC30Translation.CLOSE_CURSORS_AT_COMMIT;
+			else  
+				withHoldCursor = JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
+		}
+		else 
+		{
+			withHoldCursor = JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
+		
+		}
+	}
+}
+
+
+
+
+
+
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Database.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Database.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,356 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import org.apache.derby.iapi.tools.i18n.LocalizedResource;
+
+import org.apache.derby.impl.jdbc.EmbedConnection;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+/**
+	Database stores information about the current database
+	It is used so that a session may have more than one database
+*/
+class Database
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+	protected String dbName;			// database name 
+	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 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[] publicKeyIn;		// Security token from app requester
+	protected byte[] publicKeyOut;		// 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
+
+	private Connection conn;			// Connection to the database
+	private DRDAStatement defaultStatement; // default statement used 
+													   // for execute imm
+	private DRDAStatement currentStatement; // current statement we are working on
+	private Hashtable stmtTable;		// Hash table for storing statements
+
+
+	// constructor
+	/**
+	 * Database constructor
+	 * 
+	 * @param dbName	database name
+	 */
+	protected Database (String dbName)
+	{
+		this.dbName = dbName;
+		this.stmtTable = new Hashtable();
+		this.defaultStatement = new DRDAStatement(this);
+	}
+	/**
+	 * Set connection and create the SQL statement for the default statement
+	 *
+	 * @param conn Connection
+	 * @exception SQLException
+	 */
+	protected void setConnection(Connection conn)
+		throws SQLException
+	{
+		this.conn = conn;
+		defaultStatement.setStatement(conn);
+	}
+	/**
+	 * Get the connection
+	 *
+	 * @return connection
+	 */
+	protected Connection 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(String pkgnamcsn) 
+	{
+		currentStatement = defaultStatement;
+		currentStatement.setPkgnamcsn(pkgnamcsn);
+		return currentStatement;
+	}
+
+	/**
+	 * Get prepared statement based on pkgnamcsn
+	 *
+	 * @param pkgnamcsn - key to access statement
+	 * @return prepared statement
+	 */
+	protected PreparedStatement getPreparedStatement(String pkgnamcsn) 
+		throws SQLException
+	{
+		currentStatement = getDRDAStatement(pkgnamcsn);
+		if (currentStatement == null)
+			return null;
+		return currentStatement.getPreparedStatement();
+	}
+	
+	/**
+	 * Get a new DRDA statement and store it in the stmtTable if stortStmt is true
+	 * If possible recycle an existing statement
+	 * If we are asking for one with the same name it means it
+	 * was already closed.
+	 * @param pkgnamcsn  Package name and section
+	 * @return DRDAStatement  
+	 */
+	protected DRDAStatement newDRDAStatement(String pkgnamcsn)
+	throws SQLException
+	{
+		DRDAStatement stmt = getDRDAStatement(pkgnamcsn);
+		if (stmt != null)
+			stmt.close();
+		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(String pkgnamcsn) 
+		throws SQLException
+	{
+		// Need to get the short version because resultSets have different
+		// corelation ids.
+		String key = getStmtKey(pkgnamcsn);
+		DRDAStatement newStmt = null;
+
+		// If our current statement doesn't match,retrieve the statement
+		// and make it current if not null.
+		if (currentStatement == null || 
+			!key.equals(getStmtKey(currentStatement.getPkgnamcsn())));
+			{
+				newStmt  = (DRDAStatement) stmtTable.get(key);				
+			}
+			
+			if (newStmt != null)	 // don't blow away currentStatement if we can't find this one
+				currentStatement = newStmt;
+			else
+				return null;
+
+		// Set the correct result set.
+		currentStatement.setCurrentDrdaResultSet(pkgnamcsn);
+		return currentStatement;
+	}
+
+	/**
+	 * Get result set
+	 *
+	 * @param pkgnamcsn - key to access prepared statement
+	 * @return result set
+	 */
+	protected ResultSet getResultSet(String pkgnamcsn) throws SQLException
+	{
+		return getDRDAStatement(pkgnamcsn).getResultSet();
+	}
+	/**
+ 	 * Set result set
+	 *
+	 * @param value
+	 */
+	protected void setResultSet(ResultSet value) throws SQLException
+	{
+		currentStatement.setResultSet(value);
+	}
+	/**
+	 * Store DRDA prepared statement
+	 * @param  stmt	DRDA prepared statement
+	 */
+	protected void storeStatement(DRDAStatement stmt) throws SQLException
+	{
+		stmtTable.put(getStmtKey(stmt.getPkgnamcsn()), stmt);
+	}
+
+	protected void removeStatement(DRDAStatement stmt) throws SQLException
+	{
+		stmtTable.remove(stmt.getPkgnamcsn());
+		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();
+	}
+	/**
+	  * Close the connection and 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())
+			{
+				conn.rollback();
+				conn.close();
+			}
+		}
+		finally {
+			conn = null;
+			currentStatement = null;
+			defaultStatement = null;
+			stmtTable=null;
+		}
+	}
+
+	/**
+	 *  Set the internal isolation level to use for preparing statements.
+	 *  Subsequent prepares will use this isoalation level
+	 * @param internal isolation level 
+	 *
+	 * @throws SQLException
+	 * @see EmbedConnection#setPrepareIsolation
+	 * 
+	 */
+	protected void setPrepareIsolation(int level) throws SQLException
+	{
+		((EmbedConnection) conn).setPrepareIsolation(level);
+	}
+
+	protected int getPrepareIsolation() throws SQLException
+	{
+		return ((EmbedConnection) 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 String getStmtKey(String pkgnamcsn)
+	{
+		if (pkgnamcsn == null)
+			return null;
+		return  pkgnamcsn.substring(0,pkgnamcsn.length() - CodePoint.PKGCNSTKN_LEN);
+	}
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DecryptionManager.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DecryptionManager.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,378 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.security.KeyPairGenerator;
+import java.security.KeyPair;
+import javax.crypto.KeyAgreement;
+import javax.crypto.spec.DHParameterSpec;
+import javax.crypto.interfaces.DHPublicKey;
+import javax.crypto.spec.DHPublicKeySpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.KeyFactory;
+import java.security.PublicKey;
+import java.sql.SQLException;
+import java.math.BigInteger;
+
+/**
+ * This class is used to decrypt password and/or userid.
+ * It uses Diffie_Hellman algorithm to get the publick key and secret key, and then
+ * DES encryption is done using certain token (based on security mechanism) and 
+ * this side's own public key. Basically, this class is called when using a security
+ * mechanism that encrypts user ID and password (eusridpwd). This class uses IBM JCE
+ * to do Diffie_Hellman algorithm and DES encryption.
+ */
+
+public class DecryptionManager
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+  private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+  // DRDA's Diffie-Hellman agreed public value: prime.
+  private static final byte modulusBytes__[] = {
+    (byte)0xC6, (byte)0x21, (byte)0x12, (byte)0xD7,
+    (byte)0x3E, (byte)0xE6, (byte)0x13, (byte)0xF0,
+    (byte)0x94, (byte)0x7A, (byte)0xB3, (byte)0x1F,
+    (byte)0x0F, (byte)0x68, (byte)0x46, (byte)0xA1,
+    (byte)0xBF, (byte)0xF5, (byte)0xB3, (byte)0xA4,
+    (byte)0xCA, (byte)0x0D, (byte)0x60, (byte)0xBC,
+    (byte)0x1E, (byte)0x4C, (byte)0x7A, (byte)0x0D,
+    (byte)0x8C, (byte)0x16, (byte)0xB3, (byte)0xE3
+  };
+
+  //the prime value in BigInteger form. It has to be in BigInteger form because this
+  //is the form used in JCE library.
+  private static final BigInteger modulus__
+  = new BigInteger (1, modulusBytes__);
+
+  //  DRDA's Diffie-Hellman agreed public value: base.
+  private static final byte baseBytes__[] = {
+    (byte)0x46, (byte)0x90, (byte)0xFA, (byte)0x1F,
+    (byte)0x7B, (byte)0x9E, (byte)0x1D, (byte)0x44,
+    (byte)0x42, (byte)0xC8, (byte)0x6C, (byte)0x91,
+    (byte)0x14, (byte)0x60, (byte)0x3F, (byte)0xDE,
+    (byte)0xCF, (byte)0x07, (byte)0x1E, (byte)0xDC,
+    (byte)0xEC, (byte)0x5F, (byte)0x62, (byte)0x6E,
+    (byte)0x21, (byte)0xE2, (byte)0x56, (byte)0xAE,
+    (byte)0xD9, (byte)0xEA, (byte)0x34, (byte)0xE4
+  };
+
+  // The base value in BigInteger form. It has to be in BigInteger form because
+  //this is the form used in IBM JCE library.
+  private static final BigInteger base__ =
+    new BigInteger (1, baseBytes__);
+
+  //DRDA's Diffie-Hellman agreed exponential length
+  private static final int exponential_length__ = 255;
+
+  private KeyPairGenerator keyPairGenerator_;
+  private KeyPair keyPair_;
+  private KeyAgreement keyAgreement_;
+  private DHParameterSpec paramSpec_;
+
+  /**
+   * EncryptionManager constructor. In this constructor,DHParameterSpec,
+   * KeyPairGenerator, KeyPair, and KeyAgreement  are initialized.
+   *
+   * @throws SQLException that wraps any error
+   */
+  public DecryptionManager () throws SQLException
+  {
+    try {
+      if (java.security.Security.getProvider ("IBMJCE") == null) // IBMJCE is not installed, install it.
+        java.security.Security.addProvider ((java.security.Provider) Class.forName("IBMJCE").newInstance());
+      paramSpec_ = new DHParameterSpec (modulus__, base__, exponential_length__);
+      keyPairGenerator_ = KeyPairGenerator.getInstance ("DH", "IBMJCE");
+      keyPairGenerator_.initialize ((AlgorithmParameterSpec)paramSpec_);
+      keyPair_ = keyPairGenerator_.generateKeyPair();
+      keyAgreement_ = KeyAgreement.getInstance ("DH", "IBMJCE");
+      keyAgreement_.init (keyPair_.getPrivate());
+    }
+    catch (java.lang.ClassNotFoundException e) {
+      throw new SQLException ("java.lang.ClassNotFoundException is caught" +
+                              " when initializing EncryptionManager '" + e.getMessage() + "'");
+    }
+    catch (java.lang.IllegalAccessException e) {
+      throw new SQLException ("java.lang.IllegalAccessException is caught" +
+                              " when initializing EncryptionManager '" + e.getMessage() + "'");
+    }
+    catch (java.lang.InstantiationException e) {
+      throw new SQLException ("java.lang.InstantiationException is caught" +
+                              " when initializing EncryptionManager '" + e.getMessage() + "'");
+    }
+    catch (java.security.NoSuchProviderException e) {
+      throw new SQLException ("java.security.NoSuchProviderException is caught" +
+                              " when initializing EncryptionManager '" + e.getMessage() + "'");
+    }
+    catch (java.security.NoSuchAlgorithmException e) {
+      throw new SQLException ("java.security.NoSuchAlgorithmException is caught" +
+			      " when initializing EncryptionManager '" + e.getMessage() + "'");
+    }
+    catch (java.security.InvalidAlgorithmParameterException e) {
+      throw new SQLException ("java.security.InvalidAlgorithmParameterException is caught" +
+			      " when initializing EncryptionManager '" + e.getMessage() + "'");
+    }
+
+    catch (java.security.InvalidKeyException e) {
+      throw new SQLException ("java.security.InvalidKeyException is caught" +
+			      " when initializing EncryptionManager '" + e.getMessage() + "'");
+    }
+  }
+
+  /**
+   * This method generates the public key and returns it. This
+   * shared public key is the application server's connection key and will
+   * be exchanged with the application requester's connection key. This connection
+   * key will be put in the sectkn in ACCSECRD command and send to the application
+   * requester.
+   *
+   * @return  a byte array that is the application server's public key
+   */
+  public byte[] obtainPublicKey ()
+  {
+    //The encoded public key
+    byte[] publicEnc =   keyPair_.getPublic().getEncoded();
+
+    //we need to get the plain form public key because DRDA accepts plain form
+    //public key only.
+    BigInteger aPub = ((DHPublicKey) keyPair_.getPublic()).getY();
+    byte[] aPubKey = aPub.toByteArray();
+
+    //the following lines of code is to adjust the length of the key. PublicKey
+    //in JCE is in the form of BigInteger and it's a signed value. When tranformed
+    //to a Byte array form, normally this array is 32 bytes. However, if the
+    //value happens to take up all 32 X 8 bits and it is positive, an extra
+    //bit is needed and then a 33 byte array will be returned. Since DRDA can't
+    //recogize the 33 byte key, we check the length here, if the length is 33,
+    //we will just trim off the first byte (0) and get the rest of 32 bytes.
+    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];
+      return newKey;
+    }
+
+    //the following lines of code is to adjust the length of the key. Occasionally,
+    //the length of the public key is less than 32, the reason of this is that the 0 byte
+    //in the beginning is somehow not returned. So we check the length here, if the length
+    //is less than 32, we will pad 0 in the beginning to make the public key 32 bytes
+    if (aPubKey.length < 32) {
+      byte[] newKey = new byte[32];
+      int i;
+      for (i=0; i < 32-aPubKey.length; i++) {
+		newKey[i] = 0;
+      }
+      for (int j=i; j<newKey.length; j++)
+		newKey[j] = aPubKey[j-i];
+      return newKey;
+    }
+    return aPubKey;
+  }
+
+  /**
+   * This method is used to calculate the decryption token. DES encrypts the
+   * data using a token and the generated shared private key. The token used
+   * depends on the type of security mechanism being used:
+   * USRENCPWD - The userid is used as the token. The USRID is zero-padded to
+   * 8 bytes if less than 8 bytes or truncated to 8 bytes if greater than 8 bytes.
+   * EUSRIDPWD - The middle 8 bytes of the server's connection key is used as
+   * the token.  Decryption needs to use exactly the same token as encryption.
+   *
+   * @param  int     securityMechanism
+   * @param  byte[]  userid or server(this side)'s connection key
+   * @return byte[]  the decryption token
+   */
+  private byte[] calculateDecryptionToken (int securityMechanism, byte[] initVector)
+  {
+    byte[] token = new byte[8];
+
+    //USRENCPWD, the userid is used as token
+    if (securityMechanism == 7) {
+      if (initVector.length < 8) { //shorter than 8 bytes, zero padded to 8 bytes
+		for (int i=0; i<initVector.length; i++)
+		  token[i] = initVector[i];
+		for (int i=initVector.length; i<8; i++)
+	 	 token[i] = 0;
+      }
+      else {  //longer than 8 bytes, truncated to 8 bytes
+		for (int i=0; i<8; i++)
+		  token[i] = initVector[i];
+      }
+    }
+    //EUSRIDPWD - The middle 8 bytes of the server's connection key is used as
+    //the token.
+    else if (securityMechanism == 9) {
+      for (int i = 0; i < 8; i++) {
+		token[i] = initVector[i + 12];
+      }
+    }
+    return token;
+  }
+
+  /**
+   * This method generates a secret key using the application requester's
+   * public key, and decrypts the usreid/password with the middle 8 bytes of
+   * the generated secret key and a decryption token. Then it returns the
+   * decrypted data in a byte array.
+   *
+   * @param cipherText        The byte array form userid/password to decrypt.
+   * @param security mechanism
+   * @param initVector        The byte array which is used to calculate the
+   *                          decryption token for initializing the cipher
+   * @param sourcePublicKey   application requester (encrypter)'s public key.
+   * @return the decrypted data (plain text) in a byte array.
+   */
+  public byte[] decryptData (byte[] cipherText,
+			     int    securityMechanism,
+			     byte[] initVector,
+			     byte[] sourcePublicKey) throws SQLException
+  {
+    byte[] plainText = null;
+    byte[] token = calculateDecryptionToken (securityMechanism, initVector);
+    try {
+
+      //initiate a Diffie_Hellman KeyFactory object.
+      KeyFactory keyFac = KeyFactory.getInstance ("DH", "IBMJCE");
+
+      //Use server's public key to initiate a DHPublicKeySpec and then use
+      //this DHPublicKeySpec to initiate a publicKey object
+      BigInteger publicKey = new BigInteger (1, sourcePublicKey);
+      DHPublicKeySpec dhKeySpec = new DHPublicKeySpec (publicKey, modulus__, base__);
+      PublicKey pubKey = keyFac.generatePublic (dhKeySpec);
+
+      //Execute the first phase of DH keyagreement protocal.
+      keyAgreement_.doPhase (pubKey, true);
+
+      //generate the shared secret key. The application requestor's shared secret
+      //key should be exactly the same as the application server's shared secret
+      //key
+      byte[] sharedSecret = keyAgreement_.generateSecret();
+      byte[] newKey = new byte[32];
+
+      //We adjust the length here. If the length of secret key is 33 and the first byte is 0,
+      //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];
+      }
+      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];
+      }
+
+      //The Data Encryption Standard (DES) is going to be used to encrypt userid
+      //and password. DES is a block cipher; it encrypts data in 64-bit blocks.
+      //DRDA encryption uses DES CBC mode as defined by the FIPS standard
+      //DES CBC requires an encryption key and an 8 byte token to encrypt the data.
+      //The middle 8 bytes of Diffie-Hellman shared private key is used as the
+      //encryption key. The following code retrieves middle 8 bytes of the shared
+      //private key.
+      byte[] key = new byte[8];
+
+      //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];
+      }
+      else if (sharedSecret.length==33 || sharedSecret.length < 32) {
+		for (int i=0; i< 8;i++)
+		  key[i] = newKey[i+12];
+      }
+      else
+		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;
+		}
+	  }
+
+      //use this encryption key to initiate a SecretKeySpec object
+      SecretKeySpec desKey = new SecretKeySpec (key, "DES");
+
+      //We use DES in CBC mode because this is the mode used in DRDA. The
+      //encryption mode has to be consistent for encryption and decryption.
+      //CBC mode requires an initialization vector(IV) parameter. In CBC mode
+      //we need to initialize the Cipher object with an IV, which can be supplied
+      // using the javax.crypto.spec.IvParameterSpec class.
+      Cipher cipher= Cipher.getInstance ("DES/CBC/PKCS5Padding", "IBMJCE");
+
+      //generate a IVParameterSpec object and use it to initiate the
+      //Cipher object.
+      IvParameterSpec ivParam = new IvParameterSpec (token);
+
+      //initiate the Cipher using encryption mode, encryption key and the
+      //IV parameter.
+      cipher.init (javax.crypto.Cipher.DECRYPT_MODE, desKey,ivParam);
+
+      //Execute the final phase of encryption
+      plainText = cipher.doFinal (cipherText);
+    }
+    catch (java.security.NoSuchProviderException e) {
+      throw new SQLException ("java.security.NoSuchProviderException is caught "
+			      + "when encrypting data '" + e.getMessage() + "'");
+    }
+    catch (java.security.NoSuchAlgorithmException e) {
+      throw new SQLException ("java.security.NoSuchAlgorithmException is caught "
+			      + "when encrypting data '" + e.getMessage() + "'");
+    }
+    catch (java.security.spec.InvalidKeySpecException e) {
+      throw new SQLException ("java.security.InvalidKeySpecException is caught "
+			      + "when encrypting data");
+    }
+    catch (java.security.InvalidKeyException e) {
+      throw new SQLException ("java.security.InvalidKeyException is caught "
+			      + "when encrypting data '" + e.getMessage() + "'");
+    }
+    catch (javax.crypto.NoSuchPaddingException e) {
+      throw new SQLException ("javax.crypto.NoSuchPaddingException is caught "
+			      + "when encrypting data '" + e.getMessage() + "'");
+    }
+    catch (javax.crypto.BadPaddingException e) {
+      throw new SQLException ("javax.crypto.BadPaddingException is caught "
+			      + "when encrypting data '" + e.getMessage() + "'");
+    }
+    catch (java.security.InvalidAlgorithmParameterException e) {
+      throw new SQLException ("java.security.InvalidAlgorithmParameterException is caught "
+			      + "when encrypting data '" + e.getMessage() + "'");
+    }
+    catch (javax.crypto.IllegalBlockSizeException e) {
+      throw new SQLException ("javax.crypto.IllegalBlockSizeException is caught "
+			      + "when encrypting data '" + e.getMessage() + "'");
+    }
+    return plainText;
+  }
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssConstants.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssConstants.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,75 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+
+package org.apache.derby.impl.drda;
+
+/**
+	This class defines DSS constants that are shared in the classes implementing
+	the DRDA protocol.
+*/
+class DssConstants
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+  private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+
+  protected static final int MAX_DSS_LENGTH = 32767;
+
+  // Registered DSS identifier indicating DDM data (xD0 for DDM data).
+  protected static final int DSS_ID = 0xD0;
+
+  // DSS chaining bit.
+  protected static final int DSSCHAIN = 0x40;
+
+  // DSS chaining bit for continuation on error
+  protected static final int DSSCHAIN_ERROR_CONTINUE = 0x20;
+
+  // DSS chaining bit where next DSS has same correlation ID.
+  protected static final int DSSCHAIN_SAME_ID = 0x10;
+
+  // DSS formatter for an OBJDSS.
+  protected static final int DSSFMT_OBJDSS = 0x03;
+
+  // DSS formatter for an RPYDSS.
+  protected static final int DSSFMT_RPYDSS = 0x02;
+
+  // DSSformatter for an RQSDSS.
+  protected static final int DSSFMT_RQSDSS = 0x01;
+
+  // DSS request correlation id unknown value
+  protected static final int CORRELATION_ID_UNKNOWN = -1;
+
+  // DSS length continuation bit
+  protected static final int CONTINUATION_BIT = 0x8000;
+
+ // Registered SNA GDS identifier indicating DDM data (xD0 for DDM data).
+  static final int GDS_ID = 0xD0;
+
+  // GDS chaining bits.
+  static final int GDSCHAIN = 0x40;
+
+  // GDS chaining bits where next DSS has different correlation ID.
+  static final int GDSCHAIN_SAME_ID = 0x10;
+
+  // GDS formatter for an OBJDSS.
+  static final int GDSFMT_OBJDSS = 0x03;
+
+  // GDS formatter for an RPYDSS.
+  static final int GDSFMT_RPYDSS = 0x02;
+
+  // GDS formatter for an RQSDSS.
+  static final int GDSFMT_RQSDSS = 0x01;
+
+  // hide the default constructor
+  private DssConstants () {}
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,423 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derby.impl.drda;
+
+// Generic process and error tracing encapsulation.
+// This class also traces a DRDA communications buffer.
+// The value of the hex bytes are traced along with
+// the ascii and ebcdic translations.
+public class DssTrace
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+
+  private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+  // This class was implemented using character arrays to translate bytes
+  // into ascii and ebcdic.  The goal was to be able to quickly index into the
+  // arrays to find the characters.  Char arrays instead of strings were used as
+  // much as possible in an attempt to help speed up performance.
+  private static final String LIST_SEPARATOR = " # ";
+
+  // trace representation for a java null.
+  private static final String NULL_VALUE = "null";
+
+  // An array of characters used to translate bytes to ascii.
+  // The position in the array corresponds to the hex value of the
+  // character
+  private static final char asciiChar [] = {
+    // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //0
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //1
+    ' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/', //2
+    '0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?',  //3
+    '@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',  //4
+    'P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_', //5
+    '`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',  //6
+    'p','q','r','s','t','u','v','w','x','y','z','{','|','}','~','.',  //7
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //8
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //9
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //A
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //B
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //C
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //D
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //E
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'   //F
+  };
+
+
+  // This mapping table associates a codepoint to a String describing the codepoint.
+  // This is needed because the trace prints the
+  // first codepoint in send and receive buffers.
+  // This could be final but there is no need to create the mapping
+  // if tracing isn't used.  So... this array will only be created when
+  // the com buffer trace is started.  Note this ref is not protected
+  // by final and care must be taken if it's value needs to change.
+  private static CodePointNameTable codePointNameTable = null;
+
+  // This column position header is used to mark offsets into the trace.
+  private static final String colPosHeader =
+  "       0 1 2 3 4 5 6 7   8 9 A B C D E F   0123456789ABCDEF  0123456789ABCDEF";
+
+  // An array of characters used to translate bytes to ebcdic.
+  // The position in the array corresponds to the hex value of the
+  // character.
+  private static final char ebcdicChar[] = {
+    // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //0
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //1
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //2
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //3
+    ' ','.','.','.','.','.','.','.','.','.','.','.','<','(','+','|',  //4
+    '&','.','.','.','.','.','.','.','.','.','!','$','*',')',';','.',  //5
+    '-','/','.','.','.','.','.','.','.','.','|',',','%','_','>','?',  //6
+    '.','.','.','.','.','.','.','.','.','`',':','#','@','\'','=','"', //7
+    '.','a','b','c','d','e','f','g','h','i','.','.','.','.','.','.',  //8
+    '.','j','k','l','m','n','o','p','q','r','.','.','.','.','.','.',  //9
+    '.','~','s','t','u','v','w','x','y','z','.','.','.','.','.','.',  //A
+    '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.',  //B
+    '{','A','B','C','D','E','F','G','H','I','.','.','.','.','.','.',  //C
+    '}','J','K','L','M','N','O','P','Q','R','.','.','.','.','.','.',  //D
+    '\\','.','S','T','U','V','W','X','Y','Z','.','.','.','.','.','.', //E
+    '0','1','2','3','4','5','6','7','8','9','.','.','.','.','.','.'   //F
+  };
+
+
+  // An array of characters representing hex numbers.
+  private static final char hexDigit [] = {
+    '0','1','2','3','4','5','6','7',
+    '8','9','A','B','C','D','E','F'
+  };
+
+
+  // A PrintWriter is used in printing the trace.
+  private java.io.PrintWriter comBufferWriter = null;
+
+
+  // The receive header comes befor bytes which would be read from
+  // a Stream.
+  private static final String receiveHeader =
+  "       RECEIVE BUFFER:                     (ASCII)           (EBCDIC)";
+
+
+  // The send header comes before bytes which would be written to
+  // a Stream.
+  private static final String sendHeader =
+  "       SEND BUFFER:                        (ASCII)           (EBCDIC)";
+
+
+  // The space character is defined for convience.
+  private static final char spaceChar = ' ';
+
+
+  // This boolean indicates if the trace is on.
+  // It has been declared private now but may be made public at
+  // a later time.
+  private boolean comBufferTraceOn = false;
+
+
+  // The comBufferSync is an object used for serialization.
+  // This separate object is used because this trace code may
+  // get eventually placed into another class which performs
+  // method entry and exit tracing.  Since each trace may be writing
+  // to different logs, separate objects will be used to perform the
+  // synchronization.
+  private Boolean comBufferSync = new Boolean (true);
+
+
+  // The zero character is defined for convinience.
+  private static final char zeroChar = '0';
+
+  // The recevie constant is used to indicate that the bytes were read to a Stream.
+  // It indicates to this class that a receive header should be used.
+  protected static final int TYPE_TRACE_RECEIVE = 2;
+
+  // The send constant is used to indicate that the bytes were written to
+  // a Stream.  It indicates to this class that a send header should be used.
+  protected static final int TYPE_TRACE_SEND = 1;
+
+  // Query if trace is on.
+  // This is currently needed since the comBufferTrcOn flag is private.
+  protected boolean isComBufferTraceOn()
+  {
+    // The trace flag indicates if tracing is on.
+    return comBufferTraceOn;
+  }
+
+  // Start the communications buffer trace.
+  // The name of the file to place the trace is passed to this method.
+  // After calling this method, calls to isComBufferTraceOn() will return true.
+  protected void startComBufferTrace (String fileName)
+  {
+    synchronized (comBufferSync) {
+      try {
+        // Only start the trace if it is off.
+        if (comBufferTraceOn == false) {
+          // The writer will be buffered for effeciency.
+          comBufferWriter = new java.io.PrintWriter (new java.io.BufferedWriter (new java.io.FileWriter (fileName), 4096));
+          // Turn on the trace flag.
+          comBufferTraceOn = true;
+          // initialize the codepoint name table if it is null.
+          // this is done here so that the CodePointName objects
+          // aren't created if the trace isn't used (save some memory).
+          // this process should only be done once
+          // since after the table is created the ref will
+          // no longer be null.
+          if (DssTrace.codePointNameTable == null) {
+            codePointNameTable = new CodePointNameTable();
+          }
+        }
+      }
+      catch (java.io.IOException e) {
+        // The IOException is currently ignored.  Handling should be added.
+      }
+    }
+  }
+
+  // Stop the communications buffer trace.
+  // The trace file is flushed and closed.  After calling this method,
+  // calls to isComBufferTraceOn () will return false.
+  protected void stopComBufferTrace ()
+  {
+    synchronized (comBufferSync) {
+      // Only stop the trace if it is actually on.
+      if (comBufferTraceOn == true) {
+        // Turn of the trace flag.
+        comBufferTraceOn = false;
+        // Flush and close the writer used for tracing.
+        comBufferWriter.flush();
+        comBufferWriter.close();
+      }
+    }
+  }
+
+  // Write the communication buffer data to the trace.
+  // The data is passed in via a byte array.  The start and length of the data is given.
+  // The type is needed to indicate if the data is part of the send or receive buffer.
+  // The class name, method name, and trcPt number are also written to the trace.
+  // Not much checking is performed on the parameters.  This is done to help performance.
+  protected void writeComBufferData (byte[] buff,
+                                         int offset,
+                                         int len,
+                                         int type,
+                                         String className,
+                                         String methodName,
+                                         int trcPt)
+  {
+    // why don't we synchronize the method!!!
+
+    // Grab the lock to make sure another thread doesn't try to
+    // write data or close the writer.
+    synchronized (comBufferSync) {
+
+      // Only take action if the trace is on.
+      if (comBufferTraceOn) {
+
+        // Obtain an instance of the Calendar so a timestamp can be written.
+        // this call seems to slow things down a bit.
+        java.util.Calendar time = java.util.Calendar.getInstance();
+
+        // Print the timestamp, class name, method name, thread name, and tracepoint.
+        comBufferWriter.println ("       (" +
+                                 time.get (java.util.Calendar.YEAR) +
+                                 "." +
+                                 (time.get (java.util.Calendar.MONTH) + 1) +
+                                 "." +
+                                 time.get (java.util.Calendar.DAY_OF_MONTH) +
+                                 " " +
+                                 time.get (java.util.Calendar.HOUR_OF_DAY) +
+                                 ":" +
+                                 time.get (java.util.Calendar.MINUTE) +
+                                 ":" +
+                                 time.get (java.util.Calendar.SECOND) +
+                                 ") " +
+                                 className +
+                                 " " +
+                                 methodName +
+                                 " " +
+                                 Thread.currentThread().getName() +
+                                 " " +
+                                 trcPt);
+
+        // A newline is added for formatting.
+        comBufferWriter.println();
+
+        // The data will only be written if there is a non-zero positive length.
+        if (len != 0) {
+          String codePointName = null;
+          // If the length <= 10, lookup the first codepoint so it's name can be printed???
+          if (len >= 10) {
+            // Get the int value of the two byte unsigned codepoint.
+            int codePoint = getCodePoint (buff, offset+8);
+            codePointName = codePointNameTable.lookup (codePoint);
+          }
+
+          if (codePointName == null) {
+            // codePointName was still null so either < 10 bytes were given or
+            // the codepoint wasn't found in the table.  Just print the plain send header.
+            comBufferWriter.println (getHeader (type));
+          }
+          else {
+            // codePointName isn't null so the name of the codepoint will be printed.
+            printHeaderWithCodePointName (codePointName, type);
+          }
+
+          // Print the col position header in the trace.
+          comBufferWriter.println (colPosHeader);
+
+          // A char array will be used to translate the bytes to their character
+          // representations along with ascii and ebcdic representations.
+          char trcDump[] = new char[77];
+
+          // bCounter, aCounter, eCounter are offsets used to help position the characters
+          short bCounter = 7;
+          short aCounter = 43;
+          short eCounter = 61;
+
+          // The lines will be counted starting at zero.  This is hard coded since we are
+          // at the beginning.
+          trcDump[0] = DssTrace.zeroChar;
+          trcDump[1] = DssTrace.zeroChar;
+          trcDump[2] = DssTrace.zeroChar;
+          trcDump[3] = DssTrace.zeroChar;
+
+          // The 0's are already in the trace so bump the line counter up a row.
+          int lineCounter = 0x10;
+
+          // Make sure the character array has all blanks in it.
+          // Some of these blanks will be replaced later with values.
+          // The 0's were not wrote over.
+          for (int j = 4; j < 77; j++) {
+            trcDump[j] = DssTrace.spaceChar;
+          }
+
+          // i will maintain the position in the byte array to be traced.
+          int i = 0;
+
+          do {
+            // Get the unsigned value of the byte.
+            //                  int num = b[off++] & 0xff;
+            int num = (buff[offset] < 0)? buff[offset] + 256 : buff[offset]; // jev
+            offset++;
+            i++;
+            // Place the characters representing the bytes in the array.
+            trcDump[bCounter++] = DssTrace.hexDigit[((num >>> 4) & 0xf)];
+            trcDump[bCounter++] = DssTrace.hexDigit[(num & 0xf)];
+
+            // Place the ascii and ebcdc representations in the array.
+            trcDump[aCounter++] = DssTrace.asciiChar[num];
+            trcDump[eCounter++] = DssTrace.ebcdicChar[num];
+
+            if (((i%8) == 0)) {
+              if (((i%16) == 0)) {
+                // Print the array each time 16 bytes are processed.
+                comBufferWriter.println (trcDump);
+                if (i != len) {
+                  // Not yet at the end of the byte array.
+                  if ((len - i) < 16) {
+                    // This is the last line so blank it all out.
+                    // This keeps the last line looking pretty in case
+                    // < 16 bytes remain.
+                    for (int j = 0; j < trcDump.length; j++) {
+                      trcDump[j] = DssTrace.spaceChar;
+                    }
+                  }
+                  // Reset the counters.
+                  bCounter = 0;
+                  aCounter = 43;
+                  eCounter = 61;
+                  // Reset the lineCounter if it starts to get too large.
+                  if (lineCounter == 0xfff0) {
+                    lineCounter = 0;
+                  }
+                  // Place the characters representing the line counter in the array.
+                  trcDump[bCounter++] = DssTrace.hexDigit[((lineCounter >>> 12) & 0xf)];
+                  trcDump[bCounter++] = DssTrace.hexDigit[((lineCounter >>> 8) & 0xf)];
+                  trcDump[bCounter++] = DssTrace.hexDigit[((lineCounter >>> 4) & 0xf)];
+                  trcDump[bCounter++] = DssTrace.hexDigit[(lineCounter & 0xf)];
+                  bCounter += 3;
+                  // Bump up the line counter.
+                  lineCounter += 0x10;
+                }
+              }
+              else {
+                // 8 bytes were processed so move the counter to adjust for
+                // spaces between the columns of bytes.
+                bCounter += 2;
+              }
+            }
+            // do this until we all the data has been traced.
+          } while (i < len);
+
+          // print the last line and add some blank lines to make it easier to read.
+          if (len % 16 != 0) {
+            comBufferWriter.println (trcDump);
+          }
+          comBufferWriter.println();
+          comBufferWriter.println();
+        }
+        // Flush the writer.
+        comBufferWriter.flush();
+      }
+    }
+  }
+
+  // Gets the int value of the two byte unsigned codepoint.
+  private static int getCodePoint (byte[] buff, int offset)
+  {
+    return ((buff[offset++] & 0xff) << 8) +
+      ((buff[offset] & 0xff) << 0);
+  }
+
+  private static String getHeader (int type)
+  {
+    switch (type) {
+    case DssTrace.TYPE_TRACE_SEND:
+      return DssTrace.sendHeader;
+    case DssTrace.TYPE_TRACE_RECEIVE:
+      return DssTrace.receiveHeader;
+    default:
+      //  throw new !!!
+      return null;
+    }
+  }
+
+  private static int getStartPosition (int type)
+  {
+    switch (type) {
+    case DssTrace.TYPE_TRACE_SEND:
+      return 20; // This is right after 'SEND BUFFER: '.
+    case DssTrace.TYPE_TRACE_RECEIVE:
+      return 23; // This is right after 'RECEIVE BUFFER: '.
+    default:
+      //  throw new !!!
+      return 0;
+    }
+  }
+
+  private void printHeaderWithCodePointName (String codePointName, int type)
+  {
+    // Create a char array so some of the characters
+    // can be replaced with the name of the codepoint.
+    char headerArray[] = DssTrace.getHeader(type).toCharArray();
+
+    // At most, 16 character name will be used.  This is so
+    // the headers on top of the ascii and ebcdic rows aren't shifted.
+    int replaceLen = (codePointName.length() < 17) ? codePointName.length() : 16;
+
+    int offset = getStartPosition (type);
+    for (int i = 0; i < replaceLen; i++) {
+      headerArray[offset++] = codePointName.charAt (i); // make sure charAt() starts at 0!!!
+    }
+    comBufferWriter.println (headerArray);
+  }
+
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EbcdicCcsidManager.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EbcdicCcsidManager.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,171 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+   This program and the accompanying materials 
+   are made available under the terms of the Common Public License v1.0
+   which accompanies this distribution, and is available at
+   http://www.ibm.com/developerworks/oss/CPLv1.0.htm
+
+ */
+
+package org.apache.derby.impl.drda;
+
+/**
+ * A concrete implementation of a CcsidMgr used to convert
+ * between Java UCS2 and Ebcdic as needed to handle character
+ * DDM Parameters.  This implementation only supports converting
+ * from the ASCII invariant of UNICODE to Ebcdic.  This should
+ * be fine since this class is intended for converting
+ * DDM Parameter data only.
+ */
+public class EbcdicCcsidManager extends CcsidManager
+{
+	public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+
+	private static final int[] conversionArrayToEbcdic = {
+		0x0000,0x0001,0x0002,0x0003,0x0037,0x002d,0x002e,0x002f
+		,0x0016,0x0005,0x0025,0x000b,0x000c,0x000d,0x000e,0x000f
+		,0x0010,0x0011,0x0012,0x0013,0x003c,0x003d,0x0032,0x0026
+		,0x0018,0x0019,0x003f,0x0027,0x001c,0x001d,0x001e,0x001f
+		,0x0040,0x004f,0x007f,0x007b,0x005b,0x006c,0x0050,0x007d
+		,0x004d,0x005d,0x005c,0x004e,0x006b,0x0060,0x004b,0x0061
+		,0x00f0,0x00f1,0x00f2,0x00f3,0x00f4,0x00f5,0x00f6,0x00f7
+		,0x00f8,0x00f9,0x007a,0x005e,0x004c,0x007e,0x006e,0x006f
+		,0x007c,0x00c1,0x00c2,0x00c3,0x00c4,0x00c5,0x00c6,0x00c7
+		,0x00c8,0x00c9,0x00d1,0x00d2,0x00d3,0x00d4,0x00d5,0x00d6
+		,0x00d7,0x00d8,0x00d9,0x00e2,0x00e3,0x00e4,0x00e5,0x00e6
+		,0x00e7,0x00e8,0x00e9,0x004a,0x00e0,0x005a,0x005f,0x006d
+		,0x0079,0x0081,0x0082,0x0083,0x0084,0x0085,0x0086,0x0087
+		,0x0088,0x0089,0x0091,0x0092,0x0093,0x0094,0x0095,0x0096
+		,0x0097,0x0098,0x0099,0x00a2,0x00a3,0x00a4,0x00a5,0x00a6
+		,0x00a7,0x00a8,0x00a9,0x00c0,0x00bb,0x00d0,0x00a1,0x0007
+		,0x0020,0x0021,0x0022,0x0023,0x0024,0x0015,0x0006,0x0017
+		,0x0028,0x0029,0x002a,0x002b,0x002c,0x0009,0x000a,0x001b
+		,0x0030,0x0031,0x001a,0x0033,0x0034,0x0035,0x0036,0x0008
+		,0x0038,0x0039,0x003a,0x003b,0x0004,0x0014,0x003e,0x00ff
+		,0x0041,0x00aa,0x00b0,0x00b1,0x009f,0x00b2,0x006a,0x00b5
+		,0x00bd,0x00b4,0x009a,0x008a,0x00ba,0x00ca,0x00af,0x00bc
+		,0x0090,0x008f,0x00ea,0x00fa,0x00be,0x00a0,0x00b6,0x00b3
+		,0x009d,0x00da,0x009b,0x008b,0x00b7,0x00b8,0x00b9,0x00ab
+		,0x0064,0x0065,0x0062,0x0066,0x0063,0x0067,0x009e,0x0068
+		,0x0074,0x0071,0x0072,0x0073,0x0078,0x0075,0x0076,0x0077
+		,0x00ac,0x0069,0x00ed,0x00ee,0x00eb,0x00ef,0x00ec,0x00bf
+		,0x0080,0x00fd,0x00fe,0x00fb,0x00fc,0x00ad,0x00ae,0x0059
+		,0x0044,0x0045,0x0042,0x0046,0x0043,0x0047,0x009c,0x0048
+		,0x0054,0x0051,0x0052,0x0053,0x0058,0x0055,0x0056,0x0057
+		,0x008c,0x0049,0x00cd,0x00ce,0x00cb,0x00cf,0x00cc,0x00e1
+		,0x0070,0x00dd,0x00de,0x00db,0x00dc,0x008d,0x008e,0x00df
+	};
+
+	private static final int[] conversionArrayToUCS2 = {
+		0x0000,0x0001,0x0002,0x0003,0x009C,0x0009,0x0086,0x007F
+		,0x0097,0x008D,0x008E,0x000B,0x000C,0x000D,0x000E,0x000F
+		,0x0010,0x0011,0x0012,0x0013,0x009D,0x0085,0x0008,0x0087
+		,0x0018,0x0019,0x0092,0x008F,0x001C,0x001D,0x001E,0x001F
+		,0x0080,0x0081,0x0082,0x0083,0x0084,0x000A,0x0017,0x001B
+		,0x0088,0x0089,0x008A,0x008B,0x008C,0x0005,0x0006,0x0007
+		,0x0090,0x0091,0x0016,0x0093,0x0094,0x0095,0x0096,0x0004
+		,0x0098,0x0099,0x009A,0x009B,0x0014,0x0015,0x009E,0x001A
+		,0x0020,0x00A0,0x00E2,0x00E4,0x00E0,0x00E1,0x00E3,0x00E5
+		,0x00E7,0x00F1,0x005B,0x002E,0x003C,0x0028,0x002B,0x0021
+		,0x0026,0x00E9,0x00EA,0x00EB,0x00E8,0x00ED,0x00EE,0x00EF
+		,0x00EC,0x00DF,0x005D,0x0024,0x002A,0x0029,0x003B,0x005E
+		,0x002D,0x002F,0x00C2,0x00C4,0x00C0,0x00C1,0x00C3,0x00C5
+		,0x00C7,0x00D1,0x00A6,0x002C,0x0025,0x005F,0x003E,0x003F
+		,0x00F8,0x00C9,0x00CA,0x00CB,0x00C8,0x00CD,0x00CE,0x00CF
+		,0x00CC,0x0060,0x003A,0x0023,0x0040,0x0027,0x003D,0x0022
+		,0x00D8,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067
+		,0x0068,0x0069,0x00AB,0x00BB,0x00F0,0x00FD,0x00FE,0x00B1
+		,0x00B0,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,0x0070
+		,0x0071,0x0072,0x00AA,0x00BA,0x00E6,0x00B8,0x00C6,0x00A4
+		,0x00B5,0x007E,0x0073,0x0074,0x0075,0x0076,0x0077,0x0078
+		,0x0079,0x007A,0x00A1,0x00BF,0x00D0,0x00DD,0x00DE,0x00AE
+		,0x00A2,0x00A3,0x00A5,0x00B7,0x00A9,0x00A7,0x00B6,0x00BC
+		,0x00BD,0x00BE,0x00AC,0x007C,0x00AF,0x00A8,0x00B4,0x00D7
+		,0x007B,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047
+		,0x0048,0x0049,0x00AD,0x00F4,0x00F6,0x00F2,0x00F3,0x00F5
+		,0x007D,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F,0x0050
+		,0x0051,0x0052,0x00B9,0x00FB,0x00FC,0x00F9,0x00FA,0x00FF
+		,0x005C,0x00F7,0x0053,0x0054,0x0055,0x0056,0x0057,0x0058
+		,0x0059,0x005A,0x00B2,0x00D4,0x00D6,0x00D2,0x00D3,0x00D5
+		,0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037
+		,0x0038,0x0039,0x00B3,0x00DB,0x00DC,0x00D9,0x00DA,0x009F
+	};
+
+	EbcdicCcsidManager ()
+	{
+		super ((byte) 0x40, // 0x40 is the ebcdic space character
+		       (byte) 0x4B,
+		       new byte[] {
+		//      '0',       '1',      '2',        '3',      '4',
+		  (byte)0xf0,(byte)0xf1,(byte)0xf2,(byte)0xf3,(byte)0xf4,
+		//      '5',       '6',       '7',       '8',      '9',
+		  (byte)0xf5,(byte)0xf6,(byte)0xf7,(byte)0xf8,(byte)0xf9,
+		//      'A',       'B',       'C',       'D',      'E',
+		  (byte)0xc1,(byte)0xc2,(byte)0xc3,(byte)0xc4,(byte)0xc5,
+		//      'F',       'G',       'H',      'I',       'J',
+	  	  (byte)0xc6,(byte)0xc7,(byte)0xc8,(byte)0xc9,(byte)0xd1,
+		//     'K',        'L',       'M',       'N',      'O',
+		  (byte)0xd2,(byte)0xd3,(byte)0xd4,(byte)0xd5,(byte)0xd6,
+		//     'P'
+		  (byte)0xd7
+		}
+	  );
+	}
+
+	byte[] convertFromUCS2 (String sourceString)
+	{
+		byte[] bytes = new byte[sourceString.length()];
+		convertFromUCS2 (sourceString, bytes, 0);
+		return bytes;
+	}
+
+	int convertFromUCS2 (String sourceString,
+		       byte[] buffer,
+		       int offset)
+	{
+		for (int i=0; i < sourceString.length(); i++) {
+			char c = sourceString.charAt (i);
+			if (c > 0xff)
+				buffer[offset++] = (byte) 63; // what's this ???
+			else
+				buffer[offset++] = (byte) (conversionArrayToEbcdic [c]); ;
+		}
+
+		return offset;
+	}
+
+	String convertToUCS2 (byte[] sourceBytes)
+	{
+		int i = 0;
+		char[] theChars = new char[sourceBytes.length];
+		int num = 0;
+
+		for (i=0; i < sourceBytes.length; i++) {
+			num = (sourceBytes[i] < 0) ? (sourceBytes[i] + 256) : sourceBytes[i];
+			theChars[i] = (char) conversionArrayToUCS2[num];
+		}
+
+		return new String (theChars);
+	}
+
+	String convertToUCS2 (byte[] sourceBytes, int offset, int numToConvert)
+	{
+		int i = 0,j = 0;
+		char[] theChars = new char[numToConvert];
+		int num = 0;
+
+		for (i = offset; i < (offset + numToConvert); i++) {
+			num = (sourceBytes[i] < 0 ) ? (sourceBytes[i] + 256) : sourceBytes[i];
+			theChars[j] = (char) conversionArrayToUCS2[num];
+			j++;
+		}
+		return new String (theChars);
+	}
+
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,365 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derby.impl.drda;
+
+import java.sql.Types;
+import org.apache.derby.iapi.reference.JDBC30Translation;
+import java.sql.SQLException;
+import org.apache.derby.iapi.reference.DB2Limit;
+
+class FdocaConstants
+{
+/**
+   IBM Copyright &copy notice.
+*/
+
+public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+// DRDA FD:OCA constants.
+  static final int FDOCA_TYPE_FIXEDBYTES = 0x01;
+  static final int FDOCA_TYPE_NFIXEDBYTES = 0x81;
+  static final int FDOCA_TYPE_VARBYTES = 0x02;
+  static final int FDOCA_TYPE_NVARBYTES = 0x82;
+  static final int FDOCA_TYPE_NTBYTES = 0x03;
+  static final int FDOCA_TYPE_NNTBYTES = 0x83;
+  static final int FDOCA_TYPE_PSCLBYTE = 0x07;
+  static final int FDOCA_TYPE_NPSCLBYTE = 0x87;
+  static final int FDOCA_TYPE_FIXEDCHAR = 0x10;
+  static final int FDOCA_TYPE_NFIXEDCHAR = 0x90;
+  static final int FDOCA_TYPE_VARCHAR = 0x11;
+  static final int FDOCA_TYPE_NVARCHAR = 0x91;
+  static final int FDOCA_TYPE_NTCHAR = 0x14;
+  static final int FDOCA_TYPE_NNTCHAR = 0x94;
+  static final int FDOCA_TYPE_PSCLCHAR = 0x19;
+  static final int FDOCA_TYPE_NPSCLCHAR = 0x99;
+  static final int FDOCA_TYPE_INTEGER_BE = 0x23;
+  static final int FDOCA_TYPE_NINTEGER_BE = 0xA3;
+  static final int FDOCA_TYPE_INTEGER_LE = 0x24;
+  static final int FDOCA_TYPE_NINTEGER_LE = 0xA4;
+  static final int FDOCA_TYPE_DECIMAL = 0x30;
+  static final int FDOCA_TYPE_NDECIMAL = 0xB0;
+  static final int FDOCA_TYPE_NUMERIC_CHAR = 0x32;
+  static final int FDOCA_TYPE_NNUMERIC_CHAR = 0xB2;
+  static final int FDOCA_TYPE_ZDECIMAL_IBM = 0x33;   //370, 390, zOS and 400
+  static final int FDOCA_TYPE_NZDECIMAL_IBM = 0xB3;  //370, 390, zOS and 400
+  static final int FDOCA_TYPE_ZDECIMAL = 0x35;
+  static final int FDOCA_TYPE_NZDECIMAL = 0xB5;
+  static final int FDOCA_TYPE_FLOAT_370 = 0x40;
+  static final int FDOCA_TYPE_NFLOAT_370 = 0xC0;
+  static final int FDOCA_TYPE_FLOAT_X86 = 0x47;
+  static final int FDOCA_TYPE_NFLOAT_X86 = 0xC7;
+  static final int FDOCA_TYPE_FLOAT_IEEE = 0x48;   //including 400
+  static final int FDOCA_TYPE_NFLOAT_IEEE = 0xC8;  //including 400
+  static final int FDOCA_TYPE_FLOAT_VAX = 0x49;
+  static final int FDOCA_TYPE_NFLOAT_VAX = 0xC9;
+  static final int FDOCA_TYPE_LOBBYTES = 0x50;
+  static final int FDOCA_TYPE_NLOBBYTES = 0xD0;
+  static final int FDOCA_TYPE_LOBCHAR = 0x51;
+  static final int FDOCA_TYPE_NLOBCHAR = 0xD1;
+
+  // DRDA Type constants.
+  static final int DRDA_TYPE_INTEGER = 0x02;
+  static final int DRDA_TYPE_NINTEGER = 0x03;
+  static final int DRDA_TYPE_SMALL = 0x04;
+  static final int DRDA_TYPE_NSMALL = 0x05;
+  static final int DRDA_TYPE_1BYTE_INT = 0x06;
+  static final int DRDA_TYPE_N1BYTE_INT = 0x07;
+  static final int DRDA_TYPE_FLOAT16 = 0x08;
+  static final int DRDA_TYPE_NFLOAT16 = 0x09;
+  static final int DRDA_TYPE_FLOAT8 = 0x0A;
+  static final int DRDA_TYPE_NFLOAT8 = 0x0B;
+  static final int DRDA_TYPE_FLOAT4 = 0x0C;
+  static final int DRDA_TYPE_NFLOAT4 = 0x0D;
+  static final int DRDA_TYPE_DECIMAL = 0x0E;
+  static final int DRDA_TYPE_NDECIMAL = 0x0F;
+  static final int DRDA_TYPE_ZDECIMAL = 0x10;
+  static final int DRDA_TYPE_NZDECIMAL = 0x11;
+  static final int DRDA_TYPE_NUMERIC_CHAR = 0x12;
+  static final int DRDA_TYPE_NNUMERIC_CHAR = 0x13;
+  static final int DRDA_TYPE_RSET_LOC = 0x14;
+  static final int DRDA_TYPE_NRSET_LOC = 0x15;
+  static final int DRDA_TYPE_INTEGER8 = 0x16;
+  static final int DRDA_TYPE_NINTEGER8 = 0x17;
+  static final int DRDA_TYPE_LOBLOC = 0x18;
+  static final int DRDA_TYPE_NLOBLOC = 0x19;
+  static final int DRDA_TYPE_CLOBLOC = 0x1A;
+  static final int DRDA_TYPE_NCLOBLOC = 0x1B;
+  static final int DRDA_TYPE_DBCSCLOBLOC = 0x1C;
+  static final int DRDA_TYPE_NDBCSCLOBLOC = 0x1D;
+  static final int DRDA_TYPE_ROWID = 0x1E;
+  static final int DRDA_TYPE_NROWID = 0x1F;
+  static final int DRDA_TYPE_DATE = 0x20;
+  static final int DRDA_TYPE_NDATE = 0x21;
+  static final int DRDA_TYPE_TIME = 0x22;
+  static final int DRDA_TYPE_NTIME = 0x23;
+  static final int DRDA_TYPE_TIMESTAMP = 0x24;
+  static final int DRDA_TYPE_NTIMESTAMP = 0x25;
+  static final int DRDA_TYPE_FIXBYTE = 0x26;
+  static final int DRDA_TYPE_NFIXBYTE = 0x27;
+  static final int DRDA_TYPE_VARBYTE = 0x28;
+  static final int DRDA_TYPE_NVARBYTE = 0x29;
+  static final int DRDA_TYPE_LONGVARBYTE = 0x2A;
+  static final int DRDA_TYPE_NLONGVARBYTE = 0x2B;
+  static final int DRDA_TYPE_NTERMBYTE = 0x2C;
+  static final int DRDA_TYPE_NNTERMBYTE = 0x2D;
+  static final int DRDA_TYPE_CSTR = 0x2E;
+  static final int DRDA_TYPE_NCSTR = 0x2F;
+  static final int DRDA_TYPE_CHAR = 0x30;
+  static final int DRDA_TYPE_NCHAR = 0x31;
+  static final int DRDA_TYPE_VARCHAR = 0x32;
+  static final int DRDA_TYPE_NVARCHAR = 0x33;
+  static final int DRDA_TYPE_LONG = 0x34;
+  static final int DRDA_TYPE_NLONG = 0x35;
+  static final int DRDA_TYPE_GRAPHIC = 0x36;
+  static final int DRDA_TYPE_NGRAPHIC = 0x37;
+  static final int DRDA_TYPE_VARGRAPH = 0x38;
+  static final int DRDA_TYPE_NVARGRAPH = 0x39;
+  static final int DRDA_TYPE_LONGRAPH = 0x3A;
+  static final int DRDA_TYPE_NLONGRAPH = 0x3B;
+  static final int DRDA_TYPE_MIX = 0x3C;
+  static final int DRDA_TYPE_NMIX = 0x3D;
+  static final int DRDA_TYPE_VARMIX = 0x3E;
+  static final int DRDA_TYPE_NVARMIX = 0x3F;
+  static final int DRDA_TYPE_LONGMIX = 0x40;
+  static final int DRDA_TYPE_NLONGMIX = 0x41;
+  static final int DRDA_TYPE_CSTRMIX = 0x42;
+  static final int DRDA_TYPE_NCSTRMIX = 0x43;
+  static final int DRDA_TYPE_PSCLBYTE = 0x44;
+  static final int DRDA_TYPE_NPSCLBYTE = 0x45;
+  static final int DRDA_TYPE_LSTR = 0x46;
+  static final int DRDA_TYPE_NLSTR = 0x47;
+  static final int DRDA_TYPE_LSTRMIX = 0x48;
+  static final int DRDA_TYPE_NLSTRMIX = 0x49;
+  static final int DRDA_TYPE_SDATALINK = 0x4C;
+  static final int DRDA_TYPE_NSDATALINK = 0x4D;
+  static final int DRDA_TYPE_MDATALINK = 0x4E;
+  static final int DRDA_TYPE_NMDATALINK = 0x4F;
+
+  // --- Override LIDs 0x50 - 0xAF
+  static final int DRDA_TYPE_LOBBYTES = 0xC8;
+  static final int DRDA_TYPE_NLOBBYTES = 0xC9;
+  static final int DRDA_TYPE_LOBCSBCS = 0xCA;
+  static final int DRDA_TYPE_NLOBCSBCS = 0xCB;
+  static final int DRDA_TYPE_LOBCDBCS = 0xCC;
+  static final int DRDA_TYPE_NLOBCDBCS = 0xCD;
+  static final int DRDA_TYPE_LOBCMIXED = 0xCE;
+  static final int DRDA_TYPE_NLOBCMIXED = 0xCF;
+
+  static final int CPT_TRIPLET_TYPE = 0x7F;      // CPT triplet type
+  static final int MDD_TRIPLET_TYPE = 0x78;      // MDD triplet type
+  static final int NGDA_TRIPLET_TYPE = 0x76;     // N-GDA triplet type
+  static final int RLO_TRIPLET_TYPE = 0x71;      // RLO triplet type
+  static final int SDA_TRIPLET_TYPE = 0x70;      // SDA triplet type
+
+  static final int SDA_MD_TYPE = 1;              // SDA MD type
+  static final int GDA_MD_TYPE = 2;              // GDA MD type
+  static final int ROW_MD_TYPE = 3;              // Row MD type
+
+  static final int SQLCADTA_LID = 0xE0;
+  static final int SQLDTAGRP_LID = 0xD0;         // SQLDTAGRP LID
+  static final int NULL_LID = 0x00;
+
+  static final int INDICATOR_NULLABLE = 0x00;
+  static final int NULL_DATA = 0xFF;
+  static final int TYP_NULLIND = 1;
+  static final int MAX_ENV_LID = 0x49;           // Largest possible N-GDA/CPT repeating
+
+  static final int MAX_VARS_IN_NGDA = 84;        // Number of SQLVARs in full SQLDTAGRP
+                                                 // N-GDA or CPT
+  static final int FULL_NGDA_SIZE = 255;         // Size of full SQLDTAGRP N-GDA or CPT
+  static final int MDD_TRIPLET_SIZE = 7;         // Size of MDD triplet
+  static final int SDA_TRIPLET_SIZE = 12;        // Size of SDA triplet
+  static final int SQLDTA_RLO_SIZE = 6;          // Size of SQLDTA RLO triplet
+  static final int RLO_RPT_GRP_SIZE = 3;         // Size of RLO repeating group
+  static final int SQLDTAGRP_SIZE = 3;           // Size of SQLDTAGRP descriptor
+  static final int CPT_SIZE = 3;                 // Size of CPT descriptor
+  static final int FDODSC_FOOTER_SIZE = 6;       // Size of regular FDODSC "footer" (RLO)
+  static final int SQLDTAGRP_COL_DSC_SIZE = 3;   // Env. LID & len. bytes
+  static final int MAX_OVERRIDES = 250;          // Max nbr of overrides via pairs of MDD + SDA
+  static final int MDD_REST_SIZE = 5;            // Size of the MDD group minus length and type
+
+  // Hard-coded SQLCADTA MDD
+  static final byte[] SQLCADTA_MDD = {
+    (byte)0x07, (byte)0x78, (byte)0x00,
+    (byte)0x05, (byte)0x03, (byte)0x01,
+    (byte)0xE0
+  };
+
+  // Hard-coded SQLDTA MDD
+  static final byte[] SQLDTA_MDD = {
+    (byte)0x07, (byte)0x78, (byte)0x00,
+    (byte)0x05, (byte)0x04, (byte)0x01,
+    (byte)0xF0
+  };
+
+  // Hard-coded SQLDTA MDD
+  static final byte[] SQLDTAGRP_MDD = {
+    (byte)0x07, (byte)0x78, (byte)0x00,
+    (byte)0x05, (byte)0x02, (byte)0x01,
+    (byte)0xD0
+  };
+
+  // Hard-coded SQLCADTA+SQLDTARD footer bytes
+  static final byte[] SQLCADTA_SQLDTARD_RLO = {
+    (byte)0x09, (byte)0x71, (byte)0xE0,   // SQLCADTA
+    (byte)0x54, (byte)0x00, (byte)0x01,
+    (byte)0xD0, (byte)0x00, (byte)0x01,
+    (byte)0x06, (byte)0x71, (byte)0xF0,   // SQLDTARD
+    (byte)0xE0, (byte)0x00, (byte)0x00
+  };
+
+  // Hard-coded SQLDTA RLO
+  static final byte[] SQLDTA_RLO = {
+    (byte)0x06, (byte)0x71, (byte)0xE4,
+    (byte)0xD0, (byte)0x00, (byte)0x01
+  };
+
+  static final int SQLCADTA_SQLDTARD_RLO_SIZE = SQLCADTA_SQLDTARD_RLO.length;
+
+	protected static boolean isNullable(int fdocaType)
+	{
+		return ( (fdocaType & 1) == 1);
+	}
+
+	// The maxumum length for LONG VARCHAR RETURN RESULTS IS
+	// 64K, since we send an unsigned short.  We should be
+	// able to send the number of bytes in which we encode the
+	// length as 4 (or more) , but JCC does not support this yet.
+	// JAVA_OBJECTS are returned as LONG VARCHAR values by calling
+	// their toString() method and their limit is 64K as well.
+	// BUT, that said, we ultimately have to match DB2's limit,
+	// so just use that...
+	protected static int LONGVARCHAR_MAX_LEN = DB2Limit.DB2_LONGVARCHAR_MAXWIDTH;
+	protected static int LONGVARBINARY_MAX_LEN = DB2Limit.DB2_LONGVARCHAR_MAXWIDTH;
+	protected static int LONGVARCHAR_LEN_NUMBYTES = 2;
+
+	// JCC  only supports a max precision of 31 like DB2
+	protected static int NUMERIC_MAX_PRECISION=31;
+	protected static int NUMERIC_DEFAULT_PRECISION=NUMERIC_MAX_PRECISION;
+	protected static int NUMERIC_DEFAULT_SCALE=15;
+
+	/***
+	 * Map jdbctype to fdoca drda type
+	 * @param jdbcType - Jdbc type for mappingy
+	 * @param nullable - true if type is nullable
+	 * @param outlen - output parameter with length of type.
+	 * @return standard drdaTypeLength. -1 if we don't know.
+	 **/
+	protected static int mapJdbcTypeToDrdaType(int jdbcType, boolean nullable,
+											   int[] outlen)
+		throws SQLException
+	{
+
+		int drdaType = 0;
+		switch (jdbcType) {
+			case JDBC30Translation.BOOLEAN:
+			case java.sql.Types.BIT:
+			case java.sql.Types.TINYINT:
+			case java.sql.Types.SMALLINT:
+				drdaType = FdocaConstants.DRDA_TYPE_NSMALL;
+				outlen[0] = 2;
+				break;
+			case java.sql.Types.INTEGER:
+				drdaType = FdocaConstants.DRDA_TYPE_NINTEGER;
+				outlen[0] = 4;
+				break;
+			case java.sql.Types.BIGINT:
+				drdaType = FdocaConstants.DRDA_TYPE_NINTEGER8;
+				outlen[0] = 8;
+				break;
+			case java.sql.Types.REAL:
+				drdaType = FdocaConstants.DRDA_TYPE_NFLOAT4;
+				outlen[0] = 4;
+				break;
+			case java.sql.Types.DOUBLE:
+			case java.sql.Types.FLOAT:
+				drdaType = FdocaConstants.DRDA_TYPE_NFLOAT8;
+				outlen[0] = 8;
+				break;
+			case java.sql.Types.NUMERIC:
+			case java.sql.Types.DECIMAL:
+				drdaType = FdocaConstants.DRDA_TYPE_NDECIMAL;
+				//needs to be adjusted for actual value
+				outlen[0] = -1;
+				break;
+			case java.sql.Types.DATE:
+				drdaType = FdocaConstants.DRDA_TYPE_NDATE;
+				outlen[0] = 10;
+				break;
+			case java.sql.Types.TIME:
+				drdaType = FdocaConstants.DRDA_TYPE_NTIME;
+				outlen[0] = 8;
+				break;
+			case java.sql.Types.TIMESTAMP:
+				drdaType = FdocaConstants.DRDA_TYPE_NTIMESTAMP;
+				outlen[0] = 26;
+				break;
+			case java.sql.Types.CHAR:
+//				drdaType = FdocaConstants.DRDA_TYPE_NCHAR;
+				//making this NVARMIX for now to handle different byte length
+				//characters - checking with Paul to see if this is the
+				//correct way to handle it.
+				drdaType = FdocaConstants.DRDA_TYPE_NVARMIX;
+				outlen[0] = -1;
+				break;
+			case java.sql.Types.VARCHAR:
+				drdaType = FdocaConstants.DRDA_TYPE_NVARCHAR;
+				outlen[0] = -1;
+				break;
+				// we will just convert a java object to a string
+				// since jcc doesn't support it.
+			case java.sql.Types.JAVA_OBJECT:
+				drdaType = FdocaConstants.DRDA_TYPE_NLONG;
+				outlen[0] = LONGVARCHAR_MAX_LEN;
+				break;
+			case java.sql.Types.LONGVARCHAR:
+					drdaType = DRDA_TYPE_NLONG;
+					outlen[0] = LONGVARCHAR_MAX_LEN;
+				break;
+			case java.sql.Types.BINARY:
+			case java.sql.Types.VARBINARY:
+				drdaType = FdocaConstants.DRDA_TYPE_NVARBYTE;
+				outlen[0] = -1;
+				break;
+			case java.sql.Types.LONGVARBINARY:
+					drdaType = FdocaConstants.DRDA_TYPE_NLONGVARBYTE;
+					outlen[0] = LONGVARBINARY_MAX_LEN;
+				break;
+				// blob begin
+				// merge BLOB and BLOB_LOCATOR ????
+			case java.sql.Types.BLOB:
+				drdaType = FdocaConstants.DRDA_TYPE_NLOBBYTES;
+				// indicates fdocadata is a place holder with 4 byte length
+				outlen[0] = 0x8004;
+				break;
+			case java.sql.Types.CLOB:
+				drdaType = FdocaConstants.DRDA_TYPE_NLOBCMIXED;
+				outlen[0] = 0x8004;
+				break;
+				// blob end
+			case java.sql.Types.ARRAY:
+			case java.sql.Types.DISTINCT:
+			case java.sql.Types.NULL:
+			case java.sql.Types.OTHER:
+			case java.sql.Types.REF:
+			case java.sql.Types.STRUCT:
+				throw new SQLException("Jdbc type" + jdbcType + "not Supported yet");
+			default:
+				throw new SQLException ("unrecognized sql type: " + jdbcType);
+		}
+
+		if (!nullable)
+			drdaType--;
+		return drdaType;
+
+
+	}
+
+
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,267 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.sql.Types;
+import java.sql.SQLException;
+import org.apache.derby.iapi.reference.JDBC30Translation;
+
+
+
+public class SQLTypes {
+
+  /**
+     IBM Copyright &copy notice.
+  */
+  public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2002_2004;
+
+  //----------------------------------------------------------------------------
+  protected final static int DB2_SQLTYPE_DATE = 384;        // DATE
+  protected final static int DB2_SQLTYPE_NDATE = 385;
+  protected final static int DB2_SQLTYPE_TIME = 388;        // TIME
+  protected final static int DB2_SQLTYPE_NTIME = 389;
+  protected final static int DB2_SQLTYPE_TIMESTAMP = 392;   // TIMESTAMP
+  protected final static int DB2_SQLTYPE_NTIMESTAMP = 393;
+  protected final static int DB2_SQLTYPE_DATALINK = 396;    // DATALINK
+  protected final static int DB2_SQLTYPE_NDATALINK = 397;
+
+  protected final static int DB2_SQLTYPE_BLOB = 404;        // BLOB
+  protected final static int DB2_SQLTYPE_NBLOB = 405;
+  protected final static int DB2_SQLTYPE_CLOB = 408;        // CLOB
+  protected final static int DB2_SQLTYPE_NCLOB = 409;
+  protected final static int DB2_SQLTYPE_DBCLOB = 412;      // DBCLOB
+  protected final static int DB2_SQLTYPE_NDBCLOB = 413;
+
+  protected final static int DB2_SQLTYPE_VARCHAR = 448;     // VARCHAR(i) - varying length string
+  protected final static int DB2_SQLTYPE_NVARCHAR = 449;
+  protected final static int DB2_SQLTYPE_CHAR = 452;        // CHAR(i) - fixed length
+  protected final static int DB2_SQLTYPE_NCHAR = 453;
+  protected final static int DB2_SQLTYPE_LONG = 456;        // LONG VARCHAR - varying length string
+  protected final static int DB2_SQLTYPE_NLONG = 457;
+  protected final static int DB2_SQLTYPE_CSTR = 460;        // SBCS - null terminated
+  protected final static int DB2_SQLTYPE_NCSTR = 461;
+  protected final static int DB2_SQLTYPE_VARGRAPH = 464;    // VARGRAPHIC(i) - varying length
+                                                  // graphic string (2 byte length)
+  protected final static int DB2_SQLTYPE_NVARGRAPH = 465;
+  protected final static int DB2_SQLTYPE_GRAPHIC = 468;     // GRAPHIC(i) - fixed length graphic string                                                             */
+  protected final static int DB2_SQLTYPE_NGRAPHIC = 469;
+  protected final static int DB2_SQLTYPE_LONGRAPH = 472;    // LONG VARGRAPHIC(i) - varying length graphic string                                              */
+  protected final static int DB2_SQLTYPE_NLONGRAPH = 473;
+  protected final static int DB2_SQLTYPE_LSTR = 476;        // varying length string for Pascal (1-byte length)                                                     */
+  protected final static int DB2_SQLTYPE_NLSTR = 477;
+
+  protected final static int DB2_SQLTYPE_FLOAT = 480;       // FLOAT - 4 or 8 byte floating point
+  protected final static int DB2_SQLTYPE_NFLOAT = 481;
+  protected final static int DB2_SQLTYPE_DECIMAL = 484;     // DECIMAL (m,n)
+  protected final static int DB2_SQLTYPE_NDECIMAL = 485;
+  protected final static int DB2_SQLTYPE_ZONED = 488;       // Zoned Decimal -> DECIMAL(m,n)
+  protected final static int DB2_SQLTYPE_NZONED = 489;
+
+  protected final static int DB2_SQLTYPE_BIGINT = 492;      // BIGINT - 8-byte signed integer
+  protected final static int DB2_SQLTYPE_NBIGINT = 493;
+  protected final static int DB2_SQLTYPE_INTEGER = 496;     // INTEGER
+  protected final static int DB2_SQLTYPE_NINTEGER = 497;
+  protected final static int DB2_SQLTYPE_SMALL = 500;       // SMALLINT - 2-byte signed integer                                                                    */
+  protected final static int DB2_SQLTYPE_NSMALL = 501;
+
+  protected final static int DB2_SQLTYPE_NUMERIC = 504;     // NUMERIC -> DECIMAL (m,n)
+  protected final static int DB2_SQLTYPE_NNUMERIC = 505;
+
+  protected final static int DB2_SQLTYPE_ROWID = 904;           // ROWID
+  protected final static int DB2_SQLTYPE_NROWID = 905;
+  protected final static int DB2_SQLTYPE_BLOB_LOCATOR = 960;    // BLOB locator
+  protected final static int DB2_SQLTYPE_NBLOB_LOCATOR = 961;
+  protected final static int DB2_SQLTYPE_CLOB_LOCATOR = 964;    // CLOB locator
+  protected final static int DB2_SQLTYPE_NCLOB_LOCATOR = 965;
+  protected final static int DB2_SQLTYPE_DBCLOB_LOCATOR = 968;  // DBCLOB locator
+  protected final static int DB2_SQLTYPE_NDBCLOB_LOCATOR = 969;
+
+  // define final statics for the fdoca type codes here!!!
+
+  // hide the default constructor
+  private SQLTypes() {}
+
+
+  /**
+   * Map DB2 SQL Type to JDBC Type
+   * 
+   * @param sqlType SQL Type to convert
+   * @param length storage length of type
+   * @param ccsid ccsid of type
+   *
+   * @return Corresponding JDBC Type 
+   */
+
+  static protected int mapDB2SqlTypeToJdbcType (int sqlType, long length, int ccsid)
+  {
+    switch (getNonNullableSqlType (sqlType)) { // mask the isNullable bit
+    case DB2_SQLTYPE_SMALL:
+      return java.sql.Types.SMALLINT;
+    case DB2_SQLTYPE_INTEGER:
+      return java.sql.Types.INTEGER;
+    case DB2_SQLTYPE_BIGINT:
+      return java.sql.Types.BIGINT;
+    case DB2_SQLTYPE_FLOAT:
+      if (length == 16)                  // can map to either NUMERIC or DECIMAL!!! @sxg
+        return java.sql.Types.DECIMAL;
+      else if (length == 8)              // can map to either DOUBLE or FLOAT!!! @sxg
+        return java.sql.Types.DOUBLE;
+      else if (length == 4)
+        return java.sql.Types.REAL;
+      else
+        return 0;
+        //throw new BugCheckException ("Encountered unexpected float length");
+    case DB2_SQLTYPE_DECIMAL:            // can map to either NUMERIC or DECIMAL!!! @sxg
+    case DB2_SQLTYPE_ZONED:              // can map to either NUMERIC or DECIMAL!!! @sxg
+    case DB2_SQLTYPE_NUMERIC:            // can map to either NUMERIC or DECIMAL!!! @sxg
+      return java.sql.Types.DECIMAL;
+    case DB2_SQLTYPE_CHAR:    // mixed and single byte
+      if (ccsid == 0xffff || ccsid == 0) // we think UW returns 0, and 390 returns 0xffff, doublecheck !!!
+        return java.sql.Types.BINARY;
+      else
+        return java.sql.Types.CHAR;
+    case DB2_SQLTYPE_CSTR:    // SBCS null terminated 
+    case DB2_SQLTYPE_GRAPHIC: // fixed character DBCS
+      return java.sql.Types.CHAR;
+    // use ccsid to distinguish between BINARY and CHAR, VARBINARY and VARCHAR, LONG... !!! -j/p/s
+    case DB2_SQLTYPE_VARGRAPH:  // variable character DBCS
+    case DB2_SQLTYPE_VARCHAR:   // variable character SBCS/Mixed
+      if (ccsid == 0xffff || ccsid == 0) // we think UW returns 0, and 390 returns 0xffff, doublecheck !!!
+        return java.sql.Types.VARBINARY;
+      else
+        return java.sql.Types.VARCHAR;
+    case DB2_SQLTYPE_LSTR:      // pascal string SBCS/Mixed
+      return java.sql.Types.VARCHAR;
+    case DB2_SQLTYPE_LONGRAPH:  // long varchar DBCS
+    case DB2_SQLTYPE_LONG:      // long varchar SBCS/Mixed
+      if (ccsid == 0xffff || ccsid == 0) // we think UW returns 0, and 390 returns 0xffff, doublecheck !!!
+        return java.sql.Types.LONGVARBINARY;
+      else
+        return java.sql.Types.LONGVARCHAR;
+    case DB2_SQLTYPE_DATE:
+      return java.sql.Types.DATE;
+    case DB2_SQLTYPE_TIME:
+      return java.sql.Types.TIME;
+    case DB2_SQLTYPE_TIMESTAMP:
+      return java.sql.Types.TIMESTAMP;
+    case DB2_SQLTYPE_CLOB:    // large object character SBCS/Mixed
+    case DB2_SQLTYPE_DBCLOB:  // large object character DBCS
+      return java.sql.Types.CLOB;
+    case DB2_SQLTYPE_BLOB:    // large object bytes
+		case DB2_SQLTYPE_BLOB_LOCATOR:
+		case DB2_SQLTYPE_CLOB_LOCATOR:
+		case DB2_SQLTYPE_DBCLOB_LOCATOR:
+      return java.sql.Types.BLOB;
+    default:
+      //throw new BugCheckException ("Encountered unexpected type code");
+      return 0;
+    }
+  }
+
+
+	/**
+	 * Map jdbc type to the DB2 DRDA SQL Types expected by jcc.
+	 *@param jdbctype  - jdbc Type to convert
+	 *@param nullable - whether the type is nullable
+	 **/
+
+	
+ /**  Map JDBC Type to DB2 SqlType
+  * @param jdbctype   JDBC Type from java.sql.Types
+  * @param nullable   true if this is a nullable type
+  * @param outlen     output parameter with type length
+  *
+  * @return Corresponding DB2 SQL Type (See DRDA Manual FD:OCA Meta 
+  *          Data Summary, page 245)
+  * 
+  * @exception SQLException thrown for unrecognized SQLType
+  */
+
+ static protected int mapJdbcTypeToDB2SqlType (int jdbctype, boolean nullable,
+											   int[] outlen)
+	 throws SQLException
+  {
+	  int nullAddVal =0;
+
+	  if (nullable) 
+		  nullAddVal =1; 
+	  
+	  // Call FdocaConstants just to get the length
+	  FdocaConstants.mapJdbcTypeToDrdaType(jdbctype,nullable,outlen);
+
+	  switch(jdbctype)
+	  {
+		  case JDBC30Translation.BOOLEAN:
+		  case java.sql.Types.BIT:
+		  case java.sql.Types.TINYINT:
+		  case java.sql.Types.SMALLINT:
+			  return DB2_SQLTYPE_SMALL + nullAddVal;
+		  case java.sql.Types.INTEGER:
+			  return DB2_SQLTYPE_INTEGER + nullAddVal;
+		  case java.sql.Types.BIGINT:
+			  return DB2_SQLTYPE_BIGINT + nullAddVal;
+		  case java.sql.Types.DOUBLE:
+		  case java.sql.Types.REAL:
+			  return DB2_SQLTYPE_FLOAT + nullAddVal;
+		  case java.sql.Types.DECIMAL:
+		  case java.sql.Types.NUMERIC:
+			  return DB2_SQLTYPE_DECIMAL + nullAddVal;
+		  case java.sql.Types.DATE:
+			  return DB2_SQLTYPE_DATE + nullAddVal;
+		  case java.sql.Types.TIME:
+			  return DB2_SQLTYPE_TIME + nullAddVal;
+		  case java.sql.Types.TIMESTAMP:
+			  return DB2_SQLTYPE_TIMESTAMP + nullAddVal;
+		  case java.sql.Types.CHAR:
+			  return  DB2_SQLTYPE_CHAR + nullAddVal;    // null terminated SBCS/Mixed
+		  case java.sql.Types.BINARY:
+			  return DB2_SQLTYPE_CHAR + nullAddVal;
+
+		  case java.sql.Types.VARCHAR:
+		  case java.sql.Types.VARBINARY:
+			  return  DB2_SQLTYPE_VARCHAR + nullAddVal;			  
+		  case java.sql.Types.LONGVARBINARY:
+			  return DB2_SQLTYPE_LONG + nullAddVal;
+		  case java.sql.Types.JAVA_OBJECT:
+			  return DB2_SQLTYPE_LONG + nullAddVal;
+		  case java.sql.Types.BLOB:
+			  return DB2_SQLTYPE_BLOB + nullAddVal;
+		  case java.sql.Types.CLOB:
+			  return DB2_SQLTYPE_CLOB + nullAddVal;
+		  case java.sql.Types.LONGVARCHAR:
+			  return DB2_SQLTYPE_LONG + nullAddVal;
+		  case java.sql.Types.ARRAY:
+		  case java.sql.Types.DISTINCT:
+		  case java.sql.Types.NULL:
+		  case java.sql.Types.OTHER:
+		  case java.sql.Types.REF:
+		  case java.sql.Types.STRUCT:
+			  throw new SQLException("Jdbc type" + jdbctype + "not Supported yet");
+			default:
+				throw new SQLException ("unrecognized sql type: " + jdbctype);
+			  //throw new BugCheckException ("Encountered unexpected type code");
+
+	  }
+  }
+
+	/**
+	 * Translate DB2 SQL Type to the non-nullable type.
+	 * @param sqlType DB2 SQL Type
+	 *
+	 * @return The Non-Nullable DB2 SQL Type.
+	 */
+   protected  static int getNonNullableSqlType (int sqlType)
+  {
+    return sqlType & ~1;
+  }
+
+
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,251 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import org.apache.derby.iapi.tools.i18n.LocalizedResource;
+import java.sql.SQLException;
+
+/**
+	Session stores information about the current session
+	It is used so that a DRDAConnThread can work on any session.
+*/
+class Session
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+
+	// session states
+	protected static final int INIT = 1;	// before exchange of server attributes
+	protected static final int ATTEXC = 2;	// after exchange of server attributes
+	protected static final int CLOSED = 3;	// session has ended
+
+	// session types
+	protected static final int DRDA_SESSION = 1;
+	protected static final int CMD_SESSION = 2;
+	
+	// trace name prefix and suffix
+	private static final String TRACENAME_PREFIX = "Server";
+	private static final String TRACENAME_SUFFIX = ".trace";
+
+	// session information
+	protected Socket clientSocket;		// session socket
+	protected int connNum;				// connection number
+	protected InputStream sessionInput;	// session input stream
+	protected OutputStream sessionOutput;	// session output stream
+	protected String traceFileName;		// trace file name for session
+	protected boolean traceOn;			// whether trace is currently on for the session
+	protected int state;				// the current state of the session
+	protected int sessionType;			// type of session - DRDA or NetworkServerControl command
+	protected String drdaID;			// DRDA ID of the session
+	protected DssTrace dssTrace;		// trace object associated with the session
+	protected AppRequester appRequester;	// Application requester for this session
+	protected Database database;		// current database
+	protected int qryinsid;				// unique identifier for each query
+	protected LocalizedResource langUtil;		// localization information for command session
+										// client
+
+	private	Hashtable	dbtable;		// Table of databases accessed in this session
+
+	// constructor
+	/**
+	 * Session constructor
+	 * 
+	 * @param connNum		connection number
+	 * @param clientSocket	communications socket for this session
+	 * @param traceDirectory	location for trace files
+	 * @param traceOn		whether to start tracing this connection
+	 *
+	 * @exception throws IOException
+	 */
+	protected Session (int connNum, Socket clientSocket, String traceDirectory,
+			boolean traceOn) throws IOException
+	{
+		this.connNum = connNum;
+		this.clientSocket = clientSocket;
+		this.traceOn = traceOn;
+		if (traceOn)
+			dssTrace = new DssTrace(); 
+		dbtable = new Hashtable();
+		initialize(traceDirectory);
+	}
+
+	/**
+	 * Close session - close connection sockets and set state to closed
+	 * 
+	 */
+	protected void close() throws SQLException
+	{
+		
+		try {
+			sessionInput.close();
+			sessionOutput.close();
+			clientSocket.close();
+			if (dbtable != null)
+				for (Enumeration e = dbtable.elements() ; e.hasMoreElements() ;) 
+				{
+					((Database) e.nextElement()).close();
+				}
+			
+		}catch (IOException e) {} // ignore IOException when we are shutting down
+		finally {
+			state = CLOSED;
+			dbtable = null;
+			database = null;
+		}
+	}
+
+	/**
+	 * initialize a server trace for the DRDA protocol
+	 * 
+	 * @param traceDirectory - directory for trace file
+	 */
+	protected void initTrace(String traceDirectory)
+	{
+		if (traceDirectory != null)
+			traceFileName = traceDirectory + "/" + TRACENAME_PREFIX+
+				connNum+ TRACENAME_SUFFIX;
+		else
+			traceFileName = TRACENAME_PREFIX +connNum+ TRACENAME_SUFFIX;
+		traceOn = true;
+		if (dssTrace == null)
+			dssTrace = new DssTrace();
+		dssTrace.startComBufferTrace (traceFileName);
+	}
+
+	/**
+	 * Set tracing on
+	 * 
+	 * @param traceDirectory 	directory for trace files
+	 */
+	protected void setTraceOn(String traceDirectory)
+	{
+		if (traceOn)
+			return;
+		initTrace(traceDirectory);
+	}
+	/**
+	 * Get whether tracing is on 
+	 *
+	 * @return true if tracing is on false otherwise
+	 */
+	protected boolean isTraceOn()
+	{
+		if (traceOn)
+			return true;
+		else
+			return false;
+	}
+
+	/**
+	 * Get connection number
+	 *
+	 * @return connection number
+	 */
+	protected int getConnNum()
+	{
+		return connNum;
+	}
+
+	/**
+	 * Set tracing off
+	 * 
+	 */
+	protected void setTraceOff()
+	{
+		if (! traceOn)
+			return;
+		traceOn = false;
+		if (traceFileName != null)
+			dssTrace.stopComBufferTrace();
+	}
+	/**
+	 * Add database to session table
+	 */
+	protected void addDatabase(Database d)
+	{
+		dbtable.put(d.dbName, d);
+	}
+
+	/**
+	 * Get database
+	 */
+	protected Database getDatabase(String dbName)
+	{
+		return (Database)dbtable.get(dbName);
+	}
+
+
+	/**
+	 * Get session into initial state
+	 *
+	 * @param traceDirectory	- directory for trace files
+	 */
+	private void initialize(String traceDirectory)
+		throws IOException
+	{
+		sessionInput = clientSocket.getInputStream();
+		sessionOutput = clientSocket.getOutputStream();
+		if (traceOn)
+			initTrace(traceDirectory);
+		state = INIT;
+	}
+
+	protected  String buildRuntimeInfo(String indent, LocalizedResource localLangUtil)
+	{
+		String s = "";
+		s += indent +  localLangUtil.getTextMessage("DRDA_RuntimeInfoSessionNumber.I")
+			+ connNum + "\n";
+		if (database == null)
+			return s;
+		s += database.buildRuntimeInfo(indent,localLangUtil);
+		s += "\n";
+		return s;
+	}
+
+	private String getStateString(int s)
+	{
+		switch (s)
+		{
+			case INIT: 
+				return "INIT";
+			case ATTEXC:
+				return "ATTEXC";
+			case CLOSED:
+				return "CLOSED";
+			default:
+				return "UNKNOWN_STATE";
+
+		}
+	}
+
+	private String getTypeString(int t)
+	{
+		switch (t)
+		{
+			case DRDA_SESSION:
+				return "DRDA_SESSION";
+			case CMD_SESSION:
+				return "CMD_SESSION";
+			default:
+				return "UNKNOWN_TYPE";
+		}
+					
+	}
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SignedBinary.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SignedBinary.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,168 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.iapi.services.cache
+   (C) Copyright IBM Corp. 2001, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+package org.apache.derby.impl.drda;
+
+/**
+ * Converters from signed binary bytes to Java <code>short</code>, <code>int</code>, or <code>long</code>.
+ */
+public class SignedBinary
+{
+	/**
+		IBM Copyright &copy notice.
+	*/
+
+	public static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2001_2004;
+  // Hide the default constructor, this is a static class.
+  private SignedBinary () {}
+
+  /**
+   * AS/400, Unix, System/390 byte-order for signed binary representations.
+   */
+  public final static int BIG_ENDIAN = 1;
+
+  /**
+   * Intel 80/86 reversed byte-order for signed binary representations.
+   */
+  public final static int LITTLE_ENDIAN = 2;
+
+  /**
+   * Build a Java short from a 2-byte signed binary representation.
+   * <p>
+   * Depending on machine type, byte orders are
+   * {@link #BIG_ENDIAN BIG_ENDIAN} for signed binary integers, and
+   * {@link #LITTLE_ENDIAN LITTLE_ENDIAN} for pc8087 signed binary integers.
+   *
+   * @exception IllegalArgumentException if the specified byte order is not recognized.
+   */
+  public static short getShort (byte[] buffer, int offset, int byteOrder)
+  {
+    switch (byteOrder) {
+    case BIG_ENDIAN:
+      return bigEndianBytesToShort (buffer, offset);
+    case LITTLE_ENDIAN:
+      return littleEndianBytesToShort (buffer, offset);
+    default:
+      throw new java.lang.IllegalArgumentException();
+    }
+  }
+
+  /**
+   * Build a Java int from a 4-byte signed binary representation.
+   * <p>
+   * Depending on machine type, byte orders are
+   * {@link #BIG_ENDIAN BIG_ENDIAN} for signed binary integers, and
+   * {@link #LITTLE_ENDIAN LITTLE_ENDIAN} for pc8087 signed binary integers.
+   *
+   * @exception IllegalArgumentException if the specified byte order is not recognized.
+   */
+  public static int getInt (byte[] buffer, int offset, int byteOrder)
+  {
+    switch (byteOrder) {
+    case BIG_ENDIAN:
+      return bigEndianBytesToInt (buffer, offset);
+    case LITTLE_ENDIAN:
+      return littleEndianBytesToInt (buffer, offset);
+    default:
+      throw new java.lang.IllegalArgumentException();
+    }
+  }
+
+  /**
+   * Build a Java long from an 8-byte signed binary representation.
+   * <p>
+   * Depending on machine type, byte orders are
+   * {@link #BIG_ENDIAN BIG_ENDIAN} for signed binary integers, and
+   * {@link #LITTLE_ENDIAN LITTLE_ENDIAN} for pc8087 signed binary integers.
+   * <p>
+   *
+   * @exception IllegalArgumentException if the specified byte order is not recognized.
+   */
+  public static long getLong (byte[] buffer, int offset, int byteOrder)
+  {
+    switch (byteOrder) {
+    case BIG_ENDIAN:
+      return bigEndianBytesToLong (buffer, offset);
+    case LITTLE_ENDIAN:
+      return littleEndianBytesToLong (buffer, offset);
+    default:
+      throw new java.lang.IllegalArgumentException();
+    }
+  }
+
+  /**
+   * Build a Java short from a 2-byte big endian signed binary representation.
+   */
+  public static short bigEndianBytesToShort (byte[] buffer, int offset)
+  {
+    return (short) (((buffer[offset+0] & 0xff) << 8) +
+                    ((buffer[offset+1] & 0xff) << 0));
+  }
+
+  /**
+   * Build a Java short from a 2-byte little endian signed binary representation.
+   */
+  public static short littleEndianBytesToShort (byte[] buffer, int offset)
+  {
+    return (short) (((buffer[offset+0] & 0xff) << 0) +
+                    ((buffer[offset+1] & 0xff) << 8));
+  }
+
+  /**
+   * Build a Java int from a 4-byte big endian signed binary representation.
+   */
+  public static int bigEndianBytesToInt (byte[] buffer, int offset)
+  {
+    return (int) (((buffer[offset+0] & 0xff) << 24) +
+                  ((buffer[offset+1] & 0xff) << 16) +
+                  ((buffer[offset+2] & 0xff) << 8) +
+                  ((buffer[offset+3] & 0xff) << 0));
+  }
+
+  /**
+   * Build a Java int from a 4-byte little endian signed binary representation.
+   */
+  public static int littleEndianBytesToInt (byte[] buffer, int offset)
+  {
+    return (int) (((buffer[offset+0] & 0xff) << 0) +
+                  ((buffer[offset+1] & 0xff) << 8) +
+                  ((buffer[offset+2] & 0xff) << 16) +
+                  ((buffer[offset+3] & 0xff) << 24));
+  }
+
+  /**
+   * Build a Java long from an 8-byte big endian signed binary representation.
+   */
+  public static long bigEndianBytesToLong (byte[] buffer, int offset)
+  {
+    return (long) (((buffer[offset+0] & 0xffL) << 56) +
+                   ((buffer[offset+1] & 0xffL) << 48) +
+                   ((buffer[offset+2] & 0xffL) << 40) +
+                   ((buffer[offset+3] & 0xffL) << 32) +
+                   ((buffer[offset+4] & 0xffL) << 24) +
+                   ((buffer[offset+5] & 0xffL) << 16) +
+                   ((buffer[offset+6] & 0xffL) << 8) +
+                   ((buffer[offset+7] & 0xffL) << 0));
+  }
+
+  /**
+   * Build a Java long from an 8-byte little endian signed binary representation.
+   */
+  public static long littleEndianBytesToLong (byte[] buffer, int offset)
+  {
+    return (long) (((buffer[offset+0] & 0xffL) << 0) +
+                   ((buffer[offset+1] & 0xffL) << 8) +
+                   ((buffer[offset+2] & 0xffL) << 16) +
+                   ((buffer[offset+3] & 0xffL) << 24) +
+                   ((buffer[offset+4] & 0xffL) << 32) +
+                   ((buffer[offset+5] & 0xffL) << 40) +
+                   ((buffer[offset+6] & 0xffL) << 48) +
+                   ((buffer[offset+7] & 0xffL) << 56));
+  }
+}

Added: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/TestFile.java
==============================================================================
--- (empty file)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/TestFile.java	Thu Aug 26 07:13:46 2004
@@ -0,0 +1,51 @@
+/*
+
+   Licensed Materials - Property of IBM
+   Cloudscape - Package org.apache.derby.impl.drda
+   (C) Copyright IBM Corp. 2002, 2004. All Rights Reserved.
+   US Government Users Restricted Rights - Use, duplication or
+   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+
+ */
+
+package org.apache.derby.impl.drda;
+
+
+/**
+	This tests protocol errors and protocol not used by JCC
+	The file containing the