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

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

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

origin: com.h2database/h2

/**
 * Close the underlying reader.
 */
@Override
public void close() {
  try {
    reader.close();
  } catch (IOException e) {
    throw DbException.convertIOException(e, null);
  }
}
origin: com.h2database/h2

@Override
public FilePathDisk toRealPath() {
  try {
    String fileName = new File(name).getCanonicalPath();
    return getPath(fileName);
  } catch (IOException e) {
    throw DbException.convertIOException(e, name);
  }
}
origin: com.h2database/h2

/**
 * Call fsync. Depending on the operating system and hardware, this may or
 * may not in fact write the changes.
 */
public void sync() {
  try {
    file.force(true);
  } catch (IOException e) {
    closeFileSilently();
    throw DbException.convertIOException(e, name);
  }
}
origin: com.h2database/h2

/**
 * Close the file.
 */
public void close() {
  if (file != null) {
    try {
      trace("close", name, file);
      file.close();
    } catch (IOException e) {
      throw DbException.convertIOException(e, name);
    } finally {
      file = null;
    }
  }
}
origin: com.h2database/h2

/**
 * Read a statement from the reader. This method returns null if the end has
 * been reached.
 *
 * @return the SQL statement or null
 */
public String readStatement() {
  if (endOfFile) {
    return null;
  }
  try {
    return readStatementLoop();
  } catch (IOException e) {
    throw DbException.convertIOException(e, null);
  }
}
origin: com.h2database/h2

/**
 * Get the current location of the file pointer.
 *
 * @return the location
 */
public long getFilePointer() {
  if (SysProperties.CHECK2) {
    try {
      if (file.position() != filePos) {
        DbException.throwInternalError(file.position() + " " + filePos);
      }
    } catch (IOException e) {
      throw DbException.convertIOException(e, name);
    }
  }
  return filePos;
}
origin: com.h2database/h2

/**
 * Create a temporary file in the database folder.
 *
 * @return the file name
 */
public String createTempFile() {
  try {
    boolean inTempDir = readOnly;
    String name = databaseName;
    if (!persistent) {
      name = "memFS:" + name;
    }
    return FileUtils.createTempFile(name,
        Constants.SUFFIX_TEMP_FILE, true, inTempDir);
  } catch (IOException e) {
    throw DbException.convertIOException(e, databaseName);
  }
}
origin: com.h2database/h2

/**
 * Go to the specified file location.
 *
 * @param pos the location
 */
public void seek(long pos) {
  if (SysProperties.CHECK &&
      pos % Constants.FILE_BLOCK_SIZE != 0) {
    DbException.throwInternalError(
        "unaligned seek " + name + " pos " + pos);
  }
  try {
    if (pos != filePos) {
      file.position(pos);
      filePos = pos;
    }
  } catch (IOException e) {
    throw DbException.convertIOException(e, name);
  }
}
origin: com.h2database/h2

private PrintWriter getWriter(String fileName, String suffix) {
  fileName = fileName.substring(0, fileName.length() - 3);
  String outputFile = fileName + suffix;
  trace("Created file: " + outputFile);
  try {
    return new PrintWriter(IOUtils.getBufferedWriter(
        FileUtils.newOutputStream(outputFile, false)));
  } catch (IOException e) {
    throw DbException.convertIOException(e, null);
  }
}
origin: com.h2database/h2

private static void copyFileTo(DataHandler h, String sourceFileName,
    String targetFileName) {
  synchronized (h.getLobSyncObject()) {
    try {
      IOUtils.copyFiles(sourceFileName, targetFileName);
    } catch (IOException e) {
      throw DbException.convertIOException(e, null);
    }
  }
}
origin: com.h2database/h2

private static ServerSocket createServerSocketTry(int port, boolean ssl) {
  try {
    InetAddress bindAddress = getBindAddress();
    if (ssl) {
      return CipherFactory.createServerSocket(port, bindAddress);
    }
    if (bindAddress == null) {
      return new ServerSocket(port);
    }
    return new ServerSocket(port, 0, bindAddress);
  } catch (BindException be) {
    throw DbException.get(ErrorCode.EXCEPTION_OPENING_PORT_2,
        be, "" + port, be.toString());
  } catch (IOException e) {
    throw DbException.convertIOException(e, "port: " + port + " ssl: " + ssl);
  }
}
origin: com.h2database/h2

private static void installPgCatalog(Statement stat) throws SQLException {
  try (Reader r = new InputStreamReader(new ByteArrayInputStream(Utils
        .getResource("/org/h2/server/pg/pg_catalog.sql")))) {
    ScriptReader reader = new ScriptReader(r);
    while (true) {
      String sql = reader.readStatement();
      if (sql == null) {
        break;
      }
      stat.execute(sql);
    }
    reader.close();
  } catch (IOException e) {
    throw DbException.convertIOException(e, "Can not read pg_catalog resource");
  }
}
origin: com.h2database/h2

/**
 * Read a number of bytes.
 *
 * @param b the target buffer
 * @param off the offset
 * @param len the number of bytes to read
 */
public void readFully(byte[] b, int off, int len) {
  if (SysProperties.CHECK &&
      (len < 0 || len % Constants.FILE_BLOCK_SIZE != 0)) {
    DbException.throwInternalError(
        "unaligned read " + name + " len " + len);
  }
  checkPowerOff();
  try {
    FileUtils.readFully(file, ByteBuffer.wrap(b, off, len));
  } catch (IOException e) {
    throw DbException.convertIOException(e, name);
  }
  filePos += len;
}
origin: com.h2database/h2

@Override
public byte[] getBytesNoCopy() {
  if (type == CLOB) {
    // convert hex to string
    return super.getBytesNoCopy();
  }
  if (small != null) {
    return small;
  }
  try {
    return IOUtils.readBytesAndClose(
        getInputStream(), Integer.MAX_VALUE);
  } catch (IOException e) {
    throw DbException.convertIOException(e, fileName);
  }
}
origin: com.h2database/h2

@Override
public InputStream getInputStream() {
  if (small != null) {
    return new ByteArrayInputStream(small);
  } else if (fileName != null) {
    FileStore store = handler.openFile(fileName, "r", true);
    boolean alwaysClose = SysProperties.lobCloseBetweenReads;
    return new BufferedInputStream(new FileStoreInputStream(store,
        handler, false, alwaysClose), Constants.IO_BUFFER_SIZE);
  }
  long byteCount = (type == Value.BLOB) ? precision : -1;
  try {
    return handler.getLobStorage().getInputStream(this, hmac, byteCount);
  } catch (IOException e) {
    throw DbException.convertIOException(e, toString());
  }
}
origin: com.h2database/h2

@Override
public byte[] getBytesNoCopy() {
  if (type == CLOB) {
    // convert hex to string
    return super.getBytesNoCopy();
  }
  if (small != null) {
    return small;
  }
  try {
    return IOUtils.readBytesAndClose(getInputStream(), Integer.MAX_VALUE);
  } catch (IOException e) {
    throw DbException.convertIOException(e, toString());
  }
}
origin: com.h2database/h2

@Override
public String getString() {
  int len = precision > Integer.MAX_VALUE || precision == 0 ?
      Integer.MAX_VALUE : (int) precision;
  try {
    if (type == Value.CLOB) {
      if (small != null) {
        return new String(small, StandardCharsets.UTF_8);
      }
      return IOUtils.readStringAndClose(getReader(), len);
    }
    byte[] buff;
    if (small != null) {
      buff = small;
    } else {
      buff = IOUtils.readBytesAndClose(getInputStream(), len);
    }
    return StringUtils.convertBytesToHex(buff);
  } catch (IOException e) {
    throw DbException.convertIOException(e, fileName);
  }
}
origin: com.h2database/h2

@Override
public void reset() {
  rowId = -1;
  currentRow = null;
  if (session == null) {
    return;
  }
  synchronized (session) {
    session.checkClosed();
    try {
      session.traceOperation("RESULT_RESET", id);
      transfer.writeInt(SessionRemote.RESULT_RESET).writeInt(id).flush();
    } catch (IOException e) {
      throw DbException.convertIOException(e, null);
    }
  }
}
origin: com.h2database/h2

public FileStoreInputStream(FileStore store, DataHandler handler,
    boolean compression, boolean alwaysClose) {
  this.store = store;
  this.alwaysClose = alwaysClose;
  if (compression) {
    compress = CompressTool.getInstance();
  } else {
    compress = null;
  }
  page = Data.create(handler, Constants.FILE_BLOCK_SIZE);
  try {
    if (store.length() <= FileStore.HEADER_LENGTH) {
      close();
    } else {
      fillBuffer();
    }
  } catch (IOException e) {
    throw DbException.convertIOException(e, store.name);
  }
}
origin: com.h2database/h2

private void remapIfOld() {
  if (session == null) {
    return;
  }
  try {
    if (id <= session.getCurrentId() - SysProperties.SERVER_CACHED_OBJECTS / 2) {
      // object is too old - we need to map it to a new id
      int newId = session.getNextId();
      session.traceOperation("CHANGE_ID", id);
      transfer.writeInt(SessionRemote.CHANGE_ID).writeInt(id).writeInt(newId);
      id = newId;
      // TODO remote result set: very old result sets may be
      // already removed on the server (theoretically) - how to
      // solve this?
    }
  } catch (IOException e) {
    throw DbException.convertIOException(e, null);
  }
}
org.h2.messageDbExceptionconvertIOException

Javadoc

Convert an IO exception to a database 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.
  • convertInvocation
    Convert an InvocationTarget exception to a database exception.
  • convertToIOException
    Convert an exception to an IO 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

  • Reading from database using SQL prepared statement
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • getSystemService (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Socket (java.net)
    Provides a client-side TCP socket.
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JCheckBox (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • CodeWhisperer alternatives
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