Examples of EnginePreparedStatement


Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

                                             String encoding)
        throws DRDAProtocolException ,
               SQLException ,
               IOException {
        PreparedStatement ps = stmt.getPreparedStatement();
        EnginePreparedStatement engnps =
            ( EnginePreparedStatement ) ps;
       
        final EXTDTAReaderInputStream extdtastream =
            reader.getEXTDTAReaderInputStream(checkNullability);
        // DERBY-3085. Save the stream so it can be drained later
        // if not  used.
        if (streamLOB)
            stmt.setStreamedParameter(extdtastream);
       
        final InputStream is =
            streamLOB ?
            (InputStream) extdtastream :
            convertAsByteArrayInputStream( extdtastream );
       
        final InputStreamReader streamReader =
            new InputStreamReader( is,
                                   encoding ) ;
       
        engnps.setCharacterStream( i + 1,
                                   streamReader );
    }
View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

                                         EXTDTAReaderInputStream extdtaStream,
                                         boolean streamLOB,
                                         String encoding)
           throws IOException, SQLException {
        PreparedStatement ps = stmt.getPreparedStatement();
        EnginePreparedStatement engnps =
            ( EnginePreparedStatement ) ps;
       
        // DERBY-3085. Save the stream so it can be drained later
        // if not  used.
        if (streamLOB)
            stmt.setStreamedParameter(extdtaStream);
       
        final InputStream is =
            streamLOB ?
            (InputStream) extdtaStream :
            convertAsByteArrayInputStream( extdtaStream );
       
        final InputStreamReader streamReader =
            new InputStreamReader( is,
                                   encoding ) ;
       
        engnps.setCharacterStream(i, streamReader);
    }
View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

                                             String encoding)
        throws DRDAProtocolException ,
               SQLException ,
               IOException {
       
        EnginePreparedStatement engnps =
            ( EnginePreparedStatement ) ps;
       
        final EXTDTAReaderInputStream extdtastream =
            reader.getEXTDTAReaderInputStream(checkNullability);
       
        final InputStream is =
            streamLOB ?
            (InputStream) extdtastream :
            convertAsByteArrayInputStream( extdtastream );
       
        final InputStreamReader streamReader =
            new InputStreamReader( is,
                                   encoding ) ;
       
        engnps.setCharacterStream( i + 1,
                                   streamReader );
    }
View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

                                             String encoding)
        throws DRDAProtocolException ,
               SQLException ,
               IOException {
        PreparedStatement ps = stmt.getPreparedStatement();
        EnginePreparedStatement engnps =
            ( EnginePreparedStatement ) ps;
       
        final EXTDTAReaderInputStream extdtastream =
            reader.getEXTDTAReaderInputStream(checkNullability);
        // DERBY-3085. Save the stream so it can be drained later
        // if not  used.
        if (streamLOB)
            stmt.setStreamedParameter(extdtastream);
       
        final InputStream is =
            streamLOB ?
            (InputStream) extdtastream :
            convertAsByteArrayInputStream( extdtastream );
       
        final InputStreamReader streamReader =
            new InputStreamReader( is,
                                   encoding ) ;
       
        engnps.setCharacterStream( i + 1,
                                   streamReader );
    }
View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

                                             String encoding)
        throws DRDAProtocolException ,
               SQLException ,
               IOException {
        PreparedStatement ps = stmt.getPreparedStatement();
        EnginePreparedStatement engnps =
            ( EnginePreparedStatement ) ps;
       
        final EXTDTAReaderInputStream extdtastream =
            reader.getEXTDTAReaderInputStream(checkNullability);
        // DERBY-3085. Save the stream so it can be drained later
        // if not  used.
        if (streamLOB)
            stmt.setStreamedParameter(extdtastream);
       
        final InputStream is =
            streamLOB ?
            (InputStream) extdtastream :
            convertAsByteArrayInputStream( extdtastream );
       
        final InputStreamReader streamReader =
            new InputStreamReader( is,
                                   encoding ) ;
       
        engnps.setCharacterStream( i + 1,
                                   streamReader );
    }
