Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 40926 invoked from network); 28 Apr 2005 19:13:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Apr 2005 19:13:18 -0000 Received: (qmail 85976 invoked by uid 500); 28 Apr 2005 19:14:17 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 85741 invoked by uid 500); 28 Apr 2005 19:14:14 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 85401 invoked by uid 500); 28 Apr 2005 19:14:06 -0000 Delivered-To: apmail-incubator-derby-cvs@incubator.apache.org Received: (qmail 85142 invoked by uid 99); 28 Apr 2005 19:14:03 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 28 Apr 2005 12:13:58 -0700 Received: (qmail 39160 invoked by uid 65534); 28 Apr 2005 19:06:04 -0000 Message-ID: <20050428190604.39158.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r165178 [9/26] - in /incubator/derby/code/trunk: ./ java/client/ java/client/org/ java/client/org/apache/ java/client/org/apache/derby/ java/client/org/apache/derby/client/ java/client/org/apache/derby/client/am/ java/client/org/apache/derby/client/net/ java/client/org/apache/derby/client/resources/ java/client/org/apache/derby/jdbc/ tools/ant/properties/ Date: Thu, 28 Apr 2005 19:05:45 -0000 To: derby-cvs@incubator.apache.org From: bandaram@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Fl= oatingPoint.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/FloatingPoint.java?rev=3D165178&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Float= ingPoint.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Float= ingPoint.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,130 @@ +/* + + Derby - Class org.apache.derby.client.am.FloatingPoint + + Copyright (c) 2001, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package org.apache.derby.client.am; + +/** + * Converters from floating point bytes to Java float, = double, + * or java.math.BigDecimal. + */ +public class FloatingPoint +{ + // Hide the default constructor, this is a static class. + private FloatingPoint () {} + + /** + * Supported Unix Big Endian IEEE 754 floating point representation. + */ + public final static int IEEE_754_FLOATING_POINT =3D 0x48; + + //--------------------------private helper methods----------------------= ------ + + /** + * Convert the byte array to an int. + */ + private static final int convertFromByteToInt(byte[] buffer, int offset) + { + return ( buffer[offset] << 24 ) | + ( (buffer[offset+1] & 0xFF) << 16 ) | + ( (buffer[offset+2] & 0xFF) << 8 ) | + ( buffer[offset+3] & 0xFF ); + } + + /** + * Convert the byte array to a long. + */ + private static final long convertFromByteToLong(byte[] buffer, int offse= t) + { + return ( (buffer[offset] & 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 ); + } + + + //--------------entry points for runtime representation-----------------= ------ + + /** + * Build a Java float from a 4-byte floating point representation. + *

+ * This includes DERBY types: + *

    + *
  • REAL + *
  • FLOAT(1<=3Dn<=3D24) + *
+ * + * @exception IllegalArgumentException if the specified representation i= s not recognized. + */ + public static final float getFloat (byte[] buffer, int offset) + { + return Float.intBitsToFloat (convertFromByteToInt (buffer, offset)); + } + + /** + * Build a Java double from an 8-byte floating point representation. + *

+ *

+ * This includes DERBY types: + *

    + *
  • FLOAT + *
  • DOUBLE [PRECISION] + *
+ * + * @exception IllegalArgumentException if the specified representation i= s not recognized. + */ + public static final double getDouble (byte[] buffer, int offset) + { + return Double.longBitsToDouble (convertFromByteToLong (buffer, offset)= ); + } + + //--------------entry points for runtime representation-----------------= ------ + + /** + * Write a Java float to a 4-byte floating point representa= tion. + */ + public static final void floatToIeee754Bytes (byte[] buffer, int offset,= float f) + { + int intBits =3D Float.floatToIntBits (f); + buffer[offset] =3D (byte) ((intBits >>> 24) & 0xFF); + buffer[offset+1] =3D (byte) ((intBits >>> 16) & 0xFF); + buffer[offset+2] =3D (byte) ((intBits >>> 8) & 0xFF); + buffer[offset+3] =3D (byte) ( intBits & 0xFF); + } + + /** + * Write a Java double to an 8-byte double precision + * floating point representation. + */ + public static final void doubleToIeee754Bytes (byte[] buffer, int offset= , double d) + { + long longBits =3D Double.doubleToLongBits (d); + buffer[offset] =3D (byte) ((longBits >>> 56) & 0xFF); + buffer[offset+1] =3D (byte) ((longBits >>> 48) & 0xFF); + buffer[offset+2] =3D (byte) ((longBits >>> 40) & 0xFF); + buffer[offset+3] =3D (byte) ((longBits >>> 32) & 0xFF); + buffer[offset+4] =3D (byte) ((longBits >>> 24) & 0xFF); + buffer[offset+5] =3D (byte) ((longBits >>> 16) & 0xFF); + buffer[offset+6] =3D (byte) ((longBits >>> 8) & 0xFF); + buffer[offset+7] =3D (byte) ( longBits & 0xFF); + } +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/FloatingPoint.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Ge= tFileInputStreamAction.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/GetFileInputStreamAction.java?rev=3D165178&view= =3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetFi= leInputStreamAction.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetFi= leInputStreamAction.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,55 @@ +/* + + Derby - Class org.apache.derby.client.am.GetFileInputStreamAction + + Copyright (c) 2002, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + +/** + * Java 2 PrivilegedExceptionAction encapsulation of creating a new FileIn= putStream + * throws FileNotFoundException + */ +public class GetFileInputStreamAction implements java.security.PrivilegedE= xceptionAction +{ + // the pathname used by the input file in the file system + private String filePathName_ =3D null; + =20 + private String canonicalPath_ =3D null;=20 + + //-------------------- Constructors -------------------- + + public GetFileInputStreamAction (String filePathName) + { + filePathName_ =3D filePathName; + } + + //-------------------- methods -------------------- + + public Object run() throws java.io.IOException + { + java.io.File file =3D new java.io.File (filePathName_); + java.io.FileInputStream fileInputStream =3D new java.io.FileInputStrea= m (file); + canonicalPath_ =3D file.getCanonicalPath(); + return fileInputStream; + } + =20 + public String getCanonicalPath() + { + return canonicalPath_; + } +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/GetFileInputStreamAction.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Ge= tResourceBundleAction.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/GetResourceBundleAction.java?rev=3D165178&view=3D= auto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetRe= sourceBundleAction.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetRe= sourceBundleAction.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,43 @@ +/* + + Derby - Class org.apache.derby.client.am.GetResourceBundleAction + + Copyright (c) 2002, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + +// Java 2 PrivilegedExceptionAction encapsulation of java.util.ResourceBun= dle.getBundle() action +public class GetResourceBundleAction implements java.security.PrivilegedEx= ceptionAction +{ + private String resourceBundleName_ =3D null; // class name for resources + + // the base name of the resource bundle, a fully qualified class name + public GetResourceBundleAction (String resourceBundleName) + { + resourceBundleName_ =3D resourceBundleName; + } + + public Object run () throws NullPointerException, java.util.MissingResou= rceException + { + return java.util.ResourceBundle.getBundle (resourceBundleName_); + } + + public void setResourceBundleName (String resourceBundleName) + { + resourceBundleName_ =3D resourceBundleName; + } +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/GetResourceBundleAction.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Ge= tResourceInputStreamAction.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/GetResourceInputStreamAction.java?rev=3D165178&vi= ew=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetRe= sourceInputStreamAction.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetRe= sourceInputStreamAction.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,100 @@ +/* + + Derby - Class org.apache.derby.client.am.GetResourceInputStreamAction + + Copyright (c) 2003, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + +/** + * Java 2 PrivilegedAction encapsulation of attempting to acquire driver-g= eneral + * properties as a System resource. + */ +public class GetResourceInputStreamAction implements java.security.Privile= gedAction +{ + // Name for loading the resource. + private String resourceName_ =3D null; + // Path of the resource being loaded. + private String resourcePath_ =3D null; + // Class loader being used to load the resource. + private String resourceLoaderId_ =3D null; + + //-------------------- Constructors -------------------- + =20 + public GetResourceInputStreamAction (String resourceName) + { + resourceName_ =3D resourceName; + } + + //-------------------- methods -------------------- + + public Object run() + { + try { + ClassLoader contextLoader =3D Thread.currentThread().getContextClass= Loader(); + if (contextLoader !=3D null) { + java.net.URL resourceUrl =3D contextLoader.getResource (resourceNa= me_); + if (resourceUrl !=3D null) { + resourcePath_ =3D resourceUrl.getPath(); + resourceLoaderId_ =3D "Context ClassLoader: " + contextLoader; + return contextLoader.getResourceAsStream (resourceName_); + } + } + ClassLoader thisLoader =3D getClass().getClassLoader(); + if (thisLoader !=3D contextLoader) { + java.net.URL resourceUrl =3D thisLoader.getResource (resourceName_= ); + if (resourceUrl !=3D null) { + resourcePath_ =3D resourceUrl.getPath(); + resourceLoaderId_ =3D "Driver ClassLoader: " + thisLoader; + return thisLoader.getResourceAsStream (resourceName_); + } + } + ClassLoader systemLoader =3D ClassLoader.getSystemClassLoader(); + if (systemLoader !=3D contextLoader && + systemLoader !=3D thisLoader) { + java.net.URL resourceUrl =3D systemLoader.getResource (resourceNam= e_); + if (resourceUrl !=3D null) { + resourcePath_ =3D resourceUrl.getPath(); + resourceLoaderId_ =3D "System ClassLoader: " + systemLoader; + return systemLoader.getResourceAsStream (resourceName_); + } + } + return null; + } + catch (java.security.AccessControlException ace) { + // This happens in an Applet environment, + // so return with null. + return null; + } + } + =20 + public void setResourceName (String resourceName) + { + resourceName_ =3D resourceName; + } + =20 + public String getResourcePath() + { + return resourcePath_; + } + =20 + public String getResourceLoaderId() + { + return resourceLoaderId_; + } + +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/GetResourceInputStreamAction.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Ge= tSystemPropertiesAction.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/GetSystemPropertiesAction.java?rev=3D165178&view= =3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetSy= stemPropertiesAction.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/GetSy= stemPropertiesAction.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,57 @@ +/* + + Derby - Class org.apache.derby.client.am.GetSystemPropertiesAction + + Copyright (c) 2002, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + + +/** + * Java 2 PrivilegedAction encapsulation of System getProperties processing + */ +public class GetSystemPropertiesAction implements java.security.Privileged= Action +{ + // System properties values, i.e. output from System.getProperties() + private java.util.Properties systemProperties_ =3D null; + + //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D Constructor =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + //-------------------- GetSystemPropertiesAction -------------------- + /** + * Constructor. + */ + public GetSystemPropertiesAction () + {} + + /** + * Performs the privileged action of System.getProperties() + */ + public Object run() + { + this.systemProperties_ =3D System.getProperties(); + return this.systemProperties_; + } + + /** + * Accessor for system properties (used after run() method invocation) + */ + public java.util.Properties getSystemProperties() + { + return this.systemProperties_; + } +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/GetSystemPropertiesAction.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Lo= b=2Ejava URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/Lob.java?rev=3D165178&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Lob.j= ava (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Lob.j= ava Thu Apr 28 12:05:42 2005 @@ -0,0 +1,102 @@ +/* + + Derby - Class org.apache.derby.client.am.Lob + + Copyright (c) 2001, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + +public abstract class Lob implements UnitOfWorkListener +{ + // The following flags specify the data type(s) a LOB instance currently= contains + public static final int STRING =3D 2; + public static final int ASCII_STREAM =3D 4; + public static final int UNICODE_STREAM =3D 8; + public static final int CHARACTER_STREAM =3D 16; + public static final int BINARY_STREAM =3D 32; + public static final int BINARY_STRING =3D 64; + + //---------------------navigational members-----------------------------= ------ + protected Agent agent_; + + //-----------------------------state------------------------------------= ------ + protected int dataType_ =3D 0; // data type(s) the LOB instance cur= rently contains + + protected long sqlLength_; // length of the LOB value, as defined b= y the server + protected boolean lengthObtained_; + + //---------------------constructors/finalizer---------------------------= ------ + protected Lob (Agent agent) + { + agent_ =3D agent; + lengthObtained_ =3D false; + } + + protected void finalize () throws java.lang.Throwable + { + super.finalize(); + } + + // ---------------------------jdbc 2------------------------------------= ------ + + // should only be called by a synchronized method. + + + // should only be called by a synchronized method. + public long sqlLength () throws SqlException + { + checkForClosedConnection (); + + return sqlLength_; + } + + + //-----------------------event callback methods-------------------------= ------ + + public void listenToUnitOfWork() + { + agent_.connection_.CommitAndRollbackListeners_.add (this); + } + + public void completeLocalCommit (java.util.Iterator listenerIterator) + { + listenerIterator.remove(); + } + + public void completeLocalRollback (java.util.Iterator listenerIterator) + { + listenerIterator.remove(); + } + + //----------------------------helper methods----------------------------= ------ + + public Agent getAgent () { return agent_; } + + void checkForClosedConnection () throws SqlException + { + if (agent_.connection_.isClosedX()) { + agent_.checkForDeferredExceptions(); + throw new SqlException (agent_.logWriter_, "Lob method called after = connection was closed"); + } + else { + agent_.checkForDeferredExceptions(); + } + } + + void completeLocalRollback() { ; } + void completeLocalCommit() { ; } +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/Lob.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Lo= gWriter.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/LogWriter.java?rev=3D165178&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/LogWr= iter.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/LogWr= iter.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,1095 @@ +/* + + Derby - Class org.apache.derby.client.am.LogWriter + + Copyright (c) 2001, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + +import org.apache.derby.jdbc.ClientDataSource; + +public class LogWriter +{ + protected java.io.PrintWriter printWriter_; + protected int traceLevel_; + private boolean driverConfigurationHasBeenWrittenToJdbc1Stream_ =3D fals= e; + private boolean driverConfigurationHasBeenWrittenToJdbc2Stream_ =3D fals= e; + + // It is assumed that this constructor is never called when logWriter is= null. + public LogWriter (java.io.PrintWriter printWriter, int traceLevel) + { + printWriter_ =3D printWriter; + traceLevel_ =3D traceLevel; + } + + final protected boolean loggingEnabled (int traceLevel) + { + // It is an invariant that the printWriter is never null, so remove the + return printWriter_ !=3D null && (traceLevel & traceLevel_) !=3D 0; + } + + final protected boolean traceSuspended () { return org.apache.derby.clie= nt.am.Configuration.traceSuspended__; } + + // When garbage collector doesn't kick in in time + // to close file descriptors, "Too many open files" + // exception may occur (currently found on Linux). + // To minimize the chance of this problem happening, + // the print writer needs to be closed (after this + // DNC log writer is closed) when each connection has + // its own trace file (i.e. traceDirectory is specified). + public boolean printWriterNeedsToBeClosed_; + + void close() + { + if (printWriterNeedsToBeClosed_) { + printWriter_.close(); + printWriterNeedsToBeClosed_ =3D false; + } + // printWriter_ =3D null; // help GC. + } + + // ---------------------------------------------------------------------= ------ + + public void dncprintln (String s) + { + synchronized (printWriter_) { + printWriter_.println ("[derby] " + s); + printWriter_.flush(); + } + } + + private void dncprint (String s) + { + synchronized (printWriter_) { + printWriter_.print ("[derby] " + s); + printWriter_.flush(); + } + } + + private void dncprintln (String header, String s) + { + synchronized (printWriter_) { + printWriter_.println ("[derby]" + header + " " + s); + printWriter_.flush(); + } + } + + private void dncprint (String header, String s) + { + synchronized (printWriter_) { + printWriter_.print ("[derby]" + header + " " + s); + printWriter_.flush(); + } + } + + // ------------------------ tracepoint api -----------------------------= ------ + + public void tracepoint (String component, int tracepoint, String message) + { + if (traceSuspended()) return; + dncprintln (component, + "[time:" + System.currentTimeMillis() + "]" + + "[thread:" + Thread.currentThread().getName() + "]" + + "[tracepoint:" + tracepoint + "]" + + message); + } + + public void tracepoint (String component, int tracepoint, + String classContext, String methodContext) + { + if (traceSuspended()) return; + String staticContextTracepointRecord =3D + component + + "[time:" + System.currentTimeMillis() + "]" + + "[thread:" + Thread.currentThread().getName() + "]" + + "[tracepoint:" + tracepoint + "]" + + "[" + classContext + "." + methodContext + "]"; + dncprintln (staticContextTracepointRecord); + } + + public void tracepoint (String component, int tracepoint, + Object instance, String classContext, String met= hodContext) + { + if (traceSuspended()) return; + String instanceContextTracepointRecord =3D + component + + "[time:" + System.currentTimeMillis() + "]" + + "[thread:" + Thread.currentThread().getName() + "]" + + "[tracepoint:" + tracepoint + "]" + + "[" + classContext + "@" + Integer.toHexString (instance.hashCode())= + "." + methodContext + "]"; + dncprintln (instanceContextTracepointRecord); + } + + public void tracepoint (String component, int tracepoint, + String classContext, String methodContext, + java.util.Map memory) + { + if (traceSuspended()) return; + String staticContextTracepointRecord =3D + component + + "[time:" + System.currentTimeMillis() + "]" + + "[thread:" + Thread.currentThread().getName() + "]" + + "[tracepoint:" + tracepoint + "]" + + "[" + classContext + "." + methodContext + "]"; + dncprintln (staticContextTracepointRecord + getMemoryMapDisplay (memor= y)); + } + + public void tracepoint (String component, int tracepoint, + Object instance, String classContext, String met= hodContext, + java.util.Map memory) + { + if (traceSuspended()) return; + String instanceContextTracepointRecord =3D + component + + "[time:" + System.currentTimeMillis() + "]" + + "[thread:" + Thread.currentThread().getName() + "]" + + "[tracepoint:" + tracepoint + "]" + + "[" + classContext + "@" + Integer.toHexString (instance.hashCode())= + "." + methodContext + "]"; + dncprintln (instanceContextTracepointRecord + getMemoryMapDisplay (mem= ory)); + } + + private String getMemoryMapDisplay (java.util.Map memory) + { + return memory.toString(); // need to loop thru all keys in the map and= print values + } + + // ------------- API entry and exit trace methods ----------------------= ------ + // Entry and exit are be traced separately because input arguments need + // to be traced before any potential exception can occur. + // Exit tracing is only performed on methods that return values. + // Entry tracing is only performed on methods that update state, + // so entry tracing is not performed on simple getter methods. + // We could decide in the future to restrict entry tracing only to metho= ds with input arguments. + + private void traceExternalMethod (Object instance, String className, Str= ing methodName) + { + if (traceSuspended()) return; + dncprint (buildExternalMethodHeader (instance, className), methodName); + } + + private void traceExternalDeprecatedMethod (Object instance, String clas= sName, String methodName) + { + if (traceSuspended()) return; + dncprint (buildExternalMethodHeader (instance, className), "Deprecated= " + methodName); + } + + private String buildExternalMethodHeader (Object instance, String classN= ame) + { + return + "[Time:" + System.currentTimeMillis() + "]" + + "[Thread:" + Thread.currentThread().getName() + "]" + + "[" + className + "@" + Integer.toHexString (instance.hashCode()) + = "]"; + } + + private String getClassNameOfInstanceIfTraced (Object instance) + { + if (instance =3D=3D null) // this prevents NPE from instance.getClass(= ) used below + return null; + else if (instance instanceof Connection && loggingEnabled (ClientDataS= ource.TRACE_CONNECTION_CALLS)) + return "Connection"; + else if (instance instanceof ResultSet && loggingEnabled (ClientDataSo= urce.TRACE_RESULT_SET_CALLS)) + return "ResultSet"; + else if (instance instanceof CallableStatement && loggingEnabled (Clie= ntDataSource.TRACE_STATEMENT_CALLS)) + return "CallableStatement"; + else if (instance instanceof PreparedStatement && loggingEnabled (Clie= ntDataSource.TRACE_STATEMENT_CALLS)) + return "PreparedStatement"; + else if (instance instanceof Statement && loggingEnabled (ClientDataSo= urce.TRACE_STATEMENT_CALLS)) + return "Statement"; + // Not yet externalizing Blob tracing, except for trace_all + else if (instance instanceof Blob && loggingEnabled (ClientDataSource.= TRACE_ALL)) // add a trace level for lobs !! + return "Blob"; + // Not yet externalizing Clob tracing, except for trace_all + else if (instance instanceof Clob && loggingEnabled (ClientDataSource.= TRACE_ALL)) // add a trace level for bobs !! + return "Clob"; + // Not yet externalizing dbmd catalog call tracing, except for trace_a= ll + else if (instance instanceof DatabaseMetaData && loggingEnabled (Clien= tDataSource.TRACE_ALL)) // add a trace level for dbmd ?? + return "DatabaseMetaData"; + // we don't use instanceof javax.transaction.XAResource to avoid depen= dency on j2ee.jar + else if (loggingEnabled (ClientDataSource.TRACE_XA_CALLS) && + instance.getClass().getName().startsWith ("org.apache.derby.c= lient.net.NetXAResource")) + return "NetXAResource"; + else if (loggingEnabled (ClientDataSource.TRACE_ALL) && + instance.getClass().getName().equals("org.apache.derby.client.Client= PooledConnection")) + return "ClientPooledConnection"; + else if (loggingEnabled (ClientDataSource.TRACE_ALL) && + instance.getClass().getName().equals("org.apache.derby.jdbc.ClientCo= nnectionPoolDataSource")) + return "ClientConnectionPoolDataSource"; + else if (loggingEnabled (ClientDataSource.TRACE_ALL) && + instance.getClass().getName().equals("org.apache.derby.client.Client= XAConnection")) + return "ClientXAConnection"; + else if (loggingEnabled (ClientDataSource.TRACE_ALL) && + instance.getClass().getName().equals("org.apache.derby.jdbc.ClientDa= taSource")) + return "ClientDataSource"; + else if (loggingEnabled (ClientDataSource.TRACE_ALL) && + instance.getClass().getName().equals("org.apache.derby.jdbc.ClientXA= DataSource")) + return "ClientXADataSource"; + else + return instance.getClass().getName(); + } + + // --------------------------- method exit tracing ---------------------= ----- + + public void traceExit (Object instance, String methodName, Object return= Value) + { + if (traceSuspended()) return; + String className =3D getClassNameOfInstanceIfTraced (instance); + if (className =3D=3D null) return; + synchronized (printWriter_) { + traceExternalMethod (instance, className, methodName); + printWriter_.println (" () returned " + returnValue); + printWriter_.flush(); + } + } + + public void traceDeprecatedExit (Object instance, String methodName, Obj= ect returnValue) + { + if (traceSuspended()) return; + String className =3D getClassNameOfInstanceIfTraced (instance); + if (className =3D=3D null) return; + synchronized (printWriter_) { + traceExternalDeprecatedMethod (instance, className, methodName); + printWriter_.println (" () returned " + returnValue); + printWriter_.flush(); + } + } + + public void traceExit (Object instance, String methodName, ResultSet res= ultSet) + { + if (traceSuspended()) return; + String returnValue =3D (resultSet =3D=3D null) ? "ResultSet@null" : "R= esultSet@" + Integer.toHexString (resultSet.hashCode()); + traceExit (instance, methodName, returnValue); + } + + public void traceExit (Object instance, String methodName, CallableState= ment returnValue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, "CallableStatement@" + Integer.toHexS= tring (returnValue.hashCode())); + } + + public void traceExit (Object instance, String methodName, PreparedState= ment returnValue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, "PreparedStatement@" + Integer.toHexS= tring (returnValue.hashCode())); + } + + public void traceExit (Object instance, String methodName, Statement ret= urnValue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, "Statement@" + Integer.toHexString (r= eturnValue.hashCode())); + } + + public void traceExit (Object instance, String methodName, Blob blob) + { + if (traceSuspended()) return; + String returnValue =3D (blob =3D=3D null) ? "Blob@null" : "Blob@" + In= teger.toHexString (blob.hashCode()); + traceExit (instance, methodName, returnValue); + } + + public void traceExit (Object instance, String methodName, Clob clob) + { + if (traceSuspended()) return; + String returnValue =3D (clob =3D=3D null) ? "Clob@null" : "Clob@" + In= teger.toHexString (clob.hashCode()); + traceExit (instance, methodName, returnValue); + } + + public void traceExit (Object instance, String methodName, DatabaseMetaD= ata returnValue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, "DatabaseMetaData@" + Integer.toHexSt= ring (returnValue.hashCode())); + } + + public void traceExit (Object instance, String methodName, Connection re= turnValue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, "Connection@" + Integer.toHexString (= returnValue.hashCode())); + } + + public void traceExit (Object instance, String methodName, ColumnMetaDat= a returnValue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, "MetaData@" + (returnValue !=3D null = ? Integer.toHexString (returnValue.hashCode()) : null)); + } + + public void traceExit (Object instance, String methodName, byte[] return= Value) + { + if (traceSuspended()) return; + traceExit (instance, methodName, Utils.getStringFromBytes (returnValue= )); + } + + public void traceExit (Object instance, String methodName, int[] returnV= alue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, Utils.getStringFromInts (returnValue)= ); + } + + public void traceDeprecatedExit (Object instance, String methodName, byt= e[] returnValue) + { + if (traceSuspended()) return; + traceDeprecatedExit (instance, methodName, Utils.getStringFromBytes (r= eturnValue)); + } + + public void traceExit (Object instance, String methodName, byte returnVa= lue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, "0x" + Integer.toHexString (returnVal= ue&0xff)); + } + + public void traceExit (Object instance, String methodName, int returnVal= ue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, String.valueOf (returnValue)); + } + + public void traceExit (Object instance, String methodName, boolean retur= nValue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, String.valueOf (returnValue)); + } + + public void traceExit (Object instance, String methodName, long returnVa= lue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, String.valueOf (returnValue)); + } + + public void traceExit (Object instance, String methodName, float returnV= alue) + { + if (traceSuspended()) return; + traceExit (instance, methodName, String.valueOf (returnValue)); + } + + public void traceExit (Object instance, String methodName, double return= Value) + { + if (traceSuspended()) return; + traceExit (instance, methodName, String.valueOf (returnValue)); + } + + // --------------------------- method entry tracing --------------------= ------ + + private void traceEntryAllArgs (Object instance, String methodName, Stri= ng argList) + { + if (traceSuspended()) return; + String className =3D getClassNameOfInstanceIfTraced (instance); + if (className =3D=3D null) return; + synchronized (printWriter_) { + traceExternalMethod (instance, className, methodName); + printWriter_.println (" " + argList + " called"); + printWriter_.flush(); + } + } + + private void traceDeprecatedEntryAllArgs (Object instance, String method= Name, String argList) + { + if (traceSuspended()) return; + String className =3D getClassNameOfInstanceIfTraced (instance); + if (className =3D=3D null) return; + synchronized (printWriter_) { + traceExternalDeprecatedMethod (instance, className, methodName); + printWriter_.println (" " + argList + " called"); + printWriter_.flush(); + } + } + + // ---------------------- trace entry of methods w/ no args ------------= ------ + + public void traceEntry (Object instance, String methodName) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, "()"); + } + + // ---------------------- trace entry of methods w/ 1 arg --------------= ------ + + public void traceEntry (Object instance, String methodName, Object argum= ent) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + argument + ")"); + } + + public void traceEntry (Object instance, String methodName, boolean argu= ment) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + argument + ")"); + } + + public void traceEntry (Object instance, String methodName, int argument) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + argument + ")"); + } + + public void traceDeprecatedEntry (Object instance, String methodName, in= t argument) + { + if (traceSuspended()) return; + traceDeprecatedEntryAllArgs (instance, methodName, + "(" + argument + ")"); + } + + public void traceDeprecatedEntry (Object instance, String methodName, Ob= ject argument) + { + if (traceSuspended()) return; + traceDeprecatedEntryAllArgs (instance, methodName, + "(" + argument + ")"); + } + + // ---------------------- trace entry of methods w/ 2 args -------------= ------ + + public void traceEntry (Object instance, String methodName, Object arg1,= Object arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, Ob= ject arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, by= te[] arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + Utils.getStringFromBytes (arg2) + ")"); + } + + public void traceDeprecatedEntry (Object instance, String methodName, in= t arg1, int arg2) + { + if (traceSuspended()) return; + traceDeprecatedEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceDeprecatedEntry (Object instance, String methodName, Ob= ject arg1, int arg2) + { + if (traceSuspended()) return; + traceDeprecatedEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, bo= olean arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, by= te arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", 0x" + Integer.toHexString (arg2&0xff) + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, sh= ort arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, in= t arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, lo= ng arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, fl= oat arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, int arg1, do= uble arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, Object arg1,= boolean arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, Object arg1,= byte arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", 0x" + Integer.toHexString (arg2&0xff) + ")"); + } + + public void traceEntry (Object instance, String methodName, Object arg1,= short arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, Object arg1,= int arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, Object arg1,= long arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, Object arg1,= float arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + public void traceEntry (Object instance, String methodName, Object arg1,= double arg2) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ")"); + } + + // ---------------------- trace entry of methods w/ 3 args -------------= ------ + + public void traceEntry (Object instance, String methodName, + Object arg1, Object arg2, Object arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + int arg1, Object arg2, Object arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, Object arg2, int arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + int arg1, Object arg2, int arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceDeprecatedEntry (Object instance, String methodName, + int arg1, Object arg2, int arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + int arg1, int arg2, Object arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + int arg1, int arg2, int arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, int arg2, int arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, int arg2, Object arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, boolean arg2, boolean arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, boolean arg2, int arg3) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ")"); + } + + // ---------------------- trace entry of methods w/ 4 args -------------= ------ + + public void traceEntry (Object instance, String methodName, + Object arg1, Object arg2, Object arg3, Object arg4) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ")"); + } + + public void traceEntry (Object instance, String methodName, + int arg1, Object arg2, Object arg3, Object arg4) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ")"); + } + + public void traceEntry (Object instance, String methodName, + int arg1, Object arg2, int arg3, int arg4) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, int arg2, int arg3, int arg4) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, Object arg2, int arg3, int arg4) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ")"); + } + + // ---------------------- trace entry of methods w/ 5 args -------------= ------ + + public void traceEntry (Object instance, String methodName, + Object arg1, Object arg2, Object arg3, int arg4, bool= ean arg5) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5 += ")"); + } + + public void traceEntry (Object instance, String methodName, + Object arg1, Object arg2, Object arg3, boolean arg4, = boolean arg5) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5 += ")"); + } + + // ---------------------- trace entry of methods w/ 6 args -------------= ------ + + public void traceEntry (Object instance, String methodName, + Object arg1, Object arg2, Object arg3, Object arg4, O= bject arg5, Object arg6) + { + if (traceSuspended()) return; + traceEntryAllArgs (instance, methodName, + "(" + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5 += ", " + arg6 + ")"); + } + + // ---------------------------tracing exceptions and warnings-----------= ------ + + public void traceDiagnosable (java.sql.SQLException e) + { + if (traceSuspended()) return; + if (!loggingEnabled (ClientDataSource.TRACE_DIAGNOSTICS)) return; + synchronized (printWriter_) { + dncprintln ("BEGIN TRACE_DIAGNOSTICS"); + ExceptionFormatter.printTrace (e, printWriter_, "[derby]", true); //= true means return tokens only + dncprintln ("END TRACE_DIAGNOSTICS"); + } + } + + public void traceDiagnosable (javax.transaction.xa.XAException e) + { + if (traceSuspended()) return; + if (!loggingEnabled (ClientDataSource.TRACE_DIAGNOSTICS)) return; + synchronized (printWriter_) { + dncprintln ("BEGIN TRACE_DIAGNOSTICS"); + ExceptionFormatter.printTrace (e, printWriter_, "[derby]"); + dncprintln ("END TRACE_DIAGNOSTICS"); + } + } + // ------------------------ meta data tracing --------------------------= ------ + + public void traceParameterMetaData (Statement statement, ColumnMetaData = columnMetaData) + { + if (traceSuspended()) return; + if (!loggingEnabled (ClientDataSource.TRACE_PARAMETER_META_DATA) || co= lumnMetaData =3D=3D null) return; + synchronized (printWriter_) { + String header =3D "[ParameterMetaData@" + Integer.toHexString (colum= nMetaData.hashCode()) + "]"; + try { + dncprintln (header, "BEGIN TRACE_PARAMETER_META_DATA"); + dncprintln (header, "Parameter meta data for statement Statement@"= + Integer.toHexString (statement.hashCode())); + dncprintln (header, "Number of parameter columns: " + columnMetaDa= ta.getColumnCount()); + traceColumnMetaData (header, columnMetaData); + dncprintln (header, "END TRACE_PARAMETER_META_DATA"); + } + catch (SqlException e) { + dncprintln (header, "Encountered an SQL exception while trying to = trace parameter meta data"); + dncprintln (header, "END TRACE_PARAMETER_META_DATA"); + } + } + } + + public void traceResultSetMetaData (Statement statement, ColumnMetaData = columnMetaData) + { + if (traceSuspended()) return; + if (!loggingEnabled (ClientDataSource.TRACE_RESULT_SET_META_DATA) || c= olumnMetaData =3D=3D null) return; + synchronized (printWriter_) { + String header =3D "[ResultSetMetaData@" + Integer.toHexString (columnM= etaData.hashCode()) + "]"; + try { + dncprintln (header, "BEGIN TRACE_RESULT_SET_META_DATA"); + dncprintln (header, "Result set meta data for statement Statement@= " + Integer.toHexString (statement.hashCode())); + dncprintln (header, "Number of result set columns: " + columnMetaD= ata.getColumnCount()); + traceColumnMetaData (header, columnMetaData); + dncprintln (header, "END TRACE_RESULT_SET_META_DATA"); + } + catch (SqlException e) { + dncprintln (header, "Encountered an SQL exception while trying to = trace result set meta data"); + dncprintln (header, "END TRACE_RESULT_SET_META_DATA"); + } + } + } + + //-----------------------------transient state--------------------------= ------ + + private void traceColumnMetaData (String header, ColumnMetaData columnMe= taData) + { + if (traceSuspended()) return; + try { + synchronized (printWriter_) { + + for (int column =3D 1; column <=3D columnMetaData.getColumnCount()= ; column++) { + dncprint (header, "Column " + column + ": { "); + printWriter_.print ("label=3D" + columnMetaData.getColumnLabel (= column) + ", "); + printWriter_.print ("name=3D" + columnMetaData.getColumnName (co= lumn) + ", "); + printWriter_.print ("type name=3D" + columnMetaData.getColumnTyp= eName (column) + ", "); + printWriter_.print ("type=3D" + columnMetaData.getColumnType (co= lumn) + ", "); + printWriter_.print ("nullable=3D" + columnMetaData.isNullable (c= olumn) + ", "); + printWriter_.print ("precision=3D" + columnMetaData.getPrecision= (column) + ", "); + printWriter_.print ("scale=3D" + columnMetaData.getScale (column= ) + ", "); + printWriter_.print ("schema name=3D" + columnMetaData.getSchemaN= ame (column) + ", "); + printWriter_.print ("table name=3D" + columnMetaData.getTableNam= e (column) + ", "); + printWriter_.print ("writable=3D" + columnMetaData.isWritable (c= olumn) + ", "); + printWriter_.print ("sqlPrecision=3D" + (columnMetaData.sqlPreci= sion_ =3D=3D null ? "" : ""+columnMetaData.sqlPrecision_[column-1]) += ", "); + printWriter_.print ("sqlScale=3D" + (columnMetaData.sqlScale_ = =3D=3D null ? "" : ""+columnMetaData.sqlScale_[column-1]) + ", "); + printWriter_.print ("sqlLength=3D" + (columnMetaData.sqlLength_ = =3D=3D null ? "" : ""+columnMetaData.sqlLength_[column-1]) + ", "); + printWriter_.print ("sqlType=3D" + (columnMetaData.sqlType_ =3D= =3D null ? "" : ""+columnMetaData.sqlType_[column-1]) + ", "); + printWriter_.print ("sqlCcsid=3D" + (columnMetaData.sqlCcsid_ = =3D=3D null ? "" : ""+columnMetaData.sqlCcsid_[column-1]) + ", "); + printWriter_.print ("sqlName=3D" + (columnMetaData.sqlName_ =3D= =3D null ? "" : columnMetaData.sqlName_[column-1]) + ", "); + printWriter_.print ("sqlLabel=3D" + (columnMetaData.sqlLabel_ = =3D=3D null ? "" : columnMetaData.sqlLabel_[column-1]) + ", "); + printWriter_.print ("sqlUnnamed=3D" + (columnMetaData.sqlUnnamed= _ =3D=3D null ? "" : ""+columnMetaData.sqlUnnamed_[column-1]) + ", "); + printWriter_.print ("sqlComment=3D" + (columnMetaData.sqlComment= _ =3D=3D null ? "" : columnMetaData.sqlComment_[column-1]) + ", "); + printWriter_.print ("sqlxKeymem=3D" + (columnMetaData.sqlxKeymem= _ =3D=3D null ? "" : ""+columnMetaData.sqlxKeymem_[column-1]) + ", "); + printWriter_.print ("sqlxGenerated=3D" + (columnMetaData.sqlxGen= erated_ =3D=3D null ? "" : ""+columnMetaData.sqlxGenerated_[column-1]= ) + ", "); + printWriter_.print ("sqlxParmmode=3D" + (columnMetaData.sqlxParm= mode_ =3D=3D null ? "" : ""+columnMetaData.sqlxParmmode_[column-1]) += ", "); + printWriter_.print ("sqlxCorname=3D" + (columnMetaData.sqlxCorna= me_ =3D=3D null ? "" : columnMetaData.sqlxCorname_[column-1]) + ", "); + printWriter_.print ("sqlxName=3D" + (columnMetaData.sqlxName_ = =3D=3D null ? "" : columnMetaData.sqlxName_[column-1]) + ", "); + printWriter_.print ("sqlxBasename=3D" + (columnMetaData.sqlxBase= name_ =3D=3D null ? "" : columnMetaData.sqlxBasename_[column-1]) + ",= "); + printWriter_.print ("sqlxUpdatable=3D" + (columnMetaData.sqlxUpd= atable_ =3D=3D null ? "" : ""+columnMetaData.sqlxUpdatable_[column-1]= ) + ", "); + printWriter_.print ("sqlxSchema=3D" + (columnMetaData.sqlxSchema= _ =3D=3D null ? "" : columnMetaData.sqlxSchema_[column-1]) + ", "); + printWriter_.print ("sqlxRdbnam=3D" + (columnMetaData.sqlxRdbnam= _ =3D=3D null ? "" : columnMetaData.sqlxRdbnam_[column-1]) + ", "); + printWriter_.print ("internal type=3D" + columnMetaData.types_[c= olumn-1] + ", "); + printWriter_.println (" }"); + } + dncprint (header, "{ "); + printWriter_.print ("sqldHold=3D" + columnMetaData.sqldHold_ + ", = "); + printWriter_.print ("sqldReturn=3D" + columnMetaData.sqldReturn_ += ", "); + printWriter_.print ("sqldScroll=3D" + columnMetaData.sqldScroll_ += ", "); + printWriter_.print ("sqldSensitive=3D" + columnMetaData.sqldSensit= ive_ + ", "); + printWriter_.print ("sqldFcode=3D" + columnMetaData.sqldFcode_ + "= , "); + printWriter_.print ("sqldKeytype=3D" + columnMetaData.sqldKeytype_= + ", "); + printWriter_.print ("sqldRdbnam=3D" + columnMetaData.sqldRdbnam_ += ", "); + printWriter_.print ("sqldSchema=3D" + columnMetaData.sqldSchema_); + printWriter_.println (" }"); + printWriter_.flush(); + } + } + catch (SqlException e) { + dncprintln (header, "Encountered an SQL exception while trying to tr= ace column meta data"); + } + } + + // ---------------------- 3-way tracing connects -----------------------= ------ + // Including protocol manager levels, and driver configuration + + // Jdbc 2 + public void traceConnectEntry (ClientDataSource dataSource) + { + if (traceSuspended()) return; + if (loggingEnabled (ClientDataSource.TRACE_DRIVER_CONFIGURATION)) + traceDriverConfigurationJdbc2 (); + if (loggingEnabled (ClientDataSource.TRACE_CONNECTS)) + traceConnectsEntry (dataSource); + } + + // Jdbc 1 + public void traceConnectEntry ( String server, + int port, + String database, + java.util.Properties properties) + { + if (traceSuspended()) return; + if (loggingEnabled (ClientDataSource.TRACE_DRIVER_CONFIGURATION)) + traceDriverConfigurationJdbc1 (); + if (loggingEnabled (ClientDataSource.TRACE_CONNECTS)) + traceConnectsEntry (server, port, database, properties); + } + + public void traceConnectResetEntry (Object instance, LogWriter logWriter= , String user, ClientDataSource ds) + { + if (traceSuspended()) return; + traceEntry (instance, "reset", logWriter, user, "", ds); + if (loggingEnabled(ClientDataSource.TRACE_CONNECTS)) + traceConnectsResetEntry(ds); + } + + public void traceConnectExit (Connection connection) + { + if (traceSuspended()) return; + if (loggingEnabled (ClientDataSource.TRACE_CONNECTS)) + traceConnectsExit (connection); + } + + public void traceConnectResetExit (Connection connection) + { + if (traceSuspended()) return; + if (loggingEnabled (ClientDataSource.TRACE_CONNECTS)) + traceConnectsResetExit (connection); + } + + + // ---------------------- tracing connects -----------------------------= ------ + + private void traceConnectsResetEntry (ClientDataSource dataSource) + { + if (traceSuspended()) return; + try { + traceConnectsResetEntry (dataSource.getServerName(), + dataSource.getPortNumber(), + dataSource.getDatabaseName(), + dataSource.getProperties()); + } + catch (java.sql.SQLException e) { + dncprintln ("Encountered an SQL exception while trying to trace conn= ection reset entry"); + } + } + + private void traceConnectsEntry (ClientDataSource dataSource) + { + if (traceSuspended()) return; + try { + traceConnectsEntry (dataSource.getServerName(), + dataSource.getPortNumber(), + dataSource.getDatabaseName(), + dataSource.getProperties()); + } + catch (java.sql.SQLException e) { + dncprintln ("Encountered an SQL exception while trying to trace conn= ection entry"); + } + } + + private void traceConnectsResetEntry (String server, + int port, + String database, + java.util.Properties properties) + { + if (traceSuspended()) return; + dncprintln ("BEGIN TRACE_CONNECT_RESET"); + dncprintln ("Connection reset requested for " + server + ":" + port + = "/" + database); + dncprint ("Using properties: "); + writeProperties (properties); + dncprintln ("END TRACE_CONNECT_RESET"); + } + + private void traceConnectsEntry (String server, + int port, + String database, + java.util.Properties properties) + { + if (traceSuspended()) return; + synchronized (printWriter_) { + dncprintln ("BEGIN TRACE_CONNECTS"); + dncprintln ("Attempting connection to " + server + ":" + port + "/" = + database); + dncprint ("Using properties: "); + writeProperties (properties); + dncprintln ("END TRACE_CONNECTS"); + } + } + + // Specialized by NetLogWriter.traceConnectsExit() + public void traceConnectsExit (Connection c) + { + if (traceSuspended()) return; + synchronized (printWriter_) { + String header =3D "[Connection@" + Integer.toHexString (c.hashCode()= ) + "]"; + try { + dncprintln (header, "BEGIN TRACE_CONNECTS"); + dncprintln (header, "Successfully connected to server " + c.databa= seMetaData_.getURL()); + dncprintln (header, "User: " + c.databaseMetaData_.getUserName()); + dncprintln (header, "Database product name: " + c.databaseMetaData= _=2EgetDatabaseProductName()); + dncprintln (header, "Database product version: " + c.databaseMetaD= ata_.getDatabaseProductVersion()); + dncprintln (header, "Driver name: " + c.databaseMetaData_.getDrive= rName()); + dncprintln (header, "Driver version: " + c.databaseMetaData_.getDr= iverVersion()); + dncprintln (header, "END TRACE_CONNECTS"); + } + catch (java.sql.SQLException e) { + dncprintln (header, "Encountered an SQL exception while trying to = trace connection exit"); + dncprintln (header, "END TRACE_CONNECTS"); + } + } + } + + public void traceConnectsResetExit (org.apache.derby.client.am.Connectio= n c) + { + if (traceSuspended()) return; + synchronized (printWriter_) { + String header =3D "[Connection@" + Integer.toHexString (c.hashCode()= ) + "]"; + try { + dncprintln (header, "BEGIN TRACE_CONNECT_RESET"); + dncprintln (header, "Successfully reset connection to server " + c= .databaseMetaData_.getURL()); + dncprintln (header, "User: " + c.databaseMetaData_.getUserName()); + dncprintln (header, "Database product name: " + c.databaseMetaData= _=2EgetDatabaseProductName()); + dncprintln (header, "Database product version: " + c.databaseMetaD= ata_.getDatabaseProductVersion()); + dncprintln (header, "Driver name: " + c.databaseMetaData_.getDrive= rName()); + dncprintln (header, "Driver version: " + c.databaseMetaData_.getDr= iverVersion()); + dncprintln (header, "END TRACE_CONNECT_RESET"); + } + catch (java.sql.SQLException e) { + dncprintln (header, "Encountered an SQL exception while trying to = trace connection reset exit"); + dncprintln (header, "END TRACE_CONNECT_RESET"); + } + } + } + + + // properties.toString() will print out passwords, + // so this method was written to escape the password property value. + // printWriter_ synchronized by caller. + private void writeProperties (java.util.Properties properties) + { + printWriter_.print ("{ "); + for (java.util.Iterator i =3D properties.entrySet().iterator(); i.hasN= ext(); ) { + java.util.Map.Entry e =3D (java.util.Map.Entry) (i.next()); + if ("password".equals(e.getKey())){ + printWriter_.print ("password=3D" + escapePassword((String)e.getVa= lue())); + } + else + printWriter_.print (e.getKey() + "=3D" + e.getValue()); + if (i.hasNext()) + printWriter_.print (", "); + } + printWriter_.println (" }"); + printWriter_.flush(); + } + + private String escapePassword(String pw) { + StringBuffer sb =3D new StringBuffer (pw); + for (int j =3D 0; j< pw.length(); j++) { + sb.setCharAt(j,'*'); + } + return sb.toString(); + } + //-------------------------tracing driver configuration-----------------= ------ + + private void traceDriverConfigurationJdbc2 () + { + if (traceSuspended()) return; + synchronized (printWriter_) { + if (!driverConfigurationHasBeenWrittenToJdbc2Stream_) { + writeDriverConfiguration(); + driverConfigurationHasBeenWrittenToJdbc2Stream_ =3D true; + } + } + } + + private void traceDriverConfigurationJdbc1 () + { + if (traceSuspended()) return; + synchronized (printWriter_) { + if (!driverConfigurationHasBeenWrittenToJdbc1Stream_) { + writeDriverConfiguration(); + driverConfigurationHasBeenWrittenToJdbc1Stream_ =3D true; + } + } + } + + public void writeDriverConfiguration() + { + org.apache.derby.client.am.Version.writeDriverConfiguration (printWrit= er_); + } + public static java.io.PrintWriter getPrintWriter (String fileName, boole= an fileAppend) throws SqlException + { + try { + java.io.PrintWriter printWriter =3D null; + String fileCanonicalPath =3D new java.io.File (fileName).getCanonica= lPath(); + printWriter =3D + new java.io.PrintWriter ( + new java.io.BufferedOutputStream ( + new java.io.FileOutputStream (fileCanonicalPath, fileAppend), = 4096), true); + return printWriter; + } + catch (java.io.IOException e) { + throw new SqlException (null, "Unable to open file " + fileName); + } + } + +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/LogWriter.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Lo= gicalConnection.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/LogicalConnection.java?rev=3D165178&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Logic= alConnection.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Logic= alConnection.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,348 @@ +/* + + Derby - Class org.apache.derby.client.am.LogicalConnection + + Copyright (c) 2001, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + + +// A simple delegation wrapper handle for a physical connection. +// All methods are forwarded to the underlying physical connection except = for close() and isClosed(). +// When a physical connection is wrapped, it is non-null, when the logical= connection +// is closed, the wrapped physical connection is always set to null. +// Both the finalizer and close() methods will always set the physical con= nection to null. +// After the physical conneciton is set to null, +// only the Pooled Connection instance will maintain a handle to the physi= cal connection. +public class LogicalConnection implements java.sql.Connection +{ + private Connection physicalConnection_ =3D null; // reset to null when t= he logical connection is closed. + private org.apache.derby.client.ClientPooledConnection pooledConnection_= =3D null; + + public LogicalConnection (Connection physicalConnection, + org.apache.derby.client.ClientPooledConnection= pooledConnection) throws SqlException + { + physicalConnection_ =3D physicalConnection; + pooledConnection_ =3D pooledConnection; + checkForNullPhysicalConnection(); + } + + protected void finalize () throws java.lang.Throwable + { + close(); + } + + // Used by ClientPooledConnection close when it disassociates itself fro= m the LogicalConnection + synchronized public void nullPhysicalConnection () + { + physicalConnection_ =3D null; + } + + // ------------------------ logical connection close -------------------= ------ + // All methods are simply forwarded to the physical connection, except f= or close() and isClosed(). + + synchronized public void close () throws SqlException + { + // we also need to loop thru all the logicalStatements and close them + if (physicalConnection_ =3D=3D null) return; + if (physicalConnection_.agent_.loggingEnabled()) + physicalConnection_.agent_.logWriter_.traceEntry (this, "close"); + + if (physicalConnection_.isClosed()) // connection is closed or has b= ecome stale + pooledConnection_.trashConnection (new SqlException (null, "Connec= tion is stale.")); + + else { + physicalConnection_.closeForReuse(); + if ( ! physicalConnection_.isGlobalPending_() ) + pooledConnection_.recycleConnection(); + } + physicalConnection_ =3D null; + pooledConnection_.nullLogicalConnection(); + } + + synchronized public void closeWithoutRecyclingToPool () throws SqlExcept= ion + { + if (physicalConnection_ =3D=3D null) return; + physicalConnection_.checkForTransactionInProgress(); + try { + if (physicalConnection_.isClosed()) // connection is closed or has b= ecome stale + throw new SqlException (null, "Connection is stale."); // no call = to trashConnection() + else { + ; // no call to recycleConnection() + } + } + finally { + physicalConnection_.closeForReuse(); //poolfix + physicalConnection_ =3D null; + } + } + + public boolean isClosed () throws SqlException + { + if (physicalConnection_ =3D=3D null) return true; + return physicalConnection_.isClosed(); + } + + // --------------------------- helper methods --------------------------= ------ + + // this method doesn't wrap in the standard way, because it went out wit= hout a throws clause. + // Unlike all other LogicalConnection methods, if the physical connectio= n is null, it won't throw an exception, but will return false. + + private void checkForNullPhysicalConnection () throws SqlException + { + if (physicalConnection_ =3D=3D null) + throw new SqlException (null, " Attempt to use a closed connection. = "); + } + + // ---------------------- wrapped public entry points ------------------= ------ + // All methods are forwarded to the physical connection in a standard way + + synchronized public java.sql.Statement createStatement () throws SqlExce= ption + { + checkForNullPhysicalConnection(); + return physicalConnection_.createStatement(); + } + + synchronized public java.sql.PreparedStatement prepareStatement (String = sql) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareStatement(sql); + } + + synchronized public PreparedStatement preparePositionedUpdateStatement (= String sql, Section querySection) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.preparePositionedUpdateStatement (sql, quer= ySection); + } + + synchronized public java.sql.CallableStatement prepareCall (String sql) = throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareCall(sql); + } + + public String nativeSQL (String sql) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.nativeSQL(sql); + } + + synchronized public void setAutoCommit (boolean autoCommit) throws SqlEx= ception + { + checkForNullPhysicalConnection(); + physicalConnection_.setAutoCommit(autoCommit); + } + + public boolean getAutoCommit () throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.getAutoCommit(); + } + + synchronized public void commit () throws SqlException + { + checkForNullPhysicalConnection(); + physicalConnection_.commit(); + } + + synchronized public void rollback () throws SqlException + { + checkForNullPhysicalConnection(); + physicalConnection_.rollback(); + } + + synchronized public void setTransactionIsolation (int level) throws SqlE= xception + { + checkForNullPhysicalConnection(); + physicalConnection_.setTransactionIsolation(level); + } + + public int getTransactionIsolation () throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.getTransactionIsolation(); + } + + public java.sql.SQLWarning getWarnings () throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.getWarnings(); + } + + synchronized public void clearWarnings () throws SqlException + { + checkForNullPhysicalConnection(); + physicalConnection_.clearWarnings(); + } + + public java.sql.DatabaseMetaData getMetaData () throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.getMetaData(); + } + + synchronized public void setReadOnly (boolean readOnly) throws SqlExcept= ion + { + checkForNullPhysicalConnection(); + physicalConnection_.setReadOnly (readOnly); + } + + public boolean isReadOnly () throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.isReadOnly(); + } + + synchronized public void setCatalog (String catalog) throws SqlException + { + checkForNullPhysicalConnection(); + physicalConnection_.setCatalog(catalog); + } + + public String getCatalog () throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.getCatalog(); + } + + synchronized public java.sql.Statement createStatement (int resultSetTyp= e, + int resultSetCon= currency) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.createStatement(resultSetType, resultSetCon= currency); + } + + synchronized public java.sql.PreparedStatement prepareStatement (String = sql, + int res= ultSetType, + int res= ultSetConcurrency) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareStatement(sql, resultSetType, result= SetConcurrency); + } + + synchronized public java.sql.CallableStatement prepareCall (String sql, + int resultSe= tType, + int resultSe= tConcurrency) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareCall(sql, resultSetType, resultSetC= oncurrency); + } + + public java.util.Map getTypeMap () throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.getTypeMap(); + } + + synchronized public void setTypeMap (java.util.Map map) throws SqlExcept= ion + { + checkForNullPhysicalConnection(); + physicalConnection_.setTypeMap(map); + } + + public java.sql.Statement createStatement(int resultSetType, int resultS= etConcurrency, + int resultSetHoldability) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.createStatement(resultSetType, resultSetCon= currency, resultSetHoldability); + } + + public java.sql.CallableStatement prepareCall(String sql, int resultSetT= ype, + int resultSetConcurrency, + int resultSetHoldability) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareCall(sql, resultSetType, resultSetCo= ncurrency, resultSetHoldability); + } + + public java.sql.PreparedStatement prepareStatement(String sql, int resul= tSetType, + int resultSetConcurrency, int resultSetHoldability) + throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareStatement(sql, resultSetType, result= SetConcurrency, + resultSetHoldability); + } + + public java.sql.PreparedStatement prepareStatement(String sql, int autoG= eneratedKeys) + throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareStatement(sql, autoGeneratedKeys); + } + + public java.sql.PreparedStatement prepareStatement(String sql, int colum= nIndexes[]) + throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareStatement(sql, columnIndexes); + } + + public java.sql.PreparedStatement prepareStatement(String sql, String co= lumnNames[]) + throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.prepareStatement(sql, columnNames); + } + + public void setHoldability(int holdability) throws SqlException + { + checkForNullPhysicalConnection(); + physicalConnection_.setHoldability(holdability); + } + + public int getHoldability() throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.getHoldability(); + } + + public java.sql.Savepoint setSavepoint() throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.setSavepoint (); + } + + public java.sql.Savepoint setSavepoint(String name) throws SqlException + { + checkForNullPhysicalConnection(); + return physicalConnection_.setSavepoint (name); + } + + public void rollback(java.sql.Savepoint savepoint) throws SqlException + { + checkForNullPhysicalConnection(); + physicalConnection_.rollback (savepoint); + } + + public void releaseSavepoint(java.sql.Savepoint savepoint) throws SqlExc= eption + { + checkForNullPhysicalConnection(); + physicalConnection_.releaseSavepoint (savepoint); + } + + //----------------------------------------------------------------------= ------ + + public int getServerVersion() + { + if (physicalConnection_ =3D=3D null) + return -1; + else + return physicalConnection_.getServerVersion(); + } + +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/LogicalConnection.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Ma= terialPreparedStatement.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/MaterialPreparedStatement.java?rev=3D165178&view= =3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Mater= ialPreparedStatement.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Mater= ialPreparedStatement.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,60 @@ +/* + + Derby - Class org.apache.derby.client.am.MaterialPreparedStatement + + Copyright (c) 2001, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + +import org.apache.derby.client.am.Section; + +public interface MaterialPreparedStatement extends MaterialStatement +{ + + + // ------------------------ abstract box car and callback methods ------= -------------------------- + + public abstract void writeExecute_ (Section section, + ColumnMetaData parameterMetaData, + Object[] inputs, + int numInputColumns, + boolean outputExpected, + // This is a hint to the material layer that m= ore write commands will follow. + // It is ignored by the driver in all cases ex= cept when blob data is written, + // in which case this boolean is used to optim= ize the implementation. + // Otherwise we wouldn't be able to chain afte= r blob data is sent. + // Current servers have a restriction that blo= bs can only be chained with blobs + // Can the blob code + boolean chainedWritesFollowingSetLob + ) throws SqlException; + + + public abstract void readExecute_ () throws SqlException; + + public abstract void writeOpenQuery_ (Section section, + int fetchSize, + int resultSetType, + int numInputColumns, + ColumnMetaData parameterMetaData, + Object[] inputs + ) throws SqlException; + public abstract void writeDescribeInput_ (Section section) throws SqlExc= eption; + public abstract void readDescribeInput_ () throws SqlException; + + public abstract void writeDescribeOutput_ (Section section) throws SqlEx= ception; + public abstract void readDescribeOutput_ () throws SqlException; +} Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/MaterialPreparedStatement.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Added: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Ma= terialStatement.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/MaterialStatement.java?rev=3D165178&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Mater= ialStatement.java (added) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Mater= ialStatement.java Thu Apr 28 12:05:42 2005 @@ -0,0 +1,64 @@ +/* + + Derby - Class org.apache.derby.client.am.MaterialStatement + + Copyright (c) 2001, 2005 The Apache Software Foundation or its licensor= s, where applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +package org.apache.derby.client.am; + +import org.apache.derby.client.am.Section; + +public interface MaterialStatement +{ + public abstract void writeExecuteImmediate_ (String sql, Section section= ) throws SqlException; + public abstract void readExecuteImmediate_ () throws SqlException; + // The sql parameter is supplied in the read method for drivers that + // process all commands on the "read-side" and do little/nothing on the = "write-side". + // Drivers that follow the write/read paradigm (e.g. NET) will likely ig= nore the sql parameter. + public abstract void readExecuteImmediateForBatch_ (String sql) throws S= qlException; + + public abstract void writePrepareDescribeOutput_ (String sql, Section se= ction) throws SqlException; + public abstract void readPrepareDescribeOutput_ () throws SqlException; + + public abstract void writeOpenQuery_ (Section section, + int fetchSize, + int resultSetType) throws SqlException; + public abstract void readOpenQuery_ () throws SqlException; + + public abstract void writeExecuteCall_ (boolean outputExpected, + String procedureName, + Section section, + int fetchSize, + boolean suppressResultSets, // for batch = updates set to true, otherwise to false + int resultSetType, + ColumnMetaData parameterMetaData, + Object[] inputs) throws SqlException; + public abstract void readExecuteCall_ () throws SqlException; + + // Used for re-prepares across commit and other places as well + public abstract void writePrepare_ (String sql, Section section) throws = SqlException; + public abstract void readPrepare_ () throws SqlException; + + public abstract void markClosedOnServer_(); + + public abstract void writeSetSpecialRegister_ (java.util.ArrayList sqlst= tList) throws SqlException; + public abstract void readSetSpecialRegister_ () throws SqlException; + + public abstract void reset_ (); + +} + Propchange: incubator/derby/code/trunk/java/client/org/apache/derby/client/= am/MaterialStatement.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native