Tabnine Logo
DbException.convertToIOException
Code IndexAdd Tabnine to your IDE (free)

How to use
convertToIOException
method
in
org.h2.message.DbException

Best Java code snippets using org.h2.message.DbException.convertToIOException (Showing top 20 results out of 315)

origin: com.h2database/h2

  @Override
  public void close() throws IOException {
    if (closed) {
      return;
    }
    closed = true;
    try {
      rs.close();
    } catch (SQLException e) {
      throw DbException.convertToIOException(e);
    }
  }
};
origin: com.h2database/h2

@Override
public void close() throws IOException {
  if (closed) {
    return;
  }
  closed = true;
  try {
    rs.close();
  } catch (SQLException e) {
    throw DbException.convertToIOException(e);
  }
}
@Override
origin: com.h2database/h2

private static byte[] getKeyStoreBytes(KeyStore store, String password)
    throws IOException {
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  try {
    store.store(bout, password.toCharArray());
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  }
  return bout.toByteArray();
}
origin: com.h2database/h2

/**
 * Skip a number of characters in a reader.
 *
 * @param reader the reader
 * @param skip the number of characters to skip
 * @throws EOFException if the end of file has been reached before all
 *             characters could be skipped
 * @throws IOException if an IO exception occurred while skipping
 */
public static void skipFully(Reader reader, long skip) throws IOException {
  try {
    while (skip > 0) {
      long skipped = reader.skip(skip);
      if (skipped <= 0) {
        throw new EOFException();
      }
      skip -= skipped;
    }
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  }
}
origin: com.h2database/h2

/**
 * Skip a number of bytes in an input stream.
 *
 * @param in the input stream
 * @param skip the number of bytes to skip
 * @throws EOFException if the end of file has been reached before all bytes
 *             could be skipped
 * @throws IOException if an IO exception occurred while skipping
 */
public static void skipFully(InputStream in, long skip) throws IOException {
  try {
    while (skip > 0) {
      long skipped = in.skip(skip);
      if (skipped <= 0) {
        throw new EOFException();
      }
      skip -= skipped;
    }
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  }
}
origin: com.h2database/h2

  @Override
  public void close() throws IOException {
    super.close();
    try {
      task.get();
    } catch (Exception e) {
      throw DbException.convertToIOException(e);
    }
  }
};
origin: com.h2database/h2

  @Override
  public void close() throws IOException {
    super.close();
    try {
      task.get();
    } catch (Exception e) {
      throw DbException.convertToIOException(e);
    }
  }
};
origin: com.h2database/h2

/**
 * Try to read the given number of bytes to the buffer. This method reads
 * until the maximum number of bytes have been read or until the end of
 * file.
 *
 * @param in the input stream
 * @param buffer the output buffer
 * @param max the number of bytes to read at most
 * @return the number of bytes read, 0 meaning EOF
 */
public static int readFully(InputStream in, byte[] buffer, int max)
    throws IOException {
  try {
    int result = 0, len = Math.min(max, buffer.length);
    while (len > 0) {
      int l = in.read(buffer, result, len);
      if (l < 0) {
        break;
      }
      result += l;
      len -= l;
    }
    return result;
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  }
}
origin: com.h2database/h2

/**
 * Try to read the given number of characters to the buffer. This method
 * reads until the maximum number of characters have been read or until the
 * end of file.
 *
 * @param in the reader
 * @param buffer the output buffer
 * @param max the number of characters to read at most
 * @return the number of characters read, 0 meaning EOF
 */
public static int readFully(Reader in, char[] buffer, int max)
    throws IOException {
  try {
    int result = 0, len = Math.min(max, buffer.length);
    while (len > 0) {
      int l = in.read(buffer, result, len);
      if (l < 0) {
        break;
      }
      result += l;
      len -= l;
    }
    return result;
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  }
}
origin: com.h2database/h2

private void initWrite() throws IOException {
  if (output == null) {
    try {
      OutputStream out = FileUtils.newOutputStream(fileName, false);
      out = new BufferedOutputStream(out, Constants.IO_BUFFER_SIZE);
      output = new BufferedWriter(new OutputStreamWriter(out, characterSet));
    } catch (Exception e) {
      close();
      throw DbException.convertToIOException(e);
    }
  }
}
origin: com.h2database/h2

    private void fillBuffer() throws IOException {
      if (buffer != null && bufferPos < buffer.length) {
        return;
      }
      if (remainingBytes <= 0) {
        return;
      }
if (lobMapIndex >= lobMapBlocks.length) {
  System.out.println("halt!");
}
      try {
        buffer = readBlock(lobMapBlocks[lobMapIndex]);
        lobMapIndex++;
        bufferPos = 0;
      } catch (SQLException e) {
        throw DbException.convertToIOException(e);
      }
    }

origin: com.h2database/h2

@Override
public int read(byte[] buff, int off, int length) throws IOException {
  if (length == 0) {
    return 0;
  }
  length = (int) Math.min(length, remainingBytes);
  if (length == 0) {
    return -1;
  }
  try {
    length = handler.readLob(lob, hmac, pos, buff, off, length);
  } catch (DbException e) {
    throw DbException.convertToIOException(e);
  }
  if (length == 0) {
    return -1;
  }
  remainingBytes -= length;
  pos += length;
  return length;
}
origin: com.h2database/h2

/**
 * Read a number of bytes from an input stream and close the stream.
 *
 * @param in the input stream
 * @param length the maximum number of bytes to read, or -1 to read until
 *            the end of file
 * @return the bytes read
 */