View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

     * @throws SQLException
     */
    private void parseSQLDTA_work(DRDAStatement stmt) throws DRDAProtocolException,SQLException
    {
        String strVal;
        EnginePreparedStatement ps = stmt.getPreparedStatement();
        int codePoint;
        ParameterMetaData pmeta = null;

        // Clear params without releasing storage
        stmt.clearDrdaParams();

        int numVars = 0;
        boolean rtnParam = false;

        reader.markCollection();       
        codePoint = reader.getCodePoint();
        while (codePoint != -1)
        {
                switch (codePoint)
                {
                    // required
                    case CodePoint.FDODSC:
                        while (reader.getDdmLength() > 6) //we get parameter info til last 6 byte
                    {
                        int dtaGrpLen = reader.readUnsignedByte();
                        int numVarsInGrp = (dtaGrpLen - 3) / 3;
                        if (SanityManager.DEBUG) {
                            trace("num of vars in this group is: "+numVarsInGrp);
                        }
                        reader.readByte();      // tripletType
                        reader.readByte();      // id
                        for (int j = 0; j < numVarsInGrp; j++)
                        {
                            final byte t = reader.readByte();
                            if (SanityManager.DEBUG)  {
                                trace("drdaType is: "+ "0x" +
                                      Integer.toHexString(t));
                            }
                            int drdaLength = reader.readNetworkShort();
                            if (SanityManager.DEBUG) {
                                trace("drdaLength is: "+drdaLength);
                            }
                            stmt.addDrdaParam(t, drdaLength);
                        }
                    }
                    numVars = stmt.getDrdaParamCount();
                    if (SanityManager.DEBUG) {
                        trace("numVars = " + numVars);
                    }
                    if (ps == null)     // it is a CallableStatement under construction
                    {
                        StringBuilder marks = new StringBuilder()// construct parameter marks
                        marks.append("(?");
                        for (int i = 1; i < numVars; i++) {
                            marks.append(", ?");
                        }
                        String prepareString = "call " + stmt.procName + marks.toString() + ")";
                        if (SanityManager.DEBUG) {
                            trace ("$$ prepareCall is: "+prepareString);
                        }
                        CallableStatement cs = null;
                        try {
                            cs = (CallableStatement)
                                stmt.prepare(prepareString);           
                            stmt.registerAllOutParams();
                        } catch (SQLException se) {
                            if (! stmt.outputExpected ||
                                (!se.getSQLState().equals(
                                    SQLState.LANG_NO_METHOD_FOUND))) {
                                throw se;
                            }
                            if (SanityManager.DEBUG) {
                                trace("****** second try with return parameter...");
                            }
                            // Save first SQLException most likely suspect
                            if (numVars == 1) {
                                prepareString = "? = call " + stmt.procName +"()";
                            } else {
                                prepareString = "? = call " + stmt.procName +"("+marks.substring(3) + ")";
                            }
                            if (SanityManager.DEBUG) {
                                trace ("$$ prepareCall is: "+prepareString);
                            }
                            try {
                                cs = (CallableStatement) stmt.prepare(prepareString);
                            } catch (SQLException se2)
                            {
                                // The first exception is the most likely suspect
                                throw se;
                            }
                            rtnParam = true;
                        }
                        ps = (EnginePreparedStatement) cs;
                        stmt.ps = ps;
                    }

                    pmeta = stmt.getParameterMetaData();

                    reader.readBytes(6);    // descriptor footer
                    break;
                // optional
                case CodePoint.FDODTA:
                    reader.readByte()// row indicator
                    for (int i = 0; i < numVars; i++)
                    {
                   
                        if ((stmt.getParamDRDAType(i+1) & 0x1) == 0x1// nullable
                        {
                            int nullData = reader.readUnsignedByte();
                            if ((nullData & 0xFF) == FdocaConstants.NULL_DATA)
                            {
                                if (SanityManager.DEBUG) {
                                    trace("******param null");
                                }
                                if (pmeta.getParameterMode(i + 1)
                                    != ParameterMetaData.parameterModeOut) {
                                        ps.setNull(i+1, pmeta.getParameterType(i+1));
                                }
                                if (stmt.isOutputParam(i+1)) {
                                    stmt.registerOutParam(i+1);
                                }
                                continue;
View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

        //We need to marke that params are finished so that we know we
        // are ready to send resultset info.
        stmt.finishParams();
           
        EnginePreparedStatement ps = stmt.getPreparedStatement();
        int rsNum = 0;
        do {
        if (hasResultSet)
        {
            stmt.setCurrentDrdaResultSet(rsNum);
            //indicate that we are going to return data
            stmt.setQryrtndta(true);
            if (!isProcedure) {
                checkWarning(null, ps, null, -1, true, true);
            }
            if (rsNum == 0) {
                writeSQLRSLRD(stmt);
            }
            writeOPNQRYRM(true, stmt);
            writeSQLCINRD(stmt);
            writeQRYDSC(stmt, false);
            stmt.rsSuspend();

            /* Currently, if LMTBLKPRC is used, a pre-condition is that no lob columns.
             * But in the future, when we do support LOB in LMTBLKPRC, the drda spec still
             * does not allow LOB to be sent with OPNQRYRM.  So this "if" here will have
             * to add "no lob columns".
             */
            if (stmt.getQryprctyp() == CodePoint.LMTBLKPRC) {
                writeQRYDTA(stmt);
            }
        }
        else  if (! sendSQLDTARD)
        {
            long updateCount = ps.getLargeUpdateCount();

            // The protocol wants us to send RDBUPDRM here, but we don't do
            // that because it used to cause protocol errors. DERBY-5847 has
            // some discussion about this issue.

View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

                                         EXTDTAReaderInputStream extdtaStream,
                                         boolean streamLOB,
                                         String encoding)
           throws IOException, SQLException {
        PreparedStatement ps = stmt.getPreparedStatement();
        EnginePreparedStatement engnps =
            ( EnginePreparedStatement ) ps;
       
        // DERBY-3085. Save the stream so it can be drained later
        // if not  used.
        if (streamLOB)
            stmt.setStreamedParameter(extdtaStream);
       
        final InputStream is =
            streamLOB ?
            (InputStream) extdtaStream :
            convertAsByteArrayInputStream( extdtaStream );
       
        final InputStreamReader streamReader =
            new InputStreamReader( is,
                                   encoding ) ;
       
        engnps.setCharacterStream(i, streamReader);
    }
View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

        //We need to marke that params are finished so that we know we
        // are ready to send resultset info.
        stmt.finishParams();
           
        EnginePreparedStatement ps = stmt.getPreparedStatement();
        int rsNum = 0;
        do {
        if (hasResultSet)
        {
            stmt.setCurrentDrdaResultSet(rsNum);
            //indicate that we are going to return data
            stmt.setQryrtndta(true);
            if (!isProcedure) {
                checkWarning(null, ps, null, -1, true, true);
            }
            if (rsNum == 0) {
                writeSQLRSLRD(stmt);
            }
            writeOPNQRYRM(true, stmt);
            writeSQLCINRD(stmt);
            writeQRYDSC(stmt, false);
            stmt.rsSuspend();

            /* Currently, if LMTBLKPRC is used, a pre-condition is that no lob columns.
             * But in the future, when we do support LOB in LMTBLKPRC, the drda spec still
             * does not allow LOB to be sent with OPNQRYRM.  So this "if" here will have
             * to add "no lob columns".
             */
            if (stmt.getQryprctyp() == CodePoint.LMTBLKPRC) {
                writeQRYDTA(stmt);
            }
        }
        else  if (! sendSQLDTARD)
        {
            long updateCount = ps.getLargeUpdateCount();

            // The protocol wants us to send RDBUPDRM here, but we don't do
            // that because it used to cause protocol errors. DERBY-5847 has
            // some discussion about this issue.

View Full Code Here

Examples of org.apache.derby.iapi.jdbc.EnginePreparedStatement

     * @throws SQLException
     */
    private void parseSQLDTA_work(DRDAStatement stmt) throws DRDAProtocolException,SQLException
    {
        String strVal;
        EnginePreparedStatement ps = stmt.getPreparedStatement();
        int codePoint;
        ParameterMetaData pmeta = null;

        // Clear params without releasing storage
        stmt.clearDrdaParams();

        int numVars = 0;
        boolean rtnParam = false;

        reader.markCollection();       
        codePoint = reader.getCodePoint();
        while (codePoint != -1)
        {
                switch (codePoint)
                {
                    // required
                    case CodePoint.FDODSC:
                        while (reader.getDdmLength() > 6) //we get parameter info til last 6 byte
                    {
                        int dtaGrpLen = reader.readUnsignedByte();
                        int numVarsInGrp = (dtaGrpLen - 3) / 3;
                        if (SanityManager.DEBUG) {
                            trace("num of vars in this group is: "+numVarsInGrp);
                        }
                        reader.readByte();      // tripletType
                        reader.readByte();      // id
                        for (int j = 0; j < numVarsInGrp; j++)
                        {
                            final byte t = reader.readByte();
                            if (SanityManager.DEBUG)  {
                                trace("drdaType is: "+ "0x" +
                                      Integer.toHexString(t));
                            }
                            int drdaLength = reader.readNetworkShort();
                            if (SanityManager.DEBUG) {
                                trace("drdaLength is: "+drdaLength);
                            }
                            stmt.addDrdaParam(t, drdaLength);
                        }
                    }
                    numVars = stmt.getDrdaParamCount();
                    if (SanityManager.DEBUG) {
                        trace("numVars = " + numVars);
                    }
                    if (ps == null)     // it is a CallableStatement under construction
                    {
                        StringBuilder marks = new StringBuilder()// construct parameter marks
                        marks.append("(?");
                        for (int i = 1; i < numVars; i++) {
                            marks.append(", ?");
                        }
                        String prepareString = "call " + stmt.procName + marks.toString() + ")";
                        if (SanityManager.DEBUG) {
                            trace ("$$ prepareCall is: "+prepareString);
                        }
                        CallableStatement cs = null;
                        try {
                            cs = (CallableStatement)
                                stmt.prepare(prepareString);           
                            stmt.registerAllOutParams();
                        } catch (SQLException se) {
                            if (! stmt.outputExpected ||
                                (!se.getSQLState().equals(
                                    SQLState.LANG_NO_METHOD_FOUND))) {
                                throw se;
                            }
                            if (SanityManager.DEBUG) {
                                trace("****** second try with return parameter...");
                            }
                            // Save first SQLException most likely suspect
                            if (numVars == 1) {
                                prepareString = "? = call " + stmt.procName +"()";
                            } else {
                                prepareString = "? = call " + stmt.procName +"("+marks.substring(3) + ")";
                            }
                            if (SanityManager.DEBUG) {
                                trace ("$$ prepareCall is: "+prepareString);
                            }
                            try {
                                cs = (CallableStatement) stmt.prepare(prepareString);
                            } catch (SQLException se2)
                            {
                                // The first exception is the most likely suspect
                                throw se;
                            }
                            rtnParam = true;
                        }
                        ps = (EnginePreparedStatement) cs;
                        stmt.ps = ps;
                    }

                    pmeta = stmt.getParameterMetaData();

                    reader.readBytes(6);    // descriptor footer
                    break;
                // optional
                case CodePoint.FDODTA:
                    reader.readByte()// row indicator
                    for (int i = 0; i < numVars; i++)
                    {
                   
                        if ((stmt.getParamDRDAType(i+1) & 0x1) == 0x1// nullable
                        {
                            int nullData = reader.readUnsignedByte();
                            if ((nullData & 0xFF) == FdocaConstants.NULL_DATA)
                            {
                                if (SanityManager.DEBUG) {
                                    trace("******param null");
                                }
                                if (pmeta.getParameterMode(i + 1)
                                    != ParameterMetaData.parameterModeOut) {
                                        ps.setNull(i+1, pmeta.getParameterType(i+1));
                                }
                                if (stmt.isOutputParam(i+1)) {
                                    stmt.registerOutParam(i+1);
                                }
                                continue;
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.