Package org.apache.derby.client.am

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


       
        if (netSqlca != null) {
            for (int i=0;i<netSqlca.length; i++) {
                int sqlcode = netSqlca[i].getSqlCode();
                if (sqlcode < 0) {
                    throw new SqlException(netAgent_.logWriter_,
                            netSqlca[i]);
                } else {
                    if (sqlcode == SqlCode.END_OF_DATA.getCode()) {
                        setAllRowsReceivedFromServer(true);
                        if (netResultSet_ != null &&
View Full Code Here


    // allow the application to continue to access the ResultSet, so we close it.
    private void checkAndThrowReceivedEndqryrm() throws SqlException {
        // If we are in a split row, and before sending CNTQRY, check whether an ENDQRYRM
        // has been received.
        if (!netResultSet_.openOnServer_) {
            SqlException sqlException = null;
            int sqlcode = org.apache.derby.client.am.Utils.getSqlcodeFromSqlca(netResultSet_.queryTerminatingSqlca_);
            if (sqlcode < 0) {
                sqlException = new SqlException(agent_.logWriter_, netResultSet_.queryTerminatingSqlca_);
            } else {
                sqlException = new SqlException(agent_.logWriter_,
                    new ClientMessageId(SQLState.NET_QUERY_PROCESSING_TERMINATED));
            }
            try {
                netResultSet_.closeX(); // the auto commit logic is in closeX()
            } catch (SqlException e) {
                sqlException.setNextException(e);
            }
            throw sqlException;
        }
    }
View Full Code Here

        } catch (java.net.SocketException e) {
            try {
                socket_.close();
            } catch (java.io.IOException doNothing) {
            }
            throw new SqlException(logWriter_,
                new ClientMessageId(SQLState.SOCKET_EXCEPTION),
                e.getMessage(), e);
        }
    }
View Full Code Here

    }

    // Close socket and its streams.
    public void close_() throws SqlException {
        // can we just close the socket here, do we need to close streams individually
        SqlException accumulatedExceptions = null;
        if (rawSocketInputStream_ != null) {
            try {
                rawSocketInputStream_.close();
            } catch (java.io.IOException e) {
                // note when {6} = 0 it indicates the socket was closed.
                // this should be ok since we are going to go an close the socket
                // immediately following this call.
                // changing {4} to e.getMessage() may require pub changes
                accumulatedExceptions = new SqlException(logWriter_,
                    new ClientMessageId(SQLState.COMMUNICATION_ERROR),
                    e.getMessage(), e);
            } finally {
                rawSocketInputStream_ = null;
            }
        }

        if (rawSocketOutputStream_ != null) {
            try {
                rawSocketOutputStream_.close();
            } catch (java.io.IOException e) {
                // note when {6} = 0 it indicates the socket was closed.
                // this should be ok since we are going to go an close the socket
                // immediately following this call.
                // changing {4} to e.getMessage() may require pub changes
                SqlException latestException = new SqlException(logWriter_,
                    new ClientMessageId(SQLState.COMMUNICATION_ERROR),
                    e.getMessage(), e);
                accumulatedExceptions = Utils.accumulateSQLException(latestException, accumulatedExceptions);
            } finally {
                rawSocketOutputStream_ = null;
            }
        }

        if (socket_ != null) {
            try {
                socket_.close();
            } catch (java.io.IOException e) {
                // again {6} = 0, indicates the socket was closed.
                // maybe set {4} to e.getMessage().
                // do this for now and but may need to modify or
                // add this to the message pubs.
                SqlException latestException = new SqlException(logWriter_,
                    new ClientMessageId(SQLState.COMMUNICATION_ERROR),
                        e.getMessage(), e);
                accumulatedExceptions = Utils.accumulateSQLException(latestException, accumulatedExceptions);
            } finally {
                socket_ = null;
View Full Code Here

            } else if (s.equalsIgnoreCase("basic")) {
        return SSL_BASIC;
      } else if (s.equalsIgnoreCase("peerAuthentication")) {
        return SSL_PEER_AUTHENTICATION;
      } else {
                throw new SqlException(null,
                                       new ClientMessageId(SQLState.INVALID_ATTRIBUTE),
                                       Attribute.SSL_ATTR, s, "off, basic, peerAuthentication");
      }
    } else {
      // Default
View Full Code Here

            while (attrTokenizer.hasMoreTokens()) {
                String v = attrTokenizer.nextToken();

                int eqPos = v.indexOf('=');
                if (eqPos == -1) {
                    throw new SqlException(null,
                        new ClientMessageId(SQLState.INVALID_ATTRIBUTE_SYNTAX),
                        attributeString);
                }
               
                augmentedProperties.setProperty((v.substring(0, eqPos)).trim(), (v.substring(eqPos + 1)).trim());
            }
        } catch (NoSuchElementException e) {
            // A null log writer is passed, because jdbc 1 sqlexceptions are automatically traced
            throw new SqlException(null,
                new ClientMessageId(SQLState.INVALID_ATTRIBUTE_SYNTAX),
                attributeString, e);
        }
        checkBoolean(augmentedProperties, Attribute.CLIENT_RETIEVE_MESSAGE_TEXT);
        return augmentedProperties;
View Full Code Here

                choicesStr += "|";
            }
            choicesStr += choices[i];
        }

        throw new SqlException(null,
            new ClientMessageId(SQLState.INVALID_ATTRIBUTE),
            attribute, value, choicesStr);
    }
View Full Code Here

        bytesRead = in.read(clearedBytes, pos, leftToRead);
        totalBytesRead += bytesRead;
      } catch (java.io.IOException e) {
        padScalarStreamForError(leftToRead, bytesToRead);
        // set with SQLSTATE 01004: The value of a string was truncated when assigned to a host variable.
        netAgent_.accumulateReadException(new SqlException(netAgent_.logWriter_,
                                   new ClientMessageId(SQLState.NET_IOEXCEPTION_ON_READ),
                                   new Integer(parameterIndex), e.getMessage(), e));
        return;
      }
      if (bytesRead == -1) {
        //padScalarStreamForError(leftToRead, bytesToRead);
        // set with SQLSTATE 01004: The value of a string was truncated when assigned to a host variable.
        /*throw new SqlException(netAgent_.logWriter_,
          "End of Stream prematurely reached while reading InputStream, parameter #" +
          parameterIndex +
          ".  Remaining data has been padded with 0x0.");*/
        //is it OK to do a chain break Exception here. It's not good to
        //pad it with 0 and encrypt and send it to the server because it takes too much time
        //can't just throw a SQLException either because some of the data PRPSQLSTT etc have already
        //been sent to the server, and server is waiting for EXTDTA, server hangs for this.
        netAgent_.accumulateChainBreakingReadExceptionAndThrow(
                                     new DisconnectException(netAgent_,
                                                 new ClientMessageId(SQLState.NET_PREMATURE_EOS_DISCONNECT),
                                                 new Integer(parameterIndex)));
        return;

        /*netAgent_.accumulateReadException(
          new SqlException(netAgent_.logWriter_,
          "End of Stream prematurely reached while reading InputStream, parameter #" +
          parameterIndex +
          ".  Remaining data has been padded with 0x0."));
          return;*/
      } else {
        pos += bytesRead;
        //offset_ += bytesRead;  //comment this out for data stream encryption.
        leftToRead -= bytesRead;
      }

    } while (leftToRead > 0);

    // check to make sure that the specified length wasn't too small
    try {
      if (in.read() != -1) {
        // set with SQLSTATE 01004: The value of a string was truncated when assigned to a host variable.
        netAgent_.accumulateReadException(new SqlException(
                                   netAgent_.logWriter_,
                                   new ClientMessageId(SQLState.NET_INPUTSTREAM_LENGTH_TOO_SMALL),
                                   new Integer(parameterIndex)));
      }
    } catch (java.io.IOException e) {
      netAgent_.accumulateReadException(new SqlException(
                                 netAgent_.logWriter_,
                                 new ClientMessageId(
                                           SQLState.NET_IOEXCEPTION_ON_STREAMLEN_VERIFICATION),
                                 new Integer(parameterIndex),
                                 e.getMessage(),
View Full Code Here

          bytesRead = in.read(bytes_, offset_, bytesToRead);
          totalBytesRead += bytesRead;
        } catch (java.io.IOException e) {
          padScalarStreamForError(leftToRead, bytesToRead);
          // set with SQLSTATE 01004: The value of a string was truncated when assigned to a host variable.
          netAgent_.accumulateReadException(new SqlException(
                                     netAgent_.logWriter_,
                                     new ClientMessageId(SQLState.NET_IOEXCEPTION_ON_READ),
                                     new Integer(parameterIndex),
                                     e.getMessage(),
                                     e));

          return;
        }
        if (bytesRead == -1) {
          padScalarStreamForError(leftToRead, bytesToRead);
          // set with SQLSTATE 01004: The value of a string was truncated when assigned to a host variable.
          netAgent_.accumulateReadException(new SqlException(netAgent_.logWriter_,
                                     new ClientMessageId(SQLState.NET_PREMATURE_EOS),
                                     new Integer(parameterIndex)));
          return;
        } else {
          bytesToRead -= bytesRead;
          offset_ += bytesRead;
          leftToRead -= bytesRead;
        }
      } while (bytesToRead > 0);

      bytesToRead = flushScalarStreamSegment(leftToRead, bytesToRead);
    } while (leftToRead > 0);

    // check to make sure that the specified length wasn't too small
    try {
      if (in.read() != -1) {
        // set with SQLSTATE 01004: The value of a string was truncated when assigned to a host variable.
        netAgent_.accumulateReadException(new SqlException(netAgent_.logWriter_,
                                   new ClientMessageId(SQLState.NET_INPUTSTREAM_LENGTH_TOO_SMALL),
                                   new Integer(parameterIndex)));
      }
    } catch (java.io.IOException e) {
      netAgent_.accumulateReadException(new SqlException(
                                 netAgent_.logWriter_,
                                 new ClientMessageId(
                                           SQLState.NET_IOEXCEPTION_ON_STREAMLEN_VERIFICATION),
                                 new Integer(parameterIndex),
                                 e.getMessage(),
View Full Code Here

            }
           
           
        } catch (java.io.IOException e) {
           
            final SqlException sqlex =
                new SqlException(netAgent_.logWriter_,
                                 new ClientMessageId(SQLState.NET_IOEXCEPTION_ON_READ),
                                 new Integer(parameterIndex),
                                 e.getMessage(),
                                 e);

            netAgent_.accumulateReadException(sqlex);
           
          return;
        }
       
       
       
    // check to make sure that the specified length wasn't too small
    try {
      if (in.read() != -1) {
        // set with SQLSTATE 01004: The value of a string was truncated when assigned to a host variable.

                final SqlException sqlex =
                    new SqlException(netAgent_.logWriter_,
                                     new ClientMessageId(SQLState.NET_INPUTSTREAM_LENGTH_TOO_SMALL),
                                     new Integer(parameterIndex));

        netAgent_.accumulateReadException(sqlex);
      }
    } catch (java.io.IOException e) {
      netAgent_.accumulateReadException(new SqlException(
                                 netAgent_.logWriter_,
                                 new ClientMessageId(
                                           SQLState.NET_IOEXCEPTION_ON_STREAMLEN_VERIFICATION),
                                 new Integer(parameterIndex),
                                 e.getMessage(),
View Full Code Here

TOP

Related Classes of org.apache.derby.client.am.SqlException

Copyright © 2018 www.massapicom. 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.