public static byte[] readBytesAndClose(InputStream in, int length)
    throws IOException {
  try {
    if (length <= 0) {
      length = Integer.MAX_VALUE;
    }
    int block = Math.min(Constants.IO_BUFFER_SIZE, length);
    ByteArrayOutputStream out = new ByteArrayOutputStream(block);
    copy(in, out, length);
    return out.toByteArray();
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  } finally {
    in.close();
  }
}
origin: com.h2database/h2

@Override
public int read() throws IOException {
  while (true) {
    try {
      if (current == null) {
        if (closed) {
          return -1;
        }
        if (!rs.next()) {
          close();
          return -1;
        }
        current = rs.getBinaryStream(1);
        current = new BufferedInputStream(current);
      }
      int x = current.read();
      if (x >= 0) {
        return x;
      }
      current = null;
    } catch (SQLException e) {
      throw DbException.convertToIOException(e);
    }
  }
}
@Override
origin: com.h2database/h2

@Override
public int read() throws IOException {
  while (true) {
    try {
      if (current == null) {
        if (closed) {
          return -1;
        }
        if (!rs.next()) {
          close();
          return -1;
        }
        current = rs.getCharacterStream(1);
        current = new BufferedReader(current);
      }
      int x = current.read();
      if (x >= 0) {
        return x;
      }
      current = null;
    } catch (SQLException e) {
      throw DbException.convertToIOException(e);
    }
  }
}
@Override
origin: com.h2database/h2

/**
 * Copy all data from the input stream to the output stream and close both
 * streams. Exceptions while closing are ignored.
 *
 * @param in the input stream
 * @param out the output stream
 * @return the number of bytes copied
 */
public static long copyAndClose(InputStream in, OutputStream out)
    throws IOException {
  try {
    long len = copyAndCloseInput(in, out);
    out.close();
    return len;
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  } finally {
    closeSilently(out);
  }
}
origin: com.h2database/h2

/**
 * Copy all data from the input stream to the output stream and close the
 * input stream. Exceptions while closing are ignored.
 *
 * @param in the input stream
 * @param out the output stream (null if writing is not required)
 * @return the number of bytes copied
 */
public static long copyAndCloseInput(InputStream in, OutputStream out)
    throws IOException {
  try {
    return copy(in, out);
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  } finally {
    closeSilently(in);
  }
}
origin: com.h2database/h2

@Override
public InputStream getInputStream(ValueLobDb lob, byte[] hmac,
    long byteCount) throws IOException {
  try {
    init();
    assertNotHolds(conn.getSession());
    // see locking discussion at the top
    synchronized (database) {
      synchronized (conn.getSession()) {
        long lobId = lob.getLobId();
        return new LobInputStream(lobId, byteCount);
      }
    }
  } catch (SQLException e) {
    throw DbException.convertToIOException(e);
  }
}
origin: com.h2database/h2

private ValueLobDb createLob(InputStream in, int type) throws IOException {
  byte[] streamStoreId;
  try {
    streamStoreId = streamStore.put(in);
  } catch (Exception e) {
    throw DbException.convertToIOException(e);
  }
  long lobId = generateLobId();
  long length = streamStore.length(streamStoreId);
  int tableId = LobStorageFrontend.TABLE_TEMP;
  Object[] value = { streamStoreId, tableId, length, 0 };
  lobMap.put(lobId, value);
  Object[] key = { streamStoreId, lobId };
  refMap.put(key, Boolean.TRUE);
  ValueLobDb lob = ValueLobDb.create(
      type, database, tableId, lobId, null, length);
  if (TRACE) {
    trace("create " + tableId + "/" + lobId);
  }
  return lob;
}
origin: com.h2database/h2

private void fillBuffer() throws IOException {
  if (buffer != null && pos < bufferLength) {
    return;
  }
  int len = readInt();
  if (decompress == null) {
    // EOF
    this.bufferLength = 0;
  } else if (len < 0) {
    len = -len;
    buffer = ensureSize(buffer, len);
    readFully(buffer, len);
    this.bufferLength = len;
  } else {
    inBuffer = ensureSize(inBuffer, len);
    int size = readInt();
    readFully(inBuffer, len);
    buffer = ensureSize(buffer, size);
    try {
      decompress.expand(inBuffer, 0, len, buffer, 0, size);
    } catch (ArrayIndexOutOfBoundsException e) {
      DbException.convertToIOException(e);
    }
    this.bufferLength = size;
  }
  pos = 0;
}
org.h2.messageDbExceptionconvertToIOException

Javadoc

Convert an exception to an IO exception.

Popular methods of DbException

  • getUnsupportedException
    Gets a SQL exception meaning this feature is not supported.
  • throwInternalError
    Throw an internal error. This method seems to return an exception object, so that it can be used ins
  • convert
    Convert a throwable to an SQL exception using the default mapping. All errors except the following a
  • get
    Create a database exception for a specific error code.
  • <init>
  • addSQL
    Set the SQL statement of the given exception. This method may create a new object.
  • convertIOException
    Convert an IO exception to a database exception.
  • convertInvocation
    Convert an InvocationTarget exception to a database exception.
  • getCause
  • getErrorCode
    Get the error code.
  • getInvalidValueException
    Gets a SQL exception meaning this value is invalid.
  • getJdbcSQLException
    Gets the SQL exception object for a specific error code.
  • getInvalidValueException,
  • getJdbcSQLException,
  • getMessage,
  • getSQLException,
  • getSource,
  • getSyntaxError,
  • printStackTrace,
  • setSource,
  • toSQLException

Popular in Java

  • Making http requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • compareTo (BigDecimal)
  • startActivity (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • String (java.lang)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • JButton (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now