Examples of Clob


Examples of java.sql.Clob

                checkProcedureOutput(param,paramType,val);
            return true;
        }
        case Types.CLOB: {
            // clob not allowed for procedures
            Clob clob = cs.getClob(param);
            boolean wn = cs.wasNull();
            return true;
        }
        case Types.BLOB: {
            // blob not allowed for procedures
View Full Code Here

Examples of java.sql.Clob

     * @param LOCATOR an integer that represents the locator that needs to be
     *                removed from the hash map.
     * @throws SQLException.
     */
    public static void CLOBRELEASELOCATOR(int LOCATOR) throws SQLException {
        Clob clob = (Clob)getEmbedConnection().getLOBMapping(LOCATOR);
        if (clob == null) {
            throw newSQLException(SQLState.LOB_LOCATOR_INVALID);
        }
        EmbedClob embedClob = (EmbedClob)clob;
        embedClob.free();
View Full Code Here

Examples of java.sql.Clob

     * @return a Clob object that is mapped to the LOCATOR object passed in.
     * @throws a SQLException.
     */
    private static Clob getClobObjectCorrespondingtoLOCATOR(int LOCATOR)
    throws SQLException {
        Clob clob = (Clob)getEmbedConnection().getLOBMapping(LOCATOR);
        if (clob == null) {
            throw newSQLException(SQLState.LOB_LOCATOR_INVALID);
        }
        return clob;
    }
View Full Code Here

Examples of oracle.sql.CLOB

      int i = 0;
      if (rs.next() && i < parameters.length) {
        Writer writer = null;
        try {
          String param = parameters[i++].toString();
          CLOB clob = (CLOB)rs.getClob(i);
          writer = clob.getCharacterOutputStream();
          writer.write(param.toCharArray(), 0, param.length());
        } finally {
          try {
            if (writer != null) {
              writer.close();
View Full Code Here

Examples of oracle.sql.CLOB

      conn = ((AnyConnection)aconn).getConnection();
      stmt = conn.createStatement();
      rs   = stmt.executeQuery(query);

      if (rs.next()) {
        CLOB clob = (CLOB)rs.getClob(1);
        if (clob == null) {
          return Any.NULL;
        }
        reader = clob.getCharacterStream();
        int length = (int)clob.length();
        //System.err.println("-OracleModule.getClob() length: "+length);
        char[] buffer = new char[length];
        int offset = 0;
        while(offset < length) {
          int read = reader.read(buffer, offset, length - offset);
View Full Code Here

Examples of oracle.sql.CLOB

        long totalBytesWritten = 0;
        int bytesRead = 0;
        String theQuery = null;
        FileReader in = null;
        Writer out = null;
        CLOB clob = null;

        try {
            logger.debug9("calling " + SOSClassUtil.getMethodName());
            if (connection == null)
                    throw new Exception(
                            SOSClassUtil.getMethodName()
                                    + ": sorry, there is no successful connection established."
                                    + " may be the connect method was not called");

            if (SOSString.isEmpty(tableName))
                    throw new NullPointerException("tableName is null.");
            if (SOSString.isEmpty(columnName))
                    throw new NullPointerException("columnName is null.");
            if (!file.exists()) throw new Exception("file doesn't exist.");

            query = new StringBuffer("UPDATE ");

            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            if (fieldNameUpperCase) {
                query.append(" SET \"");
                query.append(columnName.toUpperCase());
                query.append("\" = empty_clob() ");
            } else {
                query.append(" SET ");
                query.append(columnName);
                query.append(" = empty_clob() ");
            }

            if (!SOSString.isEmpty(condition))
                condition = " WHERE " + condition;
            else
                condition = "";

            query.append(condition);

            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);

            stmt = connection.createStatement();
            stmt.executeUpdate(theQuery);
            try {
                stmt.close();
                stmt = null;
            } catch (Exception e) {
                throw new Exception("an error occurred closing the statement: "
                        + e);
            }
            stmt = connection.createStatement();
            if (fieldNameUpperCase) {
                query = new StringBuffer("SELECT \"");
                query.append(columnName.toUpperCase());
                query.append("\" FROM ");
            } else {
                query = new StringBuffer("SELECT ");
                query.append(columnName);
                query.append(" FROM ");
            }

            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            query.append(" ");
            query.append(condition);
            query.append(" for update nowait");
            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);
            rs = stmt.executeQuery(theQuery);
            if (rs.next()) clob = (CLOB) rs.getClob(1);

            in = new FileReader(file);
            char[] buffer = new char[clob.getBufferSize()];
            out = clob.getCharacterOutputStream();

            while ((bytesRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, bytesRead);
                totalBytesWritten += bytesRead;
            }
View Full Code Here

Examples of oracle.sql.CLOB

        int bytesRead = 0;
        int bufferSize = 0;
        String theQuery = null;
        Writer out = null;
        StringReader in = null;
        CLOB clob = null;

        try {
            logger.debug9("calling " + SOSClassUtil.getMethodName());
            if (connection == null)
                    throw new Exception(
                            "sorry, there is no successful connection established."
                                    + " may be the connect method is not called");

            if (SOSString.isEmpty(tableName))
                    throw new NullPointerException("tableName is null.");
            if (SOSString.isEmpty(columnName))
                    throw new NullPointerException("columnName is null.");
            if (SOSString.isEmpty(data))
                    throw new Exception("data has null value.");

            query = new StringBuffer("UPDATE ");
            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            if (fieldNameUpperCase) {
                query.append(" SET \"");
                query.append(columnName.toUpperCase());
                query.append("\" = empty_clob() ");
            } else {
                query.append(" SET ");
                query.append(columnName);
                query.append(" = empty_clob() ");
            }

            if (!SOSString.isEmpty(condition))
                condition = " WHERE " + condition;
            else
                condition = "";

            query.append(condition);

            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);

            stmt = connection.createStatement();
            stmt.executeUpdate(theQuery);
            try {
                stmt.close();
                stmt = null;
            } catch (Exception e) {
                throw new Exception(" an error occurred closing the statement: "
                        + e);
            }
            stmt = connection.createStatement();
            if (fieldNameUpperCase) {
                query = new StringBuffer("SELECT \"");
                query.append(columnName.toUpperCase());
                query.append("\" FROM ");
            } else {
                query = new StringBuffer("SELECT ");
                query.append(columnName);
                query.append(" FROM ");
            }

            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            query.append(" ");
            query.append(condition);
            query.append(" for update nowait");
            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);
            rs = stmt.executeQuery(theQuery);
            if (rs.next()) clob = (CLOB) rs.getClob(1);
            bufferSize = clob.getBufferSize();
            char[] buffer = new char[bufferSize];
            out = clob.getCharacterOutputStream();
            in = new StringReader(data);
            while ((bytesRead = in.read(buffer, 0, bufferSize)) != -1) {
                out.write(buffer, 0, bytesRead);
                totalBytesWritten += bytesRead;
            }
View Full Code Here

Examples of org.apache.derby.client.am.Clob

                    case DRDAConstants.DRDA_TYPE_NLOBCMIXED:
                        // check for a promoted Clob
                        o = retrievePromotedParameterIfExists(i);
                        if (o == null) {
                           
                            final Clob c = (Clob) inputs[i];

                            if (c.isString()) {
                                setFDODTALobLength(protocolTypesAndLengths,
                                                   i,
                                                   c.getUTF8Length() );
                               
                            } else if ( ! c.willBeLayerBStreamed() ){
                                // must be a Unicode stream
                                setFDODTALobLength(protocolTypesAndLengths,
                                                   i,
                                                   c.length() );
                               
                            } else {
                                setFDODTALobLengthUnknown( i );
                               
                            }
View Full Code Here

Examples of org.apache.derby.client.am.Clob

                    else if (
                            parameterType == Types.CLOB
                            || parameterType == Types.CHAR
                            || parameterType == Types.VARCHAR
                            || parameterType == Types.LONGVARCHAR) {
                        Clob o = (Clob) retrievePromotedParameterIfExists(index);
                        java.sql.Clob c = (o == null) ? (java.sql.Clob) inputRow[index] : o;
                        boolean isExternalClob = !(c instanceof org.apache.derby.client.am.Clob);

                        if (isExternalClob) {
                            try {
View Full Code Here

Examples of org.apache.derby.client.am.Clob

                        java.io.ByteArrayInputStream bais = null;
                        byte[] ba = null;
                        try {
                            ba = s.getBytes("UTF-8");
                            bais = new java.io.ByteArrayInputStream(ba);
                            Clob c = new Clob(netAgent_, bais, "UTF-8", ba.length);
                            // inputRow[i] = c;
                            // Place the new Lob in the promototedParameter_ collection for
                            // NetStatementRequest use
                            promototedParameters_.put(new Integer(i), c);
                           
                            lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBCMIXED;

                            if( c.willBeLayerBStreamed() ){
                               
                                //Correspond to totalLength 0 as default length for unknown
                                lidAndLengths[i][1] = 0x8002;
                               
                            }else {
                                lidAndLengths[i][1] = buildPlaceholderLength(c.length());
                               
                            }
                           
                        } catch (java.io.UnsupportedEncodingException e) {
                            throw new SqlException(netAgent_.logWriter_,
                                new ClientMessageId(SQLState.UNSUPPORTED_ENCODING),
                                "byte array", "Clob", e);
                        }
                    }
                    break;
                case java.sql.Types.INTEGER:
                    // lid: PROTOCOL_TYPE_NINTEGER, length override: 4
                    // dataFormat: Integer
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NINTEGER;
                    lidAndLengths[i][1] = 4;
                    break;
                case java.sql.Types.BOOLEAN:
                case java.sql.Types.SMALLINT:
                case java.sql.Types.TINYINT:
                case java.sql.Types.BIT:
                    // lid: PROTOCOL_TYPE_NSMALL,  length override: 2
                    // dataFormat: Short
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NSMALL;
                    lidAndLengths[i][1] = 2;
                    break;
                case java.sql.Types.REAL:
                    // lid: PROTOCOL_TYPE_NFLOAT4, length override: 4
                    // dataFormat: Float
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NFLOAT4;
                    lidAndLengths[i][1] = 4;
                    break;
                case java.sql.Types.DOUBLE:
                case java.sql.Types.FLOAT:
                    // lid: PROTOCOL_TYPE_NFLOAT8, length override: 8
                    // dataFormat: Double
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NFLOAT8;
                    lidAndLengths[i][1] = 8;
                    break;
                case java.sql.Types.NUMERIC:
                case java.sql.Types.DECIMAL:
                    // lid: PROTOCOL_TYPE_NDECIMAL
                    // dataFormat: java.math.BigDecimal
                    // if null - guess with precision 1, scale 0
                    // if not null - get scale from data and calculate maximum precision.
                    // DERBY-2073. Get scale and precision from data so we don't lose fractional digits.
                    java.math.BigDecimal bigDecimal = (java.math.BigDecimal) inputRow[i];
                    int scale;
                    int precision;
                   
                    if (bigDecimal == null)
                    {
                        scale = 0;
                        precision = 1;
                    }
                    else
                    {
                        // adjust scale if it is negative. Packed Decimal cannot handle
                        // negative scale. We don't want to change the original
                        // object so make a new one.
                        if (bigDecimal.scale() < 0)
                        {
                            bigDecimal =  bigDecimal.setScale(0);
                            inputRow[i] = bigDecimal;
                        }                       
                        scale = bigDecimal.scale();
                        precision = Utils.computeBigDecimalPrecision(bigDecimal);
                    }                   
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NDECIMAL;
                    lidAndLengths[i][1] = (precision << 8) + // use precision above
                        (scale << 0);
                   
                    break;
                case java.sql.Types.DATE:
                    // for input, output, and inout parameters
                    // lid: PROTOCOL_TYPE_NDATE, length override: 8
                    // dataFormat: java.sql.Date
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NDATE;
                    lidAndLengths[i][1] = 10;
                    break;
                case java.sql.Types.TIME:
                    // for input, output, and inout parameters
                    // lid: PROTOCOL_TYPE_NTIME, length override: 8
                    // dataFormat: java.sql.Time
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NTIME;
                    lidAndLengths[i][1] = 8;
                    break;
                case java.sql.Types.TIMESTAMP:
                    // for input, output, and inout parameters
                    // lid: PROTOCOL_TYPE_NTIME, length overrid: 26
                    // dataFormat: java.sql.Timestamp
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NTIMESTAMP;
                    lidAndLengths[i][1] = 26;
                    break;
                case java.sql.Types.BIGINT:
                    // if SQLAM < 6 this should be mapped to decimal (19,0) in common layer
                    // if SQLAM >=6, lid: PROTOCOL_TYPE_NINTEGER8, length override: 8
                    // dataFormat: Long
                    lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NINTEGER8;
                    lidAndLengths[i][1] = 8;
                    break;
                case java.sql.Types.LONGVARCHAR:
                    // Is this the right thing to do  // should this be 32700
                    s = (String) inputRow[i];
                    if (s == null || s.length() <= 32767 / 3) {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLONGMIX;
                        lidAndLengths[i][1] = 32767;
                    } else {
                        // Flow the data as CLOB data if the data too large to for LONGVARCHAR
                        java.io.ByteArrayInputStream bais = null;
                        byte[] ba = null;
                        try {
                            ba = s.getBytes("UTF-8");
                            bais = new java.io.ByteArrayInputStream(ba);
                            Clob c = new Clob(netAgent_, bais, "UTF-8", ba.length);

                            // inputRow[i] = c;
                            // Place the new Lob in the promototedParameter_ collection for
                            // NetStatementRequest use
                            promototedParameters_.put(new Integer(i), c);

                            lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBCMIXED;
                            lidAndLengths[i][1] = buildPlaceholderLength(c.length());
                        } catch (java.io.UnsupportedEncodingException e) {
                            throw new SqlException(netAgent_.logWriter_,
                                new ClientMessageId(SQLState.UNSUPPORTED_ENCODING),
                                "byte array", "Clob");
                        }
                    }
                    break;
                case java.sql.Types.BINARY:
                case java.sql.Types.VARBINARY:
                    byte[] ba = (byte[]) inputRow[i];
                    if (ba == null) {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NVARBYTE;
                        lidAndLengths[i][1] = 32767;
                    } else if (ba.length <= 32767) {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NVARBYTE;
                        lidAndLengths[i][1] = 32767;
                    } else {
                        // Promote to a BLOB. Only reach this path in the absence of describe information.
                        Blob b = new Blob(ba, netAgent_, 0);

                        // inputRow[i] = b;
                        // Place the new Lob in the promototedParameter_ collection for
                        // NetStatementRequest use
                        promototedParameters_.put(new Integer(i), b);

                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBBYTES;
                        lidAndLengths[i][1] = buildPlaceholderLength(ba.length);
                    }
                    break;
                case java.sql.Types.LONGVARBINARY:
                    ba = (byte[]) inputRow[i];
                    if (ba == null) {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLONGVARBYTE;
                        lidAndLengths[i][1] = 32767;
                    } else if (ba.length <= 32767) {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLONGVARBYTE;
                        lidAndLengths[i][1] = 32767;
                    } else {
                        // Promote to a BLOB. Only reach this path in the absensce of describe information.
                        Blob b = new Blob(ba, netAgent_, 0);

                        // inputRow[i] = b;
                        // Place the new Lob in the promototedParameter_ collection for
                        // NetStatementRequest use
                        promototedParameters_.put(new Integer(i), b);

                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBBYTES;
                        lidAndLengths[i][1] = buildPlaceholderLength(ba.length);
                    }
                    break;
                case java.sql.Types.BLOB:
                    java.sql.Blob b = (java.sql.Blob) inputRow[i];
                    if (b == null) {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBBYTES;
                        lidAndLengths[i][1] =
                                buildPlaceholderLength(parameterMetaData.sqlLength_[i]);
                    } else if (b instanceof Blob && ((Blob)b).isLocator()){
                        //we are sending locators.
                        //Here the LID local identifier in the FDODSC
                        //FD:OCA descriptor should be initialized as
                        //to contain a BLOB locator.
                        lidAndLengths[i][0] =
                                    DRDAConstants.DRDA_TYPE_NLOBLOC;
                        lidAndLengths[i][1] = 4;
                    } else {
                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBBYTES;
                        try {
                           
                            if( b instanceof Blob &&
                                ( (Blob) b).willBeLayerBStreamed() ){
                               
                                //Correspond to totalLength 0 as default length for unknown
                                lidAndLengths[i][1] = 0x8002;
                                   
                            }else {
                                lidAndLengths[i][1] = buildPlaceholderLength(b.length());
                               
                            }
                        } catch (java.sql.SQLException e) {
                            throw new SqlException(netAgent_.logWriter_,
                                new ClientMessageId(SQLState.NET_ERROR_GETTING_BLOB_LENGTH), e);
                        }
                    }
                    break;
                case java.sql.Types.CLOB:
                    {
                        // use columnMeta.singleMixedByteOrDouble_ to decide protocolType
                        java.sql.Clob c = (java.sql.Clob) inputRow[i];
                        boolean isExternalClob = !(c instanceof org.apache.derby.client.am.Clob);
                        long lobLength = 0;
                       
                        boolean doesLayerBStreaming = false;
                       
                        if (c == null) {
                            lobLength = parameterMetaData.sqlLength_[i];
                        } else if (c instanceof Clob && ((Clob)c).isLocator()) {
                            //The inputRow contains an Integer meaning that
                            //we are sending locators.
                            //Here the LID local identifier in the FDODSC
                            //FD:OCA descriptor should be initialized as
                            //to contain a CLOB locator.
                            lidAndLengths[i][0] =
                                    DRDAConstants.DRDA_TYPE_NCLOBLOC;
                            lidAndLengths[i][1] = 4;
                        } else if (isExternalClob) {
                            try {
                                lobLength = c.length();
                            } catch (java.sql.SQLException e) {
                                throw new SqlException(netAgent_.logWriter_,
                                    new ClientMessageId(SQLState.NET_ERROR_GETTING_BLOB_LENGTH),
                                    e);
                            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.