Пример #1
0
        }          // getString

        /*
        ** Name: getISR
        **
        ** Description:
        **	Returns an InputStreamReader for input from provided stream
        **	and conversion using the associated encoding .
        **
        ** Input:
        **	stream		    InputStream to be converted.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	InputStreamReader   Reader for encoding conversion of stream.
        **
        ** History:
        **	 6-Sep-02 (gordy)
        **	    Created.
        **	11-Nov-02 (thoda04)
        **	    Ported to .NET Provider.
        */

        public virtual InputStreamReader getISR(InputStream stream)
        {
            InputStreamReader isr;

            if (encoding == null)
            {
                isr = new InputStreamReader(stream);
            }
            else
            {
                isr = new InputStreamReader(stream, encoding);
            }

            return(isr);
        }          // getISR
Пример #2
0
        /*
        ** Name: setAsciiStream
        **
        ** Description:
        **	Set parameter to an ASCII character stream.
        **
        ** Input:
        **	paramIndex	Parameter index.
        **	stream		ASCII stream.
        **	length		Length of stream in bytes.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	void.
        **
        ** History:
        **	19-May-99 (gordy)
        **	    Created.
        **	 2-Feb-00 (gordy)
        **	    Send short streams as VARCHAR or VARBINARY.
        **	13-Jun-00 (gordy)
        **	    Map parameter index.
        **	 8-Jan-01 (gordy)
        **	    Stream classes moved to ParamSet.
        **	 1-Jun-01 (gordy)
        **	    No longer need wrapper class for Reader, so use
        **	    wrapper class to convert InputStream to Reader.
        **	19-Feb-03 (gordy)
        **	    Check for alternate storage format.
        **	 1-Nov-03 (gordy)
        **	    ParamSet functionality extended.
        **	14-Sep-05 (gordy)
        **	    If stream is short enough, save as VARCHAR.
        */
        public void setAsciiStream( int paramIndex, InputStream stream, int length )
        {
            if ( trace.enabled() )  trace.log( title + ".setAsciiStream( " +
                                        paramIndex + ", " + length + " )" );

            /*
            ** Check length to see if can be sent as VARCHAR.
            ** Ingres won't coerce CLOB to VARCHAR, but will
            ** coerce VARCHAR to CLOB, so VARCHAR is preferred.
            */
            if ( length >= 0  &&  length <= (conn.ucs2_supported ? conn.max_nvch_len
                                     : conn.max_vchr_len) )
            {
            char[]  chars = new char[ length ];

            if ( length > 0 )
                try
                {
                Reader	rdr = new InputStreamReader( stream, "US-ASCII" );
                int	len = rdr.read( chars );

                if ( len != length )
                {
                    /*
                    ** Character array limits read so any difference
                    ** must be a truncation.
                    */
                    if ( trace.enabled( 1 ) )
                    trace.write( tr_id + ".setAsciiStream: read only " +
                             len + " of " + length + " characters!" );
                    setWarning( DataTruncation( paramIndex, true,
                                    false, length, len ) );
                }
                }
                catch( IOException )
                { throw SqlEx.get( ERR_GC4007_BLOB_IO ); }

            paramIndex = paramMap( paramIndex );
            paramSet.init( paramIndex, ProviderType.VarChar );
            paramSet.setString( paramIndex, new String( chars ) );
            }
            else
            {
            paramIndex = paramMap( paramIndex );
            paramSet.init( paramIndex, ProviderType.LongVarChar );
            paramSet.setAsciiStream( paramIndex, stream );
            }

            return;
        }
Пример #3
0
        /*
        ** Name: getISR
        **
        ** Description:
        **	Returns an InputStreamReader for input from provided stream
        **	and conversion using the associated encoding .
        **
        ** Input:
        **	stream		    InputStream to be converted.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	InputStreamReader   Reader for encoding conversion of stream.
        **
        ** History:
        **	 6-Sep-02 (gordy)
        **	    Created.
        **	11-Nov-02 (thoda04)
        **	    Ported to .NET Provider.
        */
        public virtual InputStreamReader getISR(InputStream stream)
        {
            InputStreamReader isr;

            if (encoding == null)
                isr = new InputStreamReader(stream);
            else
                isr = new InputStreamReader(stream, encoding);

            return (isr);
        }