You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by jb...@apache.org on 2005/05/02 08:26:03 UTC
svn commit: r165585 [23/42] - in
/incubator/derby/code/trunk/java/client/org/apache/derby: client/
client/am/ client/net/ client/resources/ jdbc/
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCallbackInterface.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCallbackInterface.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCallbackInterface.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCallbackInterface.java Sun May 1 23:25:59 2005
@@ -20,40 +20,43 @@
package org.apache.derby.client.am;
-import org.apache.derby.client.am.Section;
+
// Methods implemented by the common Statement class to handle
// certain events that may originate from the material or common layers.
//
// Reply implementations may update statement state via this interface.
//
-public interface StatementCallbackInterface
-{
- // A query has been opened on the server.
- public void completeOpenQuery (Sqlca sqlca, ResultSet resultSet) throws DisconnectException;
- public void completeExecuteCallOpenQuery (Sqlca sqlca, ResultSet resultSet, ColumnMetaData resultSetMetaData, Section generatedSection);
- // Chains a warning onto the statement.
- public void accumulateWarning (SqlWarning e);
+public interface StatementCallbackInterface {
+ // A query has been opened on the server.
+ public void completeOpenQuery(Sqlca sqlca, ResultSet resultSet) throws DisconnectException;
+
+ public void completeExecuteCallOpenQuery(Sqlca sqlca, ResultSet resultSet, ColumnMetaData resultSetMetaData, Section generatedSection);
+
+ // Chains a warning onto the statement.
+ public void accumulateWarning(SqlWarning e);
+
+ public void completePrepare(Sqlca sqlca);
+
+ public void completePrepareDescribeOutput(ColumnMetaData columnMetaData, Sqlca sqlca);
- public void completePrepare (Sqlca sqlca);
+ public void completeExecuteImmediate(Sqlca sqlca);
- public void completePrepareDescribeOutput (ColumnMetaData columnMetaData, Sqlca sqlca);
+ public void completeExecuteSetStatement(Sqlca sqlca);
- public void completeExecuteImmediate (Sqlca sqlca);
- public void completeExecuteSetStatement (Sqlca sqlca);
+ public void completeExecute(Sqlca sqlca);
+ public void completeExecuteCall(Sqlca sqlca, Cursor params, ResultSet[] resultSets);
- public void completeExecute (Sqlca sqlca);
- public void completeExecuteCall (Sqlca sqlca, Cursor params, ResultSet[] resultSets);
- public void completeExecuteCall (Sqlca sqlca, Cursor params);
+ public void completeExecuteCall(Sqlca sqlca, Cursor params);
- public int completeSqlca (Sqlca sqlca);
+ public int completeSqlca(Sqlca sqlca);
- public ConnectionCallbackInterface getConnectionCallbackInterface ();
+ public ConnectionCallbackInterface getConnectionCallbackInterface();
- public ColumnMetaData getGuessedResultSetMetaData ();
+ public ColumnMetaData getGuessedResultSetMetaData();
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java Sun May 1 23:25:59 2005
@@ -21,147 +21,153 @@
// This enumeration of types represents the typing scheme used by our jdbc driver.
// Once this is finished, we need to review our switches to make sure they are exhaustive
-public class Types
-{
- // -------------------------------- Driver types -------------------------------------------------
-
- // Not currently supported as a DERBY column type. Mapped to SMALLINT.
- // public final static int BIT = java.sql.Types.BIT; // -7;
-
- // Not currently supported as a DERBY column type. Mapped to SMALLINT.
- //public final static int TINYINT = java.sql.Types.TINYINT; // -6;
-
- public final static int SMALLINT = java.sql.Types.SMALLINT; // 5;
-
- public final static int INTEGER = java.sql.Types.INTEGER; // 4;
-
- public final static int BIGINT = java.sql.Types.BIGINT; // -5;
-
- // We type using DOUBLE
- //public final static int FLOAT = java.sql.Types.FLOAT; // 6;
-
- public final static int REAL = java.sql.Types.REAL; // 7;
-
- public final static int DOUBLE = java.sql.Types.DOUBLE; // 8;
-
- // We type using DECIMAL
- //public final static int NUMERIC = java.sql.Types.NUMERIC; // 2;
-
- public final static int DECIMAL = java.sql.Types.DECIMAL; // 3;
-
- public final static int CHAR = java.sql.Types.CHAR; // 1;
-
- public final static int VARCHAR = java.sql.Types.VARCHAR; // 12;
-
- public final static int LONGVARCHAR = java.sql.Types.LONGVARCHAR; // -1;
-
- public final static int DATE = java.sql.Types.DATE; // 91;
-
- public final static int TIME = java.sql.Types.TIME; // 92;
-
- public final static int TIMESTAMP = java.sql.Types.TIMESTAMP; // 93;
-
- public final static int BINARY = java.sql.Types.BINARY; // -2;
-
- public final static int VARBINARY = java.sql.Types.VARBINARY; // -3;
-
- public final static int LONGVARBINARY = java.sql.Types.LONGVARBINARY; // -4;
-
- public final static int BLOB = java.sql.Types.BLOB; // 2004;
-
- public final static int CLOB = java.sql.Types.CLOB; // 2005;
-
- // hide the default constructor
- private Types() {}
-
- // -------------------------------- DERBY types ----------------------------------------------------
-
- public final static int DERBY_SQLTYPE_DATE = 384; // DATE
- public final static int DERBY_SQLTYPE_NDATE = 385;
- public final static int DERBY_SQLTYPE_TIME = 388; // TIME
- public final static int DERBY_SQLTYPE_NTIME = 389;
- public final static int DERBY_SQLTYPE_TIMESTAMP = 392; // TIMESTAMP
- public final static int DERBY_SQLTYPE_NTIMESTAMP = 393;
-
- public final static int DERBY_SQLTYPE_BLOB = 404; // BLOB
- public final static int DERBY_SQLTYPE_NBLOB = 405;
- public final static int DERBY_SQLTYPE_CLOB = 408; // CLOB
- public final static int DERBY_SQLTYPE_NCLOB = 409;
-
- public final static int DERBY_SQLTYPE_VARCHAR = 448; // VARCHAR(i) - varying length string
- public final static int DERBY_SQLTYPE_NVARCHAR = 449;
- public final static int DERBY_SQLTYPE_CHAR = 452; // CHAR(i) - fixed length
- public final static int DERBY_SQLTYPE_NCHAR = 453;
- public final static int DERBY_SQLTYPE_LONG = 456; // LONG VARCHAR - varying length string
- public final static int DERBY_SQLTYPE_NLONG = 457;
- public final static int DERBY_SQLTYPE_CSTR = 460; // SBCS - null terminated
- public final static int DERBY_SQLTYPE_NCSTR = 461;
-
- public final static int DERBY_SQLTYPE_FLOAT = 480; // FLOAT - 4 or 8 byte floating point
- public final static int DERBY_SQLTYPE_NFLOAT = 481;
- public final static int DERBY_SQLTYPE_DECIMAL = 484; // DECIMAL (m,n)
- public final static int DERBY_SQLTYPE_NDECIMAL = 485;
- public final static int DERBY_SQLTYPE_BIGINT = 492; // BIGINT - 8-byte signed integer
- public final static int DERBY_SQLTYPE_NBIGINT = 493;
- public final static int DERBY_SQLTYPE_INTEGER = 496; // INTEGER
- public final static int DERBY_SQLTYPE_NINTEGER = 497;
- public final static int DERBY_SQLTYPE_SMALL = 500; // SMALLINT - 2-byte signed integer */
- public final static int DERBY_SQLTYPE_NSMALL = 501;
-
- public final static int DERBY_SQLTYPE_NUMERIC = 504; // NUMERIC -> DECIMAL (m,n)
- public final static int DERBY_SQLTYPE_NNUMERIC = 505;
-
- static public int mapDERBYTypeToDriverType (boolean isDescribed, int sqlType, long length, int ccsid)
- {
- switch (Utils.getNonNullableSqlType (sqlType)) { // mask the isNullable bit
- case DERBY_SQLTYPE_SMALL:
- return SMALLINT;
- case DERBY_SQLTYPE_INTEGER:
- return INTEGER;
- case DERBY_SQLTYPE_BIGINT:
- return BIGINT;
- case DERBY_SQLTYPE_FLOAT:
- if (length == 16) // can map to either NUMERIC or DECIMAL
- return DECIMAL;
- else if (length == 8) // can map to either DOUBLE or FLOAT
- return DOUBLE;
- else if (length == 4)
- return REAL;
- else
- return 0;
- case DERBY_SQLTYPE_DECIMAL: // can map to either NUMERIC or DECIMAL
- case DERBY_SQLTYPE_NUMERIC: // can map to either NUMERIC or DECIMAL
- return DECIMAL;
- case DERBY_SQLTYPE_CHAR: // mixed and single byte
- if (isDescribed && (ccsid == 0xffff || ccsid == 0))
- return BINARY;
- else
- return CHAR;
- case DERBY_SQLTYPE_CSTR: // null terminated SBCS/Mixed
- return CHAR;
- // use ccsid to distinguish between BINARY and CHAR, VARBINARY and VARCHAR, LONG...
- case DERBY_SQLTYPE_VARCHAR: // variable character SBCS/Mixed
- if (isDescribed && (ccsid == 0xffff || ccsid == 0))
- return VARBINARY;
- else
- return VARCHAR;
- case DERBY_SQLTYPE_LONG: // long varchar SBCS/Mixed
- if (isDescribed && (ccsid == 0xffff || ccsid == 0))
- return LONGVARBINARY;
- else
- return LONGVARCHAR;
- case DERBY_SQLTYPE_DATE:
- return DATE;
- case DERBY_SQLTYPE_TIME:
- return TIME;
- case DERBY_SQLTYPE_TIMESTAMP:
- return TIMESTAMP;
- case DERBY_SQLTYPE_CLOB: // large object character SBCS/Mixed
- return Types.CLOB;
- case DERBY_SQLTYPE_BLOB: // large object bytes
- return java.sql.Types.BLOB;
- default:
- return 0;
+
+public class Types {
+ // -------------------------------- Driver types -------------------------------------------------
+
+ // Not currently supported as a DERBY column type. Mapped to SMALLINT.
+ // public final static int BIT = java.sql.Types.BIT; // -7;
+
+ // Not currently supported as a DERBY column type. Mapped to SMALLINT.
+ //public final static int TINYINT = java.sql.Types.TINYINT; // -6;
+
+ public final static int SMALLINT = java.sql.Types.SMALLINT; // 5;
+
+ public final static int INTEGER = java.sql.Types.INTEGER; // 4;
+
+ public final static int BIGINT = java.sql.Types.BIGINT; // -5;
+
+ // We type using DOUBLE
+ //public final static int FLOAT = java.sql.Types.FLOAT; // 6;
+
+ public final static int REAL = java.sql.Types.REAL; // 7;
+
+ public final static int DOUBLE = java.sql.Types.DOUBLE; // 8;
+
+ // We type using DECIMAL
+ //public final static int NUMERIC = java.sql.Types.NUMERIC; // 2;
+
+ public final static int DECIMAL = java.sql.Types.DECIMAL; // 3;
+
+ public final static int CHAR = java.sql.Types.CHAR; // 1;
+
+ public final static int VARCHAR = java.sql.Types.VARCHAR; // 12;
+
+ public final static int LONGVARCHAR = java.sql.Types.LONGVARCHAR; // -1;
+
+ public final static int DATE = java.sql.Types.DATE; // 91;
+
+ public final static int TIME = java.sql.Types.TIME; // 92;
+
+ public final static int TIMESTAMP = java.sql.Types.TIMESTAMP; // 93;
+
+ public final static int BINARY = java.sql.Types.BINARY; // -2;
+
+ public final static int VARBINARY = java.sql.Types.VARBINARY; // -3;
+
+ public final static int LONGVARBINARY = java.sql.Types.LONGVARBINARY; // -4;
+
+ public final static int BLOB = java.sql.Types.BLOB; // 2004;
+
+ public final static int CLOB = java.sql.Types.CLOB; // 2005;
+
+ // hide the default constructor
+ private Types() {
+ }
+
+ // -------------------------------- DERBY types ----------------------------------------------------
+
+ public final static int DERBY_SQLTYPE_DATE = 384; // DATE
+ public final static int DERBY_SQLTYPE_NDATE = 385;
+ public final static int DERBY_SQLTYPE_TIME = 388; // TIME
+ public final static int DERBY_SQLTYPE_NTIME = 389;
+ public final static int DERBY_SQLTYPE_TIMESTAMP = 392; // TIMESTAMP
+ public final static int DERBY_SQLTYPE_NTIMESTAMP = 393;
+
+ public final static int DERBY_SQLTYPE_BLOB = 404; // BLOB
+ public final static int DERBY_SQLTYPE_NBLOB = 405;
+ public final static int DERBY_SQLTYPE_CLOB = 408; // CLOB
+ public final static int DERBY_SQLTYPE_NCLOB = 409;
+
+ public final static int DERBY_SQLTYPE_VARCHAR = 448; // VARCHAR(i) - varying length string
+ public final static int DERBY_SQLTYPE_NVARCHAR = 449;
+ public final static int DERBY_SQLTYPE_CHAR = 452; // CHAR(i) - fixed length
+ public final static int DERBY_SQLTYPE_NCHAR = 453;
+ public final static int DERBY_SQLTYPE_LONG = 456; // LONG VARCHAR - varying length string
+ public final static int DERBY_SQLTYPE_NLONG = 457;
+ public final static int DERBY_SQLTYPE_CSTR = 460; // SBCS - null terminated
+ public final static int DERBY_SQLTYPE_NCSTR = 461;
+
+ public final static int DERBY_SQLTYPE_FLOAT = 480; // FLOAT - 4 or 8 byte floating point
+ public final static int DERBY_SQLTYPE_NFLOAT = 481;
+ public final static int DERBY_SQLTYPE_DECIMAL = 484; // DECIMAL (m,n)
+ public final static int DERBY_SQLTYPE_NDECIMAL = 485;
+ public final static int DERBY_SQLTYPE_BIGINT = 492; // BIGINT - 8-byte signed integer
+ public final static int DERBY_SQLTYPE_NBIGINT = 493;
+ public final static int DERBY_SQLTYPE_INTEGER = 496; // INTEGER
+ public final static int DERBY_SQLTYPE_NINTEGER = 497;
+ public final static int DERBY_SQLTYPE_SMALL = 500; // SMALLINT - 2-byte signed integer */
+ public final static int DERBY_SQLTYPE_NSMALL = 501;
+
+ public final static int DERBY_SQLTYPE_NUMERIC = 504; // NUMERIC -> DECIMAL (m,n)
+ public final static int DERBY_SQLTYPE_NNUMERIC = 505;
+
+ static public int mapDERBYTypeToDriverType(boolean isDescribed, int sqlType, long length, int ccsid) {
+ switch (Utils.getNonNullableSqlType(sqlType)) { // mask the isNullable bit
+ case DERBY_SQLTYPE_SMALL:
+ return SMALLINT;
+ case DERBY_SQLTYPE_INTEGER:
+ return INTEGER;
+ case DERBY_SQLTYPE_BIGINT:
+ return BIGINT;
+ case DERBY_SQLTYPE_FLOAT:
+ if (length == 16) // can map to either NUMERIC or DECIMAL
+ {
+ return DECIMAL;
+ } else if (length == 8) // can map to either DOUBLE or FLOAT
+ {
+ return DOUBLE;
+ } else if (length == 4) {
+ return REAL;
+ } else {
+ return 0;
+ }
+ case DERBY_SQLTYPE_DECIMAL: // can map to either NUMERIC or DECIMAL
+ case DERBY_SQLTYPE_NUMERIC: // can map to either NUMERIC or DECIMAL
+ return DECIMAL;
+ case DERBY_SQLTYPE_CHAR: // mixed and single byte
+ if (isDescribed && (ccsid == 0xffff || ccsid == 0)) {
+ return BINARY;
+ } else {
+ return CHAR;
+ }
+ case DERBY_SQLTYPE_CSTR: // null terminated SBCS/Mixed
+ return CHAR;
+ // use ccsid to distinguish between BINARY and CHAR, VARBINARY and VARCHAR, LONG...
+ case DERBY_SQLTYPE_VARCHAR: // variable character SBCS/Mixed
+ if (isDescribed && (ccsid == 0xffff || ccsid == 0)) {
+ return VARBINARY;
+ } else {
+ return VARCHAR;
+ }
+ case DERBY_SQLTYPE_LONG: // long varchar SBCS/Mixed
+ if (isDescribed && (ccsid == 0xffff || ccsid == 0)) {
+ return LONGVARBINARY;
+ } else {
+ return LONGVARCHAR;
+ }
+ case DERBY_SQLTYPE_DATE:
+ return DATE;
+ case DERBY_SQLTYPE_TIME:
+ return TIME;
+ case DERBY_SQLTYPE_TIMESTAMP:
+ return TIMESTAMP;
+ case DERBY_SQLTYPE_CLOB: // large object character SBCS/Mixed
+ return Types.CLOB;
+ case DERBY_SQLTYPE_BLOB: // large object bytes
+ return java.sql.Types.BLOB;
+ default:
+ return 0;
+ }
}
- }
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/UnitOfWorkListener.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/UnitOfWorkListener.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/UnitOfWorkListener.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/UnitOfWorkListener.java Sun May 1 23:25:59 2005
@@ -20,11 +20,10 @@
package org.apache.derby.client.am;
-public interface UnitOfWorkListener
-{
- public void listenToUnitOfWork ();
+public interface UnitOfWorkListener {
+ public void listenToUnitOfWork();
- public void completeLocalCommit (java.util.Iterator listenerIterator);
+ public void completeLocalCommit(java.util.Iterator listenerIterator);
- public void completeLocalRollback (java.util.Iterator listenerIterator);
+ public void completeLocalRollback(java.util.Iterator listenerIterator);
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java Sun May 1 23:25:59 2005
@@ -22,289 +22,294 @@
// Self-contained utilities.
// Don't reference any other driver classes, except Configuration, from within this class.
-public final class Utils
-{
- static String getStringFromBytes (byte[] bytes)
- {
- if (bytes == null) return "{}";
- StringBuffer stringBuffer = new StringBuffer (bytes.length*6 + 4);
- stringBuffer.append ("{ ");
- for (int i=0; i < bytes.length; i++) {
- stringBuffer.append ("0x");
- stringBuffer.append (Integer.toHexString (bytes[i] & 0xff));
- if (i != bytes.length - 1) stringBuffer.append (", ");
- }
- stringBuffer.append (" }");
- return stringBuffer.toString();
- }
-
- static String getStringFromInts (int[] ints)
- {
- if (ints == null) return "{}";
- StringBuffer stringBuffer = new StringBuffer ();
- stringBuffer.append ("{ ");
- for (int i=0; i < ints.length; i++) {
- stringBuffer.append (String.valueOf (ints[i]));
- if (i != ints.length - 1) stringBuffer.append (", ");
- }
- stringBuffer.append (" }");
- return stringBuffer.toString();
- }
-
- static String getStringFromStrings (String[] strings)
- {
- if (strings == null) return "{}";
- StringBuffer stringBuffer = new StringBuffer ();
- stringBuffer.append ("{ ");
- for (int i=0; i < strings.length; i++) {
- stringBuffer.append (strings[i]);
- if (i != strings.length - 1) stringBuffer.append (", ");
- }
- stringBuffer.append (" }");
- return stringBuffer.toString();
- }
-
- static public int computeBigDecimalPrecision (java.math.BigDecimal decimal)
- {
- byte[] bBytes = decimal.unscaledValue().abs().toByteArray();
-
- if (byteArrayCmp (bBytes, tenRadixArr[tenRadixArr.length-1]) >= 0)
- throw new java.lang.IllegalArgumentException ("Precision exceeds 31 digits!");
-
- int lo=0, hi=tenRadixArr.length-1, mi=(hi+lo)/2;
- do {
- int compare = byteArrayCmp (bBytes, tenRadixArr[mi]);
- if (compare == 1)
- lo = mi;
- else if (compare == -1)
- hi = mi;
- else
- break;
-
- mi = (hi+lo)/2;
- }
- while (mi != lo);
-
- return (mi+1);
- }
-
- // Used only by computeBigDecimalPrecision()
- private static int byteArrayCmp (byte[] arg1, byte[] arg2)
- {
- int arg1Offset = 0;
- int arg2Offset = 0;
- int length;
- if (arg1.length > arg2.length) {
- int diff = arg1.length-arg2.length;
- for (; arg1Offset<diff; arg1Offset++)
- if (arg1[arg1Offset] != 0) return 1;
- length = arg2.length;
- }
- else if (arg1.length < arg2.length) {
- int diff = arg2.length-arg1.length;
- for (; arg2Offset<diff; arg2Offset++)
- if (arg2[arg2Offset] != 0) return -1;
- length = arg1.length;
- }
- else {
- length = arg1.length;
- }
-
- for (int i=0; i<length; i++) {
- int b1 = arg1[arg1Offset+i] & 0xFF;
- int b2 = arg2[arg2Offset+i] & 0xFF;
- if (b1 > b2)
- return 1;
- else if (b1 < b2)
- return -1;
- }
- return 0;
- }
-
- // Used only by computeBigDecimalPrecision()
- // byte array of 1, 10, 100, 1000, 10000, ..., 10^31 for
- // fast computing the length a BigDecimal.
- private static byte[][] tenRadixArr = {
- { (byte)0x01 }, // 10^0
- { (byte)0x0A }, // 10^1
- { (byte)0x64 }, // 10^2
- { (byte)0x03, (byte)0xe8 }, // 10^3
- { (byte)0x27, (byte)0x10 }, // 10^4
- { (byte)0x01, (byte)0x86, (byte)0xa0 }, // 10^5
- { (byte)0x0f, (byte)0x42, (byte)0x40 }, // 10^6
- { (byte)0x98, (byte)0x96, (byte)0x80 }, // 10^7
- { (byte)0x05, (byte)0xf5, (byte)0xe1, (byte)0x00 }, // 10^8
- { (byte)0x3b, (byte)0x9a, (byte)0xca, (byte)0x00 }, // 10^9
- { (byte)0x02, (byte)0x54, (byte)0x0b, (byte)0xe4, (byte)0x00 }, // 10^10
- { (byte)0x17, (byte)0x48, (byte)0x76, (byte)0xe8, (byte)0x00 }, // 10^11
- { (byte)0xe8, (byte)0xd4, (byte)0xa5, (byte)0x10, (byte)0x00 }, // 10^12
- { (byte)0x09, (byte)0x18, (byte)0x4e, (byte)0x72, (byte)0xa0, (byte)0x00 }, // 10^13
- { (byte)0x5a, (byte)0xf3, (byte)0x10, (byte)0x7a, (byte)0x40, (byte)0x00 }, // 10^14
- { (byte)0x03, (byte)0x8d, (byte)0x7e, (byte)0xa4, (byte)0xc6, (byte)0x80, (byte)0x00 }, // 10^15
- { (byte)0x23, (byte)0x86, (byte)0xf2, (byte)0x6f, (byte)0xc1, (byte)0x00, (byte)0x00 }, // 10^16
- { (byte)0x01, (byte)0x63, (byte)0x45, (byte)0x78, (byte)0x5d, (byte)0x8a, (byte)0x00, (byte)0x00 }, // 10^17
- { (byte)0x0d, (byte)0xe0, (byte)0xb6, (byte)0xb3, (byte)0xa7, (byte)0x64, (byte)0x00, (byte)0x00 }, // 10^18
- { (byte)0x8a, (byte)0xc7, (byte)0x23, (byte)0x04, (byte)0x89, (byte)0xe8, (byte)0x00, (byte)0x00 }, // 10^19
- { (byte)0x05, (byte)0x6b, (byte)0xc7, (byte)0x5e, (byte)0x2d, (byte)0x63, (byte)0x10, (byte)0x00, (byte)0x00 }, // 10^20
- { (byte)0x36, (byte)0x35, (byte)0xc9, (byte)0xad, (byte)0xc5, (byte)0xde, (byte)0xa0, (byte)0x00, (byte)0x00 }, // 10^21
- { (byte)0x02, (byte)0x1e, (byte)0x19, (byte)0xe0, (byte)0xc9, (byte)0xba, (byte)0xb2, (byte)0x40, (byte)0x00, (byte)0x00 }, // 10^22
- { (byte)0x15, (byte)0x2d, (byte)0x02, (byte)0xc7, (byte)0xe1, (byte)0x4a, (byte)0xf6, (byte)0x80, (byte)0x00, (byte)0x00 }, // 10^23
- { (byte)0xd3, (byte)0xc2, (byte)0x1b, (byte)0xce, (byte)0xcc, (byte)0xed, (byte)0xa1, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^24
- { (byte)0x08, (byte)0x45, (byte)0x95, (byte)0x16, (byte)0x14, (byte)0x01, (byte)0x48, (byte)0x4a, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^25
- { (byte)0x52, (byte)0xb7, (byte)0xd2, (byte)0xdc, (byte)0xc8, (byte)0x0c, (byte)0xd2, (byte)0xe4, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^26
- { (byte)0x03, (byte)0x3b, (byte)0x2e, (byte)0x3c, (byte)0x9f, (byte)0xd0, (byte)0x80, (byte)0x3c, (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^27
- { (byte)0x20, (byte)0x4f, (byte)0xce, (byte)0x5e, (byte)0x3e, (byte)0x25, (byte)0x02, (byte)0x61, (byte)0x10, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^28
- { (byte)0x01, (byte)0x43, (byte)0x1e, (byte)0x0f, (byte)0xae, (byte)0x6d, (byte)0x72, (byte)0x17, (byte)0xca, (byte)0xa0, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^29
- { (byte)0x0c, (byte)0x9f, (byte)0x2c, (byte)0x9c, (byte)0xd0, (byte)0x46, (byte)0x74, (byte)0xed, (byte)0xea, (byte)0x40, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^30
- { (byte)0x7e, (byte)0x37, (byte)0xbe, (byte)0x20, (byte)0x22, (byte)0xc0, (byte)0x91, (byte)0x4b, (byte)0x26, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00 } // 10^31
- };
-
- // If the input string is short, pad it with blanks.
- // If the input string is long, truncate it.
- static public String padOrTruncate (String s, int fixedLength)
- {
- if (s.length() >= fixedLength) // we need to truncate
- return s.substring (0, fixedLength);
- else { // we need to pad
- StringBuffer buffer = new StringBuffer (s);
- for (int i = 0; i < fixedLength - s.length(); i++)
- buffer.append (" ");
- return buffer.toString();
- }
- }
-
- static public void checkForNegativePositiveSqlcard (Sqlca sqlca, Statement statement) throws SqlException
- {
- if (sqlca != null) {
- int sqlcode = sqlca.getSqlCode ();
- if (sqlcode < 0) {
- throw new SqlException (statement.agent_.logWriter_, sqlca);
- }
- else {
- if (sqlcode > 0)
- statement.accumulateWarning (new SqlWarning (statement.agent_.logWriter_, sqlca));
- }
- }
- }
-
- static public void checkForNegativePositiveSqlcard (Sqlca sqlca, ResultSet resultSet) throws SqlException
- {
- if (sqlca != null) {
- int sqlcode = sqlca.getSqlCode ();
- if (sqlcode < 0) {
- throw new SqlException (resultSet.agent_.logWriter_, sqlca);
- }
- else {
- if (sqlcode > 0)
- resultSet.accumulateWarning (new SqlWarning (resultSet.agent_.logWriter_, sqlca));
- }
- }
- }
-
- static public int getSqlcodeFromSqlca (Sqlca sqlca)
- {
- if (sqlca == null)
- return 0;
- return sqlca.getSqlCode();
- }
-
- static public int getUpdateCountFromSqlcard (Sqlca sqlca)
- {
- if (sqlca == null)
- return 0;
- else
- return sqlca.getUpdateCount();
- }
-
- public static int min (int i, int j)
- {
- return (i < j) ? i : j;
- }
-
- public static int max (int i, int j)
- {
- return (i < j) ? j : i;
- }
-
- // latestException is assumed to be non-null, accumulatedExceptions can be null
- public static SqlException accumulateSQLException (SqlException latestException,
- SqlException accumulatedExceptions)
- {
- if (accumulatedExceptions == null)
- return latestException;
- else {
- accumulatedExceptions.setNextException (latestException);
- return accumulatedExceptions;
- }
- }
-
- // latestException is assumed to be non-null, accumulatedExceptions can be null
- public static SqlWarning accumulateSQLWarning (SqlWarning latestException,
- SqlWarning accumulatedExceptions)
- {
- latestException.setNextException (accumulatedExceptions);
- return latestException;
- }
-
- // just a thought...
- static String getSQLTypeName (int sqlType)
- {
- switch (sqlType) {
- case java.sql.Types.BIGINT:
- return "BIGINT";
- case java.sql.Types.BINARY:
- return "BINARY";
- case java.sql.Types.BIT:
- return "BIT";
- case java.sql.Types.CHAR:
- return "CHAR";
- case java.sql.Types.DATE:
- return "DATE";
- case java.sql.Types.DECIMAL:
- return "DECIMAL";
- case java.sql.Types.DOUBLE:
- return "DOUBLE";
- case java.sql.Types.REAL:
- return "REAL";
- case java.sql.Types.INTEGER:
- return "INTEGER";
- case java.sql.Types.LONGVARBINARY:
- return "LONGVARBINARY";
- case java.sql.Types.LONGVARCHAR:
- return "LONGVARCHAR";
- case java.sql.Types.NULL:
- return "NULL";
- case java.sql.Types.NUMERIC:
- return "NUMERIC";
- case java.sql.Types.OTHER:
- return "OTHER";
- case java.sql.Types.FLOAT:
- return "FLOAT";
- case java.sql.Types.SMALLINT:
- return "SMALLINT";
- case java.sql.Types.TIME:
- return "TIME";
- case java.sql.Types.TIMESTAMP:
- return "TIMESTAMP";
- case java.sql.Types.TINYINT:
- return "TINYINT";
- case java.sql.Types.VARBINARY:
- return "VARBINARY";
- case java.sql.Types.VARCHAR:
- return "VARCHAR";
- default:
- return null;
- }
- }
-
- public static boolean isSqlTypeNullable (int sqlType)
- {
- return (sqlType | 0x01) == sqlType;
- }
-
- public static int getNonNullableSqlType (int sqlType)
- {
- return sqlType & ~1;
- }
+public final class Utils {
+
+ static String getStringFromBytes(byte[] bytes) {
+ if (bytes == null) {
+ return "{}";
+ }
+ StringBuffer stringBuffer = new StringBuffer(bytes.length * 6 + 4);
+ stringBuffer.append("{ ");
+ for (int i = 0; i < bytes.length; i++) {
+ stringBuffer.append("0x");
+ stringBuffer.append(Integer.toHexString(bytes[i] & 0xff));
+ if (i != bytes.length - 1) {
+ stringBuffer.append(", ");
+ }
+ }
+ stringBuffer.append(" }");
+ return stringBuffer.toString();
+ }
+
+ static String getStringFromInts(int[] ints) {
+ if (ints == null) {
+ return "{}";
+ }
+ StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer.append("{ ");
+ for (int i = 0; i < ints.length; i++) {
+ stringBuffer.append(String.valueOf(ints[i]));
+ if (i != ints.length - 1) {
+ stringBuffer.append(", ");
+ }
+ }
+ stringBuffer.append(" }");
+ return stringBuffer.toString();
+ }
+
+ static String getStringFromStrings(String[] strings) {
+ if (strings == null) {
+ return "{}";
+ }
+ StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer.append("{ ");
+ for (int i = 0; i < strings.length; i++) {
+ stringBuffer.append(strings[i]);
+ if (i != strings.length - 1) {
+ stringBuffer.append(", ");
+ }
+ }
+ stringBuffer.append(" }");
+ return stringBuffer.toString();
+ }
+
+ static public int computeBigDecimalPrecision(java.math.BigDecimal decimal) {
+ byte[] bBytes = decimal.unscaledValue().abs().toByteArray();
+
+ if (byteArrayCmp(bBytes, tenRadixArr[tenRadixArr.length - 1]) >= 0) {
+ throw new java.lang.IllegalArgumentException("Precision exceeds 31 digits!");
+ }
+
+ int lo = 0, hi = tenRadixArr.length - 1, mi = (hi + lo) / 2;
+ do {
+ int compare = byteArrayCmp(bBytes, tenRadixArr[mi]);
+ if (compare == 1) {
+ lo = mi;
+ } else if (compare == -1) {
+ hi = mi;
+ } else {
+ break;
+ }
+
+ mi = (hi + lo) / 2;
+ } while (mi != lo);
+
+ return (mi + 1);
+ }
+
+ // Used only by computeBigDecimalPrecision()
+ private static int byteArrayCmp(byte[] arg1, byte[] arg2) {
+ int arg1Offset = 0;
+ int arg2Offset = 0;
+ int length;
+ if (arg1.length > arg2.length) {
+ int diff = arg1.length - arg2.length;
+ for (; arg1Offset < diff; arg1Offset++) {
+ if (arg1[arg1Offset] != 0) {
+ return 1;
+ }
+ }
+ length = arg2.length;
+ } else if (arg1.length < arg2.length) {
+ int diff = arg2.length - arg1.length;
+ for (; arg2Offset < diff; arg2Offset++) {
+ if (arg2[arg2Offset] != 0) {
+ return -1;
+ }
+ }
+ length = arg1.length;
+ } else {
+ length = arg1.length;
+ }
+
+ for (int i = 0; i < length; i++) {
+ int b1 = arg1[arg1Offset + i] & 0xFF;
+ int b2 = arg2[arg2Offset + i] & 0xFF;
+ if (b1 > b2) {
+ return 1;
+ } else if (b1 < b2) {
+ return -1;
+ }
+ }
+ return 0;
+ }
+
+ // Used only by computeBigDecimalPrecision()
+ // byte array of 1, 10, 100, 1000, 10000, ..., 10^31 for
+ // fast computing the length a BigDecimal.
+ private static byte[][] tenRadixArr = {
+ {(byte) 0x01}, // 10^0
+ {(byte) 0x0A}, // 10^1
+ {(byte) 0x64}, // 10^2
+ {(byte) 0x03, (byte) 0xe8}, // 10^3
+ {(byte) 0x27, (byte) 0x10}, // 10^4
+ {(byte) 0x01, (byte) 0x86, (byte) 0xa0}, // 10^5
+ {(byte) 0x0f, (byte) 0x42, (byte) 0x40}, // 10^6
+ {(byte) 0x98, (byte) 0x96, (byte) 0x80}, // 10^7
+ {(byte) 0x05, (byte) 0xf5, (byte) 0xe1, (byte) 0x00}, // 10^8
+ {(byte) 0x3b, (byte) 0x9a, (byte) 0xca, (byte) 0x00}, // 10^9
+ {(byte) 0x02, (byte) 0x54, (byte) 0x0b, (byte) 0xe4, (byte) 0x00}, // 10^10
+ {(byte) 0x17, (byte) 0x48, (byte) 0x76, (byte) 0xe8, (byte) 0x00}, // 10^11
+ {(byte) 0xe8, (byte) 0xd4, (byte) 0xa5, (byte) 0x10, (byte) 0x00}, // 10^12
+ {(byte) 0x09, (byte) 0x18, (byte) 0x4e, (byte) 0x72, (byte) 0xa0, (byte) 0x00}, // 10^13
+ {(byte) 0x5a, (byte) 0xf3, (byte) 0x10, (byte) 0x7a, (byte) 0x40, (byte) 0x00}, // 10^14
+ {(byte) 0x03, (byte) 0x8d, (byte) 0x7e, (byte) 0xa4, (byte) 0xc6, (byte) 0x80, (byte) 0x00}, // 10^15
+ {(byte) 0x23, (byte) 0x86, (byte) 0xf2, (byte) 0x6f, (byte) 0xc1, (byte) 0x00, (byte) 0x00}, // 10^16
+ {(byte) 0x01, (byte) 0x63, (byte) 0x45, (byte) 0x78, (byte) 0x5d, (byte) 0x8a, (byte) 0x00, (byte) 0x00}, // 10^17
+ {(byte) 0x0d, (byte) 0xe0, (byte) 0xb6, (byte) 0xb3, (byte) 0xa7, (byte) 0x64, (byte) 0x00, (byte) 0x00}, // 10^18
+ {(byte) 0x8a, (byte) 0xc7, (byte) 0x23, (byte) 0x04, (byte) 0x89, (byte) 0xe8, (byte) 0x00, (byte) 0x00}, // 10^19
+ {(byte) 0x05, (byte) 0x6b, (byte) 0xc7, (byte) 0x5e, (byte) 0x2d, (byte) 0x63, (byte) 0x10, (byte) 0x00, (byte) 0x00}, // 10^20
+ {(byte) 0x36, (byte) 0x35, (byte) 0xc9, (byte) 0xad, (byte) 0xc5, (byte) 0xde, (byte) 0xa0, (byte) 0x00, (byte) 0x00}, // 10^21
+ {(byte) 0x02, (byte) 0x1e, (byte) 0x19, (byte) 0xe0, (byte) 0xc9, (byte) 0xba, (byte) 0xb2, (byte) 0x40, (byte) 0x00, (byte) 0x00}, // 10^22
+ {(byte) 0x15, (byte) 0x2d, (byte) 0x02, (byte) 0xc7, (byte) 0xe1, (byte) 0x4a, (byte) 0xf6, (byte) 0x80, (byte) 0x00, (byte) 0x00}, // 10^23
+ {(byte) 0xd3, (byte) 0xc2, (byte) 0x1b, (byte) 0xce, (byte) 0xcc, (byte) 0xed, (byte) 0xa1, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^24
+ {(byte) 0x08, (byte) 0x45, (byte) 0x95, (byte) 0x16, (byte) 0x14, (byte) 0x01, (byte) 0x48, (byte) 0x4a, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^25
+ {(byte) 0x52, (byte) 0xb7, (byte) 0xd2, (byte) 0xdc, (byte) 0xc8, (byte) 0x0c, (byte) 0xd2, (byte) 0xe4, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^26
+ {(byte) 0x03, (byte) 0x3b, (byte) 0x2e, (byte) 0x3c, (byte) 0x9f, (byte) 0xd0, (byte) 0x80, (byte) 0x3c, (byte) 0xe8, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^27
+ {(byte) 0x20, (byte) 0x4f, (byte) 0xce, (byte) 0x5e, (byte) 0x3e, (byte) 0x25, (byte) 0x02, (byte) 0x61, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^28
+ {(byte) 0x01, (byte) 0x43, (byte) 0x1e, (byte) 0x0f, (byte) 0xae, (byte) 0x6d, (byte) 0x72, (byte) 0x17, (byte) 0xca, (byte) 0xa0, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^29
+ {(byte) 0x0c, (byte) 0x9f, (byte) 0x2c, (byte) 0x9c, (byte) 0xd0, (byte) 0x46, (byte) 0x74, (byte) 0xed, (byte) 0xea, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^30
+ {(byte) 0x7e, (byte) 0x37, (byte) 0xbe, (byte) 0x20, (byte) 0x22, (byte) 0xc0, (byte) 0x91, (byte) 0x4b, (byte) 0x26, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00} // 10^31
+ };
+
+ // If the input string is short, pad it with blanks.
+ // If the input string is long, truncate it.
+ static public String padOrTruncate(String s, int fixedLength) {
+ if (s.length() >= fixedLength) // we need to truncate
+ {
+ return s.substring(0, fixedLength);
+ } else { // we need to pad
+ StringBuffer buffer = new StringBuffer(s);
+ for (int i = 0; i < fixedLength - s.length(); i++) {
+ buffer.append(" ");
+ }
+ return buffer.toString();
+ }
+ }
+
+ static public void checkForNegativePositiveSqlcard(Sqlca sqlca, Statement statement) throws SqlException {
+ if (sqlca != null) {
+ int sqlcode = sqlca.getSqlCode();
+ if (sqlcode < 0) {
+ throw new SqlException(statement.agent_.logWriter_, sqlca);
+ } else {
+ if (sqlcode > 0) {
+ statement.accumulateWarning(new SqlWarning(statement.agent_.logWriter_, sqlca));
+ }
+ }
+ }
+ }
+
+ static public void checkForNegativePositiveSqlcard(Sqlca sqlca, ResultSet resultSet) throws SqlException {
+ if (sqlca != null) {
+ int sqlcode = sqlca.getSqlCode();
+ if (sqlcode < 0) {
+ throw new SqlException(resultSet.agent_.logWriter_, sqlca);
+ } else {
+ if (sqlcode > 0) {
+ resultSet.accumulateWarning(new SqlWarning(resultSet.agent_.logWriter_, sqlca));
+ }
+ }
+ }
+ }
+
+ static public int getSqlcodeFromSqlca(Sqlca sqlca) {
+ if (sqlca == null) {
+ return 0;
+ }
+ return sqlca.getSqlCode();
+ }
+
+ static public int getUpdateCountFromSqlcard(Sqlca sqlca) {
+ if (sqlca == null) {
+ return 0;
+ } else {
+ return sqlca.getUpdateCount();
+ }
+ }
+
+ public static int min(int i, int j) {
+ return (i < j) ? i : j;
+ }
+
+ public static int max(int i, int j) {
+ return (i < j) ? j : i;
+ }
+
+ // latestException is assumed to be non-null, accumulatedExceptions can be null
+ public static SqlException accumulateSQLException(SqlException latestException,
+ SqlException accumulatedExceptions) {
+ if (accumulatedExceptions == null) {
+ return latestException;
+ } else {
+ accumulatedExceptions.setNextException(latestException);
+ return accumulatedExceptions;
+ }
+ }
+
+ // latestException is assumed to be non-null, accumulatedExceptions can be null
+ public static SqlWarning accumulateSQLWarning(SqlWarning latestException,
+ SqlWarning accumulatedExceptions) {
+ latestException.setNextException(accumulatedExceptions);
+ return latestException;
+ }
+
+ // just a thought...
+ static String getSQLTypeName(int sqlType) {
+ switch (sqlType) {
+ case java.sql.Types.BIGINT:
+ return "BIGINT";
+ case java.sql.Types.BINARY:
+ return "BINARY";
+ case java.sql.Types.BIT:
+ return "BIT";
+ case java.sql.Types.CHAR:
+ return "CHAR";
+ case java.sql.Types.DATE:
+ return "DATE";
+ case java.sql.Types.DECIMAL:
+ return "DECIMAL";
+ case java.sql.Types.DOUBLE:
+ return "DOUBLE";
+ case java.sql.Types.REAL:
+ return "REAL";
+ case java.sql.Types.INTEGER:
+ return "INTEGER";
+ case java.sql.Types.LONGVARBINARY:
+ return "LONGVARBINARY";
+ case java.sql.Types.LONGVARCHAR:
+ return "LONGVARCHAR";
+ case java.sql.Types.NULL:
+ return "NULL";
+ case java.sql.Types.NUMERIC:
+ return "NUMERIC";
+ case java.sql.Types.OTHER:
+ return "OTHER";
+ case java.sql.Types.FLOAT:
+ return "FLOAT";
+ case java.sql.Types.SMALLINT:
+ return "SMALLINT";
+ case java.sql.Types.TIME:
+ return "TIME";
+ case java.sql.Types.TIMESTAMP:
+ return "TIMESTAMP";
+ case java.sql.Types.TINYINT:
+ return "TINYINT";
+ case java.sql.Types.VARBINARY:
+ return "VARBINARY";
+ case java.sql.Types.VARCHAR:
+ return "VARCHAR";
+ default:
+ return null;
+ }
+ }
+
+ public static boolean isSqlTypeNullable(int sqlType) {
+ return (sqlType | 0x01) == sqlType;
+ }
+
+ public static int getNonNullableSqlType(int sqlType) {
+ return sqlType & ~1;
+ }
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java Sun May 1 23:25:59 2005
@@ -19,160 +19,151 @@
*/
package org.apache.derby.client.am;
-import org.apache.derby.iapi.services.info.ProductVersionHolder;
-public abstract class Version
-{
- // Same as java.sql.DatabaseMetaData.getDriverName()
- public static String getDriverName ()
- { return Configuration.dncDriverName; }
-
- // for DatabaseMetaData.getDriverVersion()
- public static String getDriverVersion()
- {
- return Configuration.dncProductVersionHolder__.getVersionBuildString(false);
- }
-
-
- // Same as java.sql.Driver.getMajorVersion(), getMinorVersion()
- public static int getMajorVersion()
- {
- return Configuration.getProductVersionHolder().getMajorVersion();
- }
-
- public static int getMinorVersion()
- {
- return Configuration.getProductVersionHolder().getMinorVersion();
- }
-
- public static int getBuildNumber()
- {
- return Configuration.getProductVersionHolder().getBuildNumberAsInt();
- }
-
- public static int getProtocolMaintVersion()
- {
- return Configuration.getProductVersionHolder().getDrdaMaintVersion();
- }
-
- public static boolean isAlpha()
- {
- return Configuration.getProductVersionHolder().isAlpha();
- }
-
- public static boolean isBeta()
- {
- return Configuration.getProductVersionHolder().isBeta();
- }
-
- // Not an external, just a helper method
- private static String getDriverNameAndVersion ()
- {
- return Configuration.dncDriverName + " " +
- Configuration.dncProductVersionHolder__.getVersionBuildString(true);
- }
-
- // -------------------------- configuration print stream ---------------------
-
- public static void writeDriverConfiguration (java.io.PrintWriter printWriter)
- {
- String header = "[derby] ";
- synchronized (printWriter) {
- printWriter.println (header + "BEGIN TRACE_DRIVER_CONFIGURATION");
- printWriter.println (header + "Driver: " + getDriverNameAndVersion ());
-
- printWriter.print (header + "Compatible JRE versions: { ");
- for (int i=0; i < Configuration.dncCompatibleJREVersions.length; i++) {
- printWriter.print (Configuration.dncCompatibleJREVersions[i]);
- if (i != Configuration.dncCompatibleJREVersions.length - 1)
- printWriter.print (", ");
- }
- printWriter.println (" }");
-
- printWriter.println (header + "Range checking enabled: " + Configuration.rangeCheckCrossConverters);
- printWriter.println (header + "Bug check level: 0x" + Integer.toHexString (Configuration.bugCheckLevel));
- printWriter.println (header + "Default fetch size: " + Configuration.defaultFetchSize);
- printWriter.println (header + "Default isolation: " + Configuration.defaultIsolation);
-
- java.lang.SecurityManager security = java.lang.System.getSecurityManager ();
- if (security == null)
- printWriter.println (header + "No security manager detected.");
- else
- printWriter.println (header + "Security manager detected.");
-
- detectLocalHost (java.lang.System.getSecurityManager (), printWriter);
-
- printSystemProperty (security, "JDBC 1 system property jdbc.drivers = ", "jdbc.drivers", printWriter);
-
- printSystemProperty (security, "Java Runtime Environment version ", "java.version", printWriter);
- printSystemProperty (security, "Java Runtime Environment vendor = ", "java.vendor", printWriter);
- printSystemProperty (security, "Java vendor URL = ", "java.vendor.url", printWriter);
- printSystemProperty (security, "Java installation directory = ", "java.home", printWriter);
- printSystemProperty (security, "Java Virtual Machine specification version = ", "java.vm.specification.version", printWriter);
- printSystemProperty (security, "Java Virtual Machine specification vendor = ", "java.vm.specification.vendor", printWriter);
- printSystemProperty (security, "Java Virtual Machine specification name = ", "java.vm.specification.name", printWriter);
- printSystemProperty (security, "Java Virtual Machine implementation version = ", "java.vm.version", printWriter);
- printSystemProperty (security, "Java Virtual Machine implementation vendor = ", "java.vm.vendor", printWriter);
- printSystemProperty (security, "Java Virtual Machine implementation name = ", "java.vm.name", printWriter);
- printSystemProperty (security, "Java Runtime Environment specification version = ", "java.specification.version", printWriter);
- printSystemProperty (security, "Java Runtime Environment specification vendor = ", "java.specification.vendor", printWriter);
- printSystemProperty (security, "Java Runtime Environment specification name = ", "java.specification.name", printWriter);
- printSystemProperty (security, "Java class format version number = ", "java.class.version", printWriter);
- printSystemProperty (security, "Java class path = ", "java.class.path", printWriter);
- printSystemProperty (security, "Java native library path = ", "java.library.path", printWriter);
- printSystemProperty (security, "Path of extension directory or directories = ", "java.ext.dirs", printWriter);
- printSystemProperty (security, "Operating system name = ", "os.name", printWriter);
- printSystemProperty (security, "Operating system architecture = ", "os.arch", printWriter);
- printSystemProperty (security, "Operating system version = ", "os.version", printWriter);
- printSystemProperty (security, "File separator (\"/\" on UNIX) = ", "file.separator", printWriter);
- printSystemProperty (security, "Path separator (\":\" on UNIX) = ", "path.separator", printWriter);
- printSystemProperty (security, "User's account name = ", "user.name", printWriter);
- printSystemProperty (security, "User's home directory = ", "user.home", printWriter);
- printSystemProperty (security, "User's current working directory = ", "user.dir", printWriter);
- printWriter.println (header + "END TRACE_DRIVER_CONFIGURATION");
- printWriter.flush();
- }
- }
-
- private static void printSystemProperty (java.lang.SecurityManager security,
- String prefix,
- String property,
- java.io.PrintWriter printWriter)
- {
- String header = "[derby] ";
- synchronized (printWriter) {
- try {
- if (security != null)
- security.checkPropertyAccess (property);
- String result = System.getProperty (property);
- printWriter.println (header + prefix + result);
- printWriter.flush();
- }
- catch (SecurityException e) {
- printWriter.println (header + "Security manager does not permit access to system property " + property);
- printWriter.flush();
- }
- }
- }
-
- // printWriter synchronized by caller
- private static void detectLocalHost (java.lang.SecurityManager security, java.io.PrintWriter printWriter)
- {
- String header = "[derby] ";
- // getLocalHost() will hang the HotJava 1.0 browser with a high security manager.
- if (security == null) {
- try {
- printWriter.print (header + "Detected local client host: ");
- printWriter.println (java.net.InetAddress.getLocalHost().toString ());
- printWriter.flush();
- }
- catch (java.net.UnknownHostException e) {
- printWriter.print (header + "Detected an improper TCP/IP client configuration.");
- printWriter.print (header + "Unable to determine the IP address of your local host: ");
- printWriter.print (e.getMessage ());
- printWriter.println (header + "Make sure your client machine has a properly configured IP address.");
- printWriter.flush();
- }
+
+
+public abstract class Version {
+ // Same as java.sql.DatabaseMetaData.getDriverName()
+ public static String getDriverName() {
+ return Configuration.dncDriverName;
+ }
+
+ // for DatabaseMetaData.getDriverVersion()
+ public static String getDriverVersion() {
+ return Configuration.dncProductVersionHolder__.getVersionBuildString(false);
+ }
+
+
+ // Same as java.sql.Driver.getMajorVersion(), getMinorVersion()
+ public static int getMajorVersion() {
+ return Configuration.getProductVersionHolder().getMajorVersion();
+ }
+
+ public static int getMinorVersion() {
+ return Configuration.getProductVersionHolder().getMinorVersion();
+ }
+
+ public static int getBuildNumber() {
+ return Configuration.getProductVersionHolder().getBuildNumberAsInt();
+ }
+
+ public static int getProtocolMaintVersion() {
+ return Configuration.getProductVersionHolder().getDrdaMaintVersion();
+ }
+
+ public static boolean isAlpha() {
+ return Configuration.getProductVersionHolder().isAlpha();
+ }
+
+ public static boolean isBeta() {
+ return Configuration.getProductVersionHolder().isBeta();
+ }
+
+ // Not an external, just a helper method
+ private static String getDriverNameAndVersion() {
+ return Configuration.dncDriverName + " " +
+ Configuration.dncProductVersionHolder__.getVersionBuildString(true);
+ }
+
+ // -------------------------- configuration print stream ---------------------
+
+ public static void writeDriverConfiguration(java.io.PrintWriter printWriter) {
+ String header = "[derby] ";
+ synchronized (printWriter) {
+ printWriter.println(header + "BEGIN TRACE_DRIVER_CONFIGURATION");
+ printWriter.println(header + "Driver: " + getDriverNameAndVersion());
+
+ printWriter.print(header + "Compatible JRE versions: { ");
+ for (int i = 0; i < Configuration.dncCompatibleJREVersions.length; i++) {
+ printWriter.print(Configuration.dncCompatibleJREVersions[i]);
+ if (i != Configuration.dncCompatibleJREVersions.length - 1) {
+ printWriter.print(", ");
+ }
+ }
+ printWriter.println(" }");
+
+ printWriter.println(header + "Range checking enabled: " + Configuration.rangeCheckCrossConverters);
+ printWriter.println(header + "Bug check level: 0x" + Integer.toHexString(Configuration.bugCheckLevel));
+ printWriter.println(header + "Default fetch size: " + Configuration.defaultFetchSize);
+ printWriter.println(header + "Default isolation: " + Configuration.defaultIsolation);
+
+ java.lang.SecurityManager security = java.lang.System.getSecurityManager();
+ if (security == null) {
+ printWriter.println(header + "No security manager detected.");
+ } else {
+ printWriter.println(header + "Security manager detected.");
+ }
+
+ detectLocalHost(java.lang.System.getSecurityManager(), printWriter);
+
+ printSystemProperty(security, "JDBC 1 system property jdbc.drivers = ", "jdbc.drivers", printWriter);
+
+ printSystemProperty(security, "Java Runtime Environment version ", "java.version", printWriter);
+ printSystemProperty(security, "Java Runtime Environment vendor = ", "java.vendor", printWriter);
+ printSystemProperty(security, "Java vendor URL = ", "java.vendor.url", printWriter);
+ printSystemProperty(security, "Java installation directory = ", "java.home", printWriter);
+ printSystemProperty(security, "Java Virtual Machine specification version = ", "java.vm.specification.version", printWriter);
+ printSystemProperty(security, "Java Virtual Machine specification vendor = ", "java.vm.specification.vendor", printWriter);
+ printSystemProperty(security, "Java Virtual Machine specification name = ", "java.vm.specification.name", printWriter);
+ printSystemProperty(security, "Java Virtual Machine implementation version = ", "java.vm.version", printWriter);
+ printSystemProperty(security, "Java Virtual Machine implementation vendor = ", "java.vm.vendor", printWriter);
+ printSystemProperty(security, "Java Virtual Machine implementation name = ", "java.vm.name", printWriter);
+ printSystemProperty(security, "Java Runtime Environment specification version = ", "java.specification.version", printWriter);
+ printSystemProperty(security, "Java Runtime Environment specification vendor = ", "java.specification.vendor", printWriter);
+ printSystemProperty(security, "Java Runtime Environment specification name = ", "java.specification.name", printWriter);
+ printSystemProperty(security, "Java class format version number = ", "java.class.version", printWriter);
+ printSystemProperty(security, "Java class path = ", "java.class.path", printWriter);
+ printSystemProperty(security, "Java native library path = ", "java.library.path", printWriter);
+ printSystemProperty(security, "Path of extension directory or directories = ", "java.ext.dirs", printWriter);
+ printSystemProperty(security, "Operating system name = ", "os.name", printWriter);
+ printSystemProperty(security, "Operating system architecture = ", "os.arch", printWriter);
+ printSystemProperty(security, "Operating system version = ", "os.version", printWriter);
+ printSystemProperty(security, "File separator (\"/\" on UNIX) = ", "file.separator", printWriter);
+ printSystemProperty(security, "Path separator (\":\" on UNIX) = ", "path.separator", printWriter);
+ printSystemProperty(security, "User's account name = ", "user.name", printWriter);
+ printSystemProperty(security, "User's home directory = ", "user.home", printWriter);
+ printSystemProperty(security, "User's current working directory = ", "user.dir", printWriter);
+ printWriter.println(header + "END TRACE_DRIVER_CONFIGURATION");
+ printWriter.flush();
+ }
+ }
+
+ private static void printSystemProperty(java.lang.SecurityManager security,
+ String prefix,
+ String property,
+ java.io.PrintWriter printWriter) {
+ String header = "[derby] ";
+ synchronized (printWriter) {
+ try {
+ if (security != null) {
+ security.checkPropertyAccess(property);
+ }
+ String result = System.getProperty(property);
+ printWriter.println(header + prefix + result);
+ printWriter.flush();
+ } catch (SecurityException e) {
+ printWriter.println(header + "Security manager does not permit access to system property " + property);
+ printWriter.flush();
+ }
+ }
+ }
+
+ // printWriter synchronized by caller
+ private static void detectLocalHost(java.lang.SecurityManager security, java.io.PrintWriter printWriter) {
+ String header = "[derby] ";
+ // getLocalHost() will hang the HotJava 1.0 browser with a high security manager.
+ if (security == null) {
+ try {
+ printWriter.print(header + "Detected local client host: ");
+ printWriter.println(java.net.InetAddress.getLocalHost().toString());
+ printWriter.flush();
+ } catch (java.net.UnknownHostException e) {
+ printWriter.print(header + "Detected an improper TCP/IP client configuration.");
+ printWriter.print(header + "Unable to determine the IP address of your local host: ");
+ printWriter.print(e.getMessage());
+ printWriter.println(header + "Make sure your client machine has a properly configured IP address.");
+ printWriter.flush();
+ }
+ }
}
- }
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am/XaException.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/am/XaException.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/XaException.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/XaException.java Sun May 1 23:25:59 2005
@@ -21,95 +21,93 @@
package org.apache.derby.client.am;
-public class XaException extends javax.transaction.xa.XAException implements Diagnosable
-{
- java.lang.Throwable throwable_ = null;
-
- //-----------------constructors-----------------------------------------------
-
- public XaException (LogWriter logWriter)
- {
- super ();
- if (logWriter != null) logWriter.traceDiagnosable (this);
- }
-
- public XaException (LogWriter logWriter, java.lang.Throwable throwable)
- {
- super ();
- throwable_ = throwable;
- if( ((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
- (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
- (org.apache.derby.client.am.Configuration.jreLevelMajor > 1) )
- { // jre 1.4 or above, init the cause
- initCause( throwable );
- }
- if (logWriter != null) logWriter.traceDiagnosable (this);
- }
-
- public XaException (LogWriter logWriter, int errcode)
- {
- super ();
- errorCode = errcode;
- if (logWriter != null) logWriter.traceDiagnosable (this);
- }
-
- public XaException (LogWriter logWriter, java.lang.Throwable throwable, int errcode)
- {
- super ();
- errorCode = errcode;
- throwable_ = throwable;
- if( ((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
- (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
- (org.apache.derby.client.am.Configuration.jreLevelMajor > 1) )
- { // jre 1.4 or above, init the cause
- initCause( throwable );
- }
- if (logWriter != null) logWriter.traceDiagnosable (this);
- }
-
- public XaException (LogWriter logWriter, String s)
- {
- super (s);
- if (logWriter != null) logWriter.traceDiagnosable (this);
- }
-
- public XaException (LogWriter logWriter, java.lang.Throwable throwable, String s)
- {
- super (s);
- throwable_ = throwable;
- if( ((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
- (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
- (org.apache.derby.client.am.Configuration.jreLevelMajor > 1) )
- { // jre 1.4 or above, init the cause
- initCause( throwable );
- }
- if (logWriter != null) logWriter.traceDiagnosable (this);
- }
-
- public Sqlca getSqlca ()
- {
- return null;
- }
-
- public java.lang.Throwable getThrowable ()
- {
- return throwable_;
- }
-
- public void printTrace (java.io.PrintWriter printWriter, String header)
- {
- ExceptionFormatter.printTrace (this, printWriter, header);
- }
-
- // Return a single XaException without the "next" pointing to another SQLException.
- // Because the "next" is a private field in java.sql.SQLException,
- // we have to create a new XaException in order to break the chain with "next" as null.
- XaException copyAsUnchainedXAException (LogWriter logWriter)
- {
- XaException xae = new XaException (logWriter, this.getThrowable(), getMessage()); // client error
- xae.errorCode = this.errorCode;
- return xae;
- }
+public class XaException extends javax.transaction.xa.XAException implements Diagnosable {
+ java.lang.Throwable throwable_ = null;
+
+ //-----------------constructors-----------------------------------------------
+
+ public XaException(LogWriter logWriter) {
+ super();
+ if (logWriter != null) {
+ logWriter.traceDiagnosable(this);
+ }
+ }
+
+ public XaException(LogWriter logWriter, java.lang.Throwable throwable) {
+ super();
+ throwable_ = throwable;
+ if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
+ (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
+ (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
+ initCause(throwable);
+ }
+ if (logWriter != null) {
+ logWriter.traceDiagnosable(this);
+ }
+ }
+
+ public XaException(LogWriter logWriter, int errcode) {
+ super();
+ errorCode = errcode;
+ if (logWriter != null) {
+ logWriter.traceDiagnosable(this);
+ }
+ }
+
+ public XaException(LogWriter logWriter, java.lang.Throwable throwable, int errcode) {
+ super();
+ errorCode = errcode;
+ throwable_ = throwable;
+ if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
+ (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
+ (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
+ initCause(throwable);
+ }
+ if (logWriter != null) {
+ logWriter.traceDiagnosable(this);
+ }
+ }
+
+ public XaException(LogWriter logWriter, String s) {
+ super(s);
+ if (logWriter != null) {
+ logWriter.traceDiagnosable(this);
+ }
+ }
+
+ public XaException(LogWriter logWriter, java.lang.Throwable throwable, String s) {
+ super(s);
+ throwable_ = throwable;
+ if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
+ (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
+ (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
+ initCause(throwable);
+ }
+ if (logWriter != null) {
+ logWriter.traceDiagnosable(this);
+ }
+ }
+
+ public Sqlca getSqlca() {
+ return null;
+ }
+
+ public java.lang.Throwable getThrowable() {
+ return throwable_;
+ }
+
+ public void printTrace(java.io.PrintWriter printWriter, String header) {
+ ExceptionFormatter.printTrace(this, printWriter, header);
+ }
+
+ // Return a single XaException without the "next" pointing to another SQLException.
+ // Because the "next" is a private field in java.sql.SQLException,
+ // we have to create a new XaException in order to break the chain with "next" as null.
+ XaException copyAsUnchainedXAException(LogWriter logWriter) {
+ XaException xae = new XaException(logWriter, this.getThrowable(), getMessage()); // client error
+ xae.errorCode = this.errorCode;
+ return xae;
+ }
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java Sun May 1 23:25:59 2005
@@ -22,72 +22,71 @@
// Performs character conversions as required to send and receive PROTOCOL control data.
// User data uses the JVM's built in converters, i18n.jar,
-public abstract class CcsidManager
-{
- public 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_;
-
- // Special byte array to convert first half byte of CRRTKNs TCPIP address and port number
- // to a character. This is required for SNA hopping.
- // This was specifically added to help build the CRRTKNs.
- byte[] numToSnaRequiredCrrtknChar_;
-
- CcsidManager (byte space,
- byte dot,
- byte[] numToCharRepresentation,
- byte[] numToSnaRequiredCrrtknChar)
- {
- space_ = space;
- dot_ = dot;
- numToCharRepresentation_ = numToCharRepresentation;
- numToSnaRequiredCrrtknChar_ = numToSnaRequiredCrrtknChar;
- }
-
-
- // 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.
- public abstract byte[] convertFromUCS2 (String sourceString, org.apache.derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlException;
-
-
- // 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.
- public abstract int convertFromUCS2 (String sourceString,
- byte[] buffer,
- int offset,
- org.apache.derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlException;
-
- // 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);
-
-
- // Convert a byte representing a char in a particular ccsid into a Java char.
- //
- // @param sourceByte The byte to be converted
- // @return The converted Java char.
- abstract char convertToUCS2Char (byte sourceByte);
+
+public abstract class CcsidManager {
+ public 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_;
+
+ // Special byte array to convert first half byte of CRRTKNs TCPIP address and port number
+ // to a character. This is required for SNA hopping.
+ // This was specifically added to help build the CRRTKNs.
+ byte[] numToSnaRequiredCrrtknChar_;
+
+ CcsidManager(byte space,
+ byte dot,
+ byte[] numToCharRepresentation,
+ byte[] numToSnaRequiredCrrtknChar) {
+ space_ = space;
+ dot_ = dot;
+ numToCharRepresentation_ = numToCharRepresentation;
+ numToSnaRequiredCrrtknChar_ = numToSnaRequiredCrrtknChar;
+ }
+
+
+ // 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.
+ public abstract byte[] convertFromUCS2(String sourceString, org.apache.derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlException;
+
+
+ // 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.
+ public abstract int convertFromUCS2(String sourceString,
+ byte[] buffer,
+ int offset,
+ org.apache.derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlException;
+
+ // 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);
+
+
+ // Convert a byte representing a char in a particular ccsid into a Java char.
+ //
+ // @param sourceByte The byte to be converted
+ // @return The converted Java char.
+ abstract char convertToUCS2Char(byte sourceByte);
}