Package java.sql

Examples of java.sql.SQLException


    this.streamFactory = streamFactory;
  }

  public InputStreamFactory getStreamFactory() throws SQLException {
    if (this.streamFactory == null) {
        throw new SQLException("Already freed"); //$NON-NLS-1$
      }
    return streamFactory;
  }
View Full Code Here


    if (this.streamFactory != null) {
      try {
        this.streamFactory.free();
        this.streamFactory = null;
      } catch (IOException e) {
        SQLException ex = new SQLException(e.getMessage());
        ex.initCause(e);
        throw ex;
      }
    }
  }
View Full Code Here

      Reader r = this.getStreamFactory().getCharacterStream();
      if (r != null) {
        return r;
      }
    } catch (IOException e) {
      SQLException ex = new SQLException(e.getMessage());
      ex.initCause(e);
      throw ex;
    }
    Charset cs = getCharset();
    if (cs == null) {
      cs = Streamable.CHARSET;
View Full Code Here

    public InputStream getBinaryStream() throws SQLException {
      try {
      return this.getStreamFactory().getInputStream();
    } catch (IOException e) {
      SQLException ex = new SQLException(e.getMessage());
      ex.initCause(e);
      throw ex;
    }
    }
View Full Code Here

        return actualColumnCount;
    }
   
    private void verifyColumnIndex(int index) throws SQLException {
        if(index > actualColumnCount) {
            throw new SQLException(JDBCPlugin.Util.getString("FilteredResultsMetadata.Invalid_index", index)); //$NON-NLS-1$
        }
    }
View Full Code Here

    return iface.isInstance(this);
  }

  public <T> T unwrap(Class<T> iface) throws SQLException {
    if (!isWrapperFor(iface)) {
      throw new SQLException(JDBCPlugin.Util.getString("WrapperImpl.wrong_class", iface)); //$NON-NLS-1$
    }
   
    return iface.cast(this);
  }
View Full Code Here

                    prep = conn.prepareStatement("SELECT * FROM NEWS WHERE VALUE = ?");
                }
                prep.setString(1, PREFIX_URL + random.nextInt(len));
                ResultSet rs = prep.executeQuery();
                if (!rs.next()) {
                    throw new SQLException("expected one row, got none");
                }
                if (rs.next()) {
                    throw new SQLException("expected one row, got more");
                }
            } else {
                PreparedStatement prep = conn.prepareStatement("UPDATE NEWS SET STATE = ? WHERE FID = ?");
                prep.setInt(1, random.nextInt(100));
                prep.setInt(2, random.nextInt(len));
                int count = prep.executeUpdate();
                if (count != 1) {
                    throw new SQLException("expected one row, got " + count);
                }
            }
        }
    }
View Full Code Here

        patternLength *= bytesPerComparison;
        targetLength *= bytesPerComparison;

        if (start < 1) {
            Object[] params = new Object[] {new Long(start)};
            throw new SQLException(CorePlugin.Util.getString("MMClob_MMBlob.2", params)); //$NON-NLS-1$
        }
       
        start = (start - 1)*bytesPerComparison;
       
        if (start + patternLength > targetLength) {
            return -1;
        }
        /*
         * Use karp-rabin matching to reduce the cost of back tracing for failed matches
         *
         * TODO: optimize for patterns that are small enough to fit in a reasonable buffer
         */
        try {
          InputStream patternStream = pattern.getBinaryStream();
          InputStream targetStream = target.getBinaryStream();
          InputStream laggingTargetStream = target.getBinaryStream();
          try {
            int patternHash = computeStreamHash(patternStream, patternLength);
            int lastMod = 1;
            for (int i = 0; i < patternLength; i++) {
              lastMod *= MOD;
            }             
            targetStream.skip(start);
            laggingTargetStream.skip(start);
           
            long position = start + 1;
           
            int streamHash = computeStreamHash(targetStream, patternLength);
           
            do {
              if ((position -1)%bytesPerComparison == 0 && patternHash == streamHash && validateMatch(pattern, target, position)) {
                return (position - 1)/bytesPerComparison + 1;
              }
             
              streamHash = MOD * streamHash + targetStream.read() - lastMod * laggingTargetStream.read();
              position++;
           
            } while (position + patternLength - 1 <= targetLength);
           
            return -1;
          } finally {
            if (patternStream != null) {
              patternStream.close();
            }
            if (targetStream != null) {
              targetStream.close();
            }
            if (laggingTargetStream != null) {
              laggingTargetStream.close();
            }
          }
        } catch (IOException e) {
          throw new SQLException(e);
        }
    }
View Full Code Here

        // Closing the statement will cause the
        // MMConnection.closeStatement() method to be called,
        // which will modify this.statements.  So, we do this iteration
        // in a separate safe copy of the list
        List<StatementImpl> statementsSafe = new ArrayList<StatementImpl>(this.statements);
        SQLException ex = null;
        for (StatementImpl statement : statementsSafe) {
            try {
              statement.close();
            } catch (SQLException e) {
              ex = e;
View Full Code Here

     * @exception SQLException if there is an error accessing the <code>CLOB</code>
     */
    public String getSubString(long pos, int length) throws SQLException {
        if (pos < 1) {
            Object[] params = new Object[] {new Long(pos)};
            throw new SQLException(CorePlugin.Util.getString("MMClob_MMBlob.0", params)); //$NON-NLS-1$
        } else if (pos > length()) {
            return null;
        }
        pos = pos - 1;
        if (length < 0) {
            Object[] params = new Object[] {new Integer( length)};
            throw new SQLException(CorePlugin.Util.getString("MMClob_MMBlob.1", params)); //$NON-NLS-1$
        } else if ((pos+length) > length()) {
            length = (int)(length()-pos);
        }
        Reader in = getCharacterStream();
        try {
          try {
            long skipped = 0;
            while (pos > 0) {
              skipped = in.skip(pos);
              pos -= skipped;
            }
            return new String(ObjectConverterUtil.convertToCharArray(in, length));
          } finally {
            in.close();
          }
        } catch (IOException e) {
          throw new SQLException(e);
        }
    }
View Full Code Here

TOP

Related Classes of java.sql.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.