congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
DbException.convert
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: com.h2database/h2

FunctionCursorResultSet(FunctionIndex index, SearchRow first, SearchRow last, Session session, ResultSet result) {
  super(index, first, last, session);
  this.result = result;
  try {
    this.meta = result.getMetaData();
  } catch (SQLException e) {
    throw DbException.convert(e);
  }
}
origin: com.h2database/h2

/**
 * Converts a LocalTime to a Value.
 *
 * @param localTime the LocalTime to convert, not {@code null}
 * @return the value
 */
public static Value localTimeToTimeValue(Object localTime) {
  try {
    return ValueTime.fromNanos((Long) LOCAL_TIME_TO_NANO.invoke(localTime));
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "time conversion failed");
  }
}
origin: com.h2database/h2

private static Cursor get(Future<Cursor> f) {
  Cursor c;
  try {
    c = f.get();
  } catch (Exception e) {
    throw DbException.convert(e);
  }
  return c == null ? EMPTY_CURSOR : c;
}
origin: com.h2database/h2

/**
 * Converts a LocalDate to a Value.
 *
 * @param localDate the LocalDate to convert, not {@code null}
 * @return the value
 */
public static Value localDateToDateValue(Object localDate) {
  try {
    return ValueDate.fromDateValue(dateValueFromLocalDate(localDate));
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "date conversion failed");
  }
}
origin: com.h2database/h2

/**
 * Encode the string as an URL.
 *
 * @param s the string to encode
 * @return the encoded string
 */
public static String urlEncode(String s) {
  try {
    return URLEncoder.encode(s, "UTF-8");
  } catch (Exception e) {
    // UnsupportedEncodingException
    throw DbException.convert(e);
  }
}
origin: com.h2database/h2

private byte[] fetch() {
  try {
    prep.setInt(2, seq++);
    ResultSet rs = prep.executeQuery();
    if (rs.next()) {
      return rs.getBytes(1);
    }
    return null;
  } catch (SQLException e) {
    throw DbException.convert(e);
  }
}
origin: com.h2database/h2

/**
 * Convert an exception to a SQL exception using the default mapping.
 *
 * @param e the root cause
 * @return the SQL exception object
 */
public static SQLException toSQLException(Throwable e) {
  if (e instanceof SQLException) {
    return (SQLException) e;
  }
  return convert(e).getSQLException();
}
origin: com.h2database/h2

private void open() {
  try {
    conn = JdbcUtils.getConnection(driver, url, user, password);
  } catch (SQLException e) {
    throw DbException.convert(e);
  }
}
origin: com.h2database/h2

@Override
public void uncaughtException(Thread t, Throwable e) {
  db.setBackgroundException(DbException.convert(e));
}
origin: com.h2database/h2

/**
 * Kill a currently running query on this thread.
 */
private synchronized void cancelRequest() {
  if (activeRequest != null) {
    try {
      activeRequest.cancel();
      activeRequest = null;
    } catch (SQLException e) {
      throw DbException.convert(e);
    }
  }
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public Row get() {
  try {
    return cursor.get();
  }
  catch (IgniteCheckedException e) {
    throw DbException.convert(e);
  }
}
origin: com.h2database/h2

/**
 * Convert an InvocationTarget exception to a database exception.
 *
 * @param te the root cause
 * @param message the added message or null
 * @return the database exception object
 */
public static DbException convertInvocation(InvocationTargetException te,
    String message) {
  Throwable t = te.getTargetException();
  if (t instanceof SQLException || t instanceof DbException) {
    return convert(t);
  }
  message = message == null ? t.getMessage() : message + ": " + t.getMessage();
  return get(ErrorCode.EXCEPTION_IN_FUNCTION_1, t, message);
}
origin: com.h2database/h2

public Geometry getGeometryNoCopy() {
  if (geometry == null) {
    try {
      geometry = new WKBReader().read(bytes);
    } catch (ParseException ex) {
      throw DbException.convert(ex);
    }
  }
  return geometry;
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public Row get() {
  try {
    return desc.createRow(curr.get());
  }
  catch (IgniteCheckedException e) {
    throw DbException.convert(e);
  }
}
origin: com.h2database/h2

/**
 * Get or create a geometry value for the given geometry.
 *
 * @param s the WKT representation of the geometry
 * @return the value
 */
public static ValueGeometry get(String s) {
  try {
    Geometry g = new WKTReader().read(s);
    return get(g);
  } catch (ParseException ex) {
    throw DbException.convert(ex);
  }
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public byte[] getBytesNoCopy() {
  if (obj.cacheObjectType() == CacheObject.TYPE_REGULAR) {
    // Result must be the same as `marshaller.marshall(obj.value(coctx, false));`
    try {
      return obj.valueBytes(valCtx);
    }
    catch (IgniteCheckedException e) {
      throw DbException.convert(e);
    }
  }
  // For user-provided and array types.
  return JdbcUtils.serialize(obj, null);
}
origin: com.h2database/h2

@Override
public void removeRow(Session session, Row row) {
  lastModificationId = database.getNextModificationDataId();
  Transaction t = session.getTransaction();
  long savepoint = t.setSavepoint();
  try {
    for (int i = indexes.size() - 1; i >= 0; i--) {
      Index index = indexes.get(i);
      index.remove(session, row);
    }
  } catch (Throwable e) {
    t.rollbackToSavepoint(savepoint);
    throw DbException.convert(e);
  }
  analyzeIfRequired(session);
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public long getRowCount(Session ses) {
  try {
    int seg = threadLocalSegment();
    H2Tree tree = treeForRead(seg);
    GridH2QueryContext qctx = GridH2QueryContext.get();
    return tree.size(filter(qctx));
  }
  catch (IgniteCheckedException e) {
    throw DbException.convert(e);
  }
}
origin: com.h2database/h2

/**
 * Get or create a geometry value for the given geometry.
 *
 * @param s the WKT representation of the geometry
 * @param srid the srid of the object
 * @return the value
 */
public static ValueGeometry get(String s, int srid) {
  try {
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), srid);
    Geometry g = new WKTReader(geometryFactory).read(s);
    return get(g);
  } catch (ParseException ex) {
    throw DbException.convert(ex);
  }
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public Cursor findFirstOrLast(Session session, boolean b) {
  try {
    H2Tree tree = treeForRead(threadLocalSegment());
    GridH2QueryContext qctx = GridH2QueryContext.get();
    return new SingleRowCursor(b ? tree.findFirst(filter(qctx)): tree.findLast(filter(qctx)));
  }
  catch (IgniteCheckedException e) {
    throw DbException.convert(e);
  }
}
org.h2.messageDbExceptionconvert

Javadoc

Convert a throwable to an SQL exception using the default mapping. All errors except the following are re-thrown: StackOverflowError, LinkageError.

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
  • 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.
  • 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

  • Updating database using SQL prepared statement
  • startActivity (Activity)
  • scheduleAtFixedRate (Timer)
  • onCreateOptionsMenu (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Notification (javax.management)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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