void ReadAll()
 {
     if (_clob != null)
     {
         long length = _clob.length();
         if (length == 0)
         {
             _s = String.Empty;
         }
         else
         {
             java.io.Reader reader    = _clob.getCharacterStream();
             char[]         charValue = new char[length];
             reader.read(charValue);
             if (charValue != null)
             {
                 _s = new String(charValue);
             }
         }
     }
 }
Ejemplo n.º 2
0
        internal static object JavaResultSetToClrWrapper(CallableStatement results, int columnIndex, JavaSqlTypes javaSqlType, int maxLength, ResultSetMetaData resultsMetaData)
        {
            object returnValue = null;

            sbyte[] sbyteArray;
            long    milliseconds;
            long    ticks;
            string  s;

            columnIndex++;             //jdbc style
            switch (javaSqlType)
            {
            case JavaSqlTypes.ARRAY:
                returnValue = results.getArray(columnIndex);
                break;

            case JavaSqlTypes.BIGINT:
                returnValue = results.getLong(columnIndex);
                break;

            case JavaSqlTypes.BINARY:
            case JavaSqlTypes.VARBINARY:
            case JavaSqlTypes.LONGVARBINARY:
                // FIXME : comsider using maxLength
                sbyteArray = results.getBytes(columnIndex);
                if (sbyteArray != null)
                {
                    returnValue = vmw.common.TypeUtils.ToByteArray(sbyteArray);
                }
                break;

            case JavaSqlTypes.BIT:
                returnValue = results.getBoolean(columnIndex);
                break;

            case JavaSqlTypes.BLOB:
                // FIXME : comsider using maxLength
                java.sql.Blob blob = results.getBlob(columnIndex);
                if (blob != null)
                {
                    InputStream input = blob.getBinaryStream();
                    if (input == null)
                    {
                        returnValue = new byte[0];
                    }
                    else
                    {
                        long    length     = blob.length();
                        byte[]  byteValue  = new byte[length];
                        sbyte[] sbyteValue = vmw.common.TypeUtils.ToSByteArray(byteValue);
                        input.read(sbyteValue);
                        returnValue = byteValue;
                    }
                }
                break;

            case JavaSqlTypes.CHAR:
                if (resultsMetaData != null && "uniqueidentifier".Equals(resultsMetaData.getColumnTypeName(columnIndex)))
                {
                    returnValue = new Guid(results.getString(columnIndex));
                }
                else
                {
                    // Oracle Jdbc driver returns extra trailing 0 chars for NCHAR columns, so we threat this at parameter.Size level
                    s = results.getString(columnIndex);
                    if ((s != null) && (maxLength < s.Length))
                    {
                        s = s.Substring(0, maxLength);
                    }
                    returnValue = s;
                }
                break;

            case JavaSqlTypes.CLOB:
                // FIXME : comsider using maxLength
                java.sql.Clob clob = results.getClob(columnIndex);
                if (clob != null)
                {
                    java.io.Reader reader = clob.getCharacterStream();
                    if (reader == null)
                    {
                        returnValue = String.Empty;
                    }
                    else
                    {
                        long   length    = clob.length();
                        char[] charValue = new char[length];
                        reader.read(charValue);
                        returnValue = new string(charValue);
                    }
                }
                break;

            case JavaSqlTypes.TIME:
                Time t = results.getTime(columnIndex);
                if (t != null)
                {
                    returnValue = new TimeSpan(JavaTimeToClrTicks(t));
                }
                break;

            case JavaSqlTypes.DATE:
                Date d = results.getDate(columnIndex);
                if (d != null)
                {
                    returnValue = new DateTime(JavaDateToClrTicks(d));
                }
                break;

            case JavaSqlTypes.TIMESTAMP:
                Timestamp ts = results.getTimestamp(columnIndex);
                if (ts != null)
                {
                    returnValue = new DateTime(JavaTimestampToClrTicks(ts));
                }
                break;

            case JavaSqlTypes.DECIMAL:
            case JavaSqlTypes.NUMERIC:
                // java.sql.Types.NUMERIC (2), columnTypeName NUMBER, columnClassName java.math.BigDecimal
                // therefore we rely on scale
                if (resultsMetaData != null && resultsMetaData.getScale(columnIndex) == -127)
                {
                    // Oracle db type FLOAT
                    returnValue = results.getDouble(columnIndex);
                }
                else
                {
                    java.math.BigDecimal bigDecimal = results.getBigDecimal(columnIndex);
                    if (bigDecimal != null)
                    {
                        returnValue = vmw.common.PrimitiveTypeUtils.BigDecimalToDecimal(bigDecimal);
                    }
                }
                break;

            case JavaSqlTypes.DISTINCT:
                returnValue = results.getObject(columnIndex);
                break;

            case JavaSqlTypes.DOUBLE:
                returnValue = results.getDouble(columnIndex);
                break;

            case JavaSqlTypes.FLOAT:
                //float f = results.getFloat(columnIndex);
                returnValue = results.getDouble(columnIndex);
                break;

            case JavaSqlTypes.INTEGER:
                returnValue = results.getInt(columnIndex);
                break;

            case JavaSqlTypes.JAVA_OBJECT:
                returnValue = results.getObject(columnIndex);
                break;

            case JavaSqlTypes.LONGVARCHAR:
                returnValue = results.getString(columnIndex);
                break;

            case JavaSqlTypes.NULL:
                returnValue = DBNull.Value;
                break;

            case JavaSqlTypes.OTHER:
                returnValue = results.getObject(columnIndex);
                break;

            case JavaSqlTypes.REAL:
                returnValue = results.getFloat(columnIndex);
                break;

            case JavaSqlTypes.REF:
                returnValue = results.getRef(columnIndex);
                break;

            case JavaSqlTypes.SMALLINT:
                returnValue = results.getShort(columnIndex);
                break;

            case JavaSqlTypes.STRUCT:
                returnValue = results.getObject(columnIndex);
                break;

            case JavaSqlTypes.TINYINT:
                returnValue = Convert.ToByte(results.getByte(columnIndex));
                break;

            case JavaSqlTypes.VARCHAR:
                s = results.getString(columnIndex);
                if ((s != null) && (maxLength < s.Length))
                {
                    s = s.Substring(0, maxLength);
                }
                returnValue = s;
                break;

            default:
                returnValue = results.getObject(columnIndex);
                break;
            }

            if (results.wasNull() || results == null)
            {
                return(DBNull.Value);
            }
            return(returnValue);
        }