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

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

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

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

/**
 * Converts a value to a Instant.
 *
 * <p>This method should only called from Java 8 or later.</p>
 *
 * @param value the value to convert
 * @return the Instant
 */
public static Object valueToInstant(Value value) {
  try {
    return TIMESTAMP_TO_INSTANT.invoke(value.getTimestamp());
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "timestamp conversion failed");
  }
}
origin: com.h2database/h2

/**
 * Converts a value to a LocalTime.
 *
 * <p>This method should only called from Java 8 or later.</p>
 *
 * @param value the value to convert
 * @return the LocalTime
 */
public static Object valueToLocalTime(Value value) {
  try {
    return LOCAL_TIME_OF_NANO.invoke(null,
        ((ValueTime) value.convertTo(Value.TIME)).getNanos());
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "time conversion failed");
  }
}
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

/**
 * Converts a OffsetDateTime to a Value.
 *
 * @param offsetDateTime the OffsetDateTime to convert, not {@code null}
 * @return the value
 */
public static Value offsetDateTimeToValue(Object offsetDateTime) {
  try {
    Object localDateTime = OFFSET_DATE_TIME_TO_LOCAL_DATE_TIME.invoke(offsetDateTime);
    Object localDate = LOCAL_DATE_TIME_TO_LOCAL_DATE.invoke(localDateTime);
    Object zoneOffset = OFFSET_DATE_TIME_GET_OFFSET.invoke(offsetDateTime);
    long dateValue = dateValueFromLocalDate(localDate);
    long timeNanos = timeNanosFromLocalDateTime(localDateTime);
    short timeZoneOffsetMins = zoneOffsetToOffsetMinute(zoneOffset);
    return ValueTimestampTimeZone.fromDateValueAndNanos(dateValue,
        timeNanos, timeZoneOffsetMins);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "time conversion failed");
  }
}
origin: com.h2database/h2

/**
 * Converts a LocalDateTime to a Value.
 *
 * @param localDateTime the LocalDateTime to convert, not {@code null}
 * @return the value
 */
public static Value localDateTimeToValue(Object localDateTime) {
  try {
    Object localDate = LOCAL_DATE_TIME_TO_LOCAL_DATE.invoke(localDateTime);
    long dateValue = dateValueFromLocalDate(localDate);
    long timeNanos = timeNanosFromLocalDateTime(localDateTime);
    return ValueTimestamp.fromDateValueAndNanos(dateValue, timeNanos);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "local date time conversion failed");
  }
}
origin: com.h2database/h2

/**
 * Convert a throwable to an SQL exception using the default mapping. All
 * errors except the following are re-thrown: StackOverflowError,
 * LinkageError.
 *
 * @param e the root cause
 * @return the exception object
 */
public static DbException convert(Throwable e) {
  if (e instanceof DbException) {
    return (DbException) e;
  } else if (e instanceof SQLException) {
    return new DbException((SQLException) e);
  } else if (e instanceof InvocationTargetException) {
    return convertInvocation((InvocationTargetException) e, null);
  } else if (e instanceof IOException) {
    return get(ErrorCode.IO_EXCEPTION_1, e, e.toString());
  } else if (e instanceof OutOfMemoryError) {
    return get(ErrorCode.OUT_OF_MEMORY, e);
  } else if (e instanceof StackOverflowError || e instanceof LinkageError) {
    return get(ErrorCode.GENERAL_ERROR_1, e, e.toString());
  } else if (e instanceof Error) {
    throw (Error) e;
  }
  return get(ErrorCode.GENERAL_ERROR_1, e, e.toString());
}
origin: com.h2database/h2

/**
 * Converts a value to a OffsetDateTime.
 *
 * <p>This method should only called from Java 8 or later.</p>
 *
 * @param value the value to convert
 * @return the OffsetDateTime
 */
public static Object valueToOffsetDateTime(Value value) {
  ValueTimestampTimeZone valueTimestampTimeZone = (ValueTimestampTimeZone) value.convertTo(Value.TIMESTAMP_TZ);
  long dateValue = valueTimestampTimeZone.getDateValue();
  long timeNanos = valueTimestampTimeZone.getTimeNanos();
  try {
    Object localDateTime = localDateTimeFromDateNanos(dateValue, timeNanos);
    short timeZoneOffsetMins = valueTimestampTimeZone.getTimeZoneOffsetMins();
    int offsetSeconds = (int) TimeUnit.MINUTES.toSeconds(timeZoneOffsetMins);
    Object offset = ZONE_OFFSET_OF_TOTAL_SECONDS.invoke(null, offsetSeconds);
    return OFFSET_DATE_TIME_OF_LOCAL_DATE_TIME_ZONE_OFFSET.invoke(null,
        localDateTime, offset);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "timestamp with time zone conversion failed");
  }
}
origin: com.h2database/h2

/**
 * Converts a value to a LocalDate.
 *
 * <p>This method should only called from Java 8 or later.</p>
 *
 * @param value the value to convert
 * @return the LocalDate
 */
public static Object valueToLocalDate(Value value) {
  try {
    return localDateFromDateValue(((ValueDate) value.convertTo(Value.DATE)).getDateValue());
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "date conversion failed");
  }
}
origin: com.h2database/h2

/**
 * Converts a value to a LocalDateTime.
 *
 * <p>This method should only called from Java 8 or later.</p>
 *
 * @param value the value to convert
 * @return the LocalDateTime
 */
public static Object valueToLocalDateTime(Value value) {
  ValueTimestamp valueTimestamp = (ValueTimestamp) value.convertTo(Value.TIMESTAMP);
  long dateValue = valueTimestamp.getDateValue();
  long timeNanos = valueTimestamp.getTimeNanos();
  try {
    return localDateTimeFromDateNanos(dateValue, timeNanos);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "timestamp conversion failed");
  }
}
origin: com.h2database/h2

  throw DbException.convertInvocation(e, buff.toString());
} catch (Exception e) {
  throw DbException.convert(e);
origin: org.wowtools/h2

private static Object dateToLocalDate(Date date) {
  try {
    return TO_LOCAL_DATE.invoke(date);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "date conversion failed");
  }
}
origin: org.wowtools/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: org.wowtools/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 {
    Date date = (Date) DATE_VALUE_OF.invoke(null, localDate);
    return ValueDate.get(date);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "date conversion failed");
  }
}
origin: org.wowtools/h2

/**
 * Converts a value to a LocalTime.
 *
 * <p>This method should only called from Java 8 or later.</p>
 *
 * @param value the value to convert
 * @return the LocalTime
 */
public static Object valueToLocalTime(Value value) {
  try {
    return LOCAL_TIME_OF_NANO.invoke(null, ((ValueTime) value.convertTo(Value.TIME)).getNanos());
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "time conversion failed");
  }
}
origin: org.wowtools/h2

private static Object timestampWithTimeZoneToOffsetDateTime(
    TimestampWithTimeZone timestampWithTimeZone) {
  long dateValue = timestampWithTimeZone.getYMD();
  long timeNanos = timestampWithTimeZone.getNanosSinceMidnight();
  try {
    Object localDateTime = localDateTimeFromDateNanos(dateValue, timeNanos);
    short timeZoneOffsetMins = timestampWithTimeZone.getTimeZoneOffsetMins();
    int offsetSeconds = (int) TimeUnit.MINUTES.toSeconds(timeZoneOffsetMins);
    Object offset = ZONE_OFFSET_OF_TOTAL_SECONDS.invoke(null, offsetSeconds);
    return OFFSET_DATE_TIME_OF_LOCAL_DATE_TIME_ZONE_OFFSET.invoke(null,
        localDateTime, offset);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "timestamp with time zone conversion failed");
  }
}
origin: org.wowtools/h2

/**
 * Converts a value to a LocalDateTime.
 *
 * <p>This method should only called from Java 8 or later.</p>
 *
 * @param value the value to convert
 * @return the LocalDateTime
 */
public static Object valueToLocalDateTime(ValueTimestamp value) {
  long dateValue = value.getDateValue();
  long timeNanos = value.getTimeNanos();
  try {
    Object localDate = localDateFromDateValue(dateValue);
    Object localDateTime = LOCAL_DATE_AT_START_OF_DAY.invoke(localDate);
    return LOCAL_DATE_TIME_PLUS_NANOS.invoke(localDateTime, timeNanos);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "timestamp conversion failed");
  }
}
origin: org.wowtools/h2

/**
 * Converts a OffsetDateTime to a Value.
 *
 * @param offsetDateTime the OffsetDateTime to convert, not {@code null}
 * @return the value
 */
public static Value offsetDateTimeToValue(Object offsetDateTime) {
  try {
    Object localDateTime = OFFSET_DATE_TIME_TO_LOCAL_DATE_TIME.invoke(offsetDateTime);
    Object localDate = LOCAL_DATE_TIME_TO_LOCAL_DATE.invoke(localDateTime);
    Object zoneOffset = OFFSET_DATE_TIME_GET_OFFSET.invoke(offsetDateTime);
    long dateValue = dateValueFromLocalDate(localDate);
    long timeNanos = timeNanosFromLocalDate(localDateTime);
    short timeZoneOffsetMins = zoneOffsetToOffsetMinute(zoneOffset);
    return ValueTimestampTimeZone.fromDateValueAndNanos(dateValue,
        timeNanos, timeZoneOffsetMins);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "time conversion failed");
  }
}
origin: org.wowtools/h2

/**
 * Converts a LocalDateTime to a Value.
 *
 * @param localDateTime the LocalDateTime to convert, not {@code null}
 * @return the value
 */
public static Value localDateTimeToValue(Object localDateTime) {
  try {
    Object localDate = LOCAL_DATE_TIME_TO_LOCAL_DATE.invoke(localDateTime);
    long dateValue = dateValueFromLocalDate(localDate);
    long timeNanos = timeNanosFromLocalDate(localDateTime);
    return ValueTimestamp.fromDateValueAndNanos(dateValue, timeNanos);
  } catch (IllegalAccessException e) {
    throw DbException.convert(e);
  } catch (InvocationTargetException e) {
    throw DbException.convertInvocation(e, "local date time conversion failed");
  }
}
origin: com.eventsourcing/h2

/**
 * Convert a throwable to an SQL exception using the default mapping. All
 * errors except the following are re-thrown: StackOverflowError,
 * LinkageError.
 *
 * @param e the root cause
 * @return the exception object
 */
public static DbException convert(Throwable e) {
  if (e instanceof DbException) {
    return (DbException) e;
  } else if (e instanceof SQLException) {
    return new DbException((SQLException) e);
  } else if (e instanceof InvocationTargetException) {
    return convertInvocation((InvocationTargetException) e, null);
  } else if (e instanceof IOException) {
    return get(ErrorCode.IO_EXCEPTION_1, e, e.toString());
  } else if (e instanceof OutOfMemoryError) {
    return get(ErrorCode.OUT_OF_MEMORY, e);
  } else if (e instanceof StackOverflowError || e instanceof LinkageError) {
    return get(ErrorCode.GENERAL_ERROR_1, e, e.toString());
  } else if (e instanceof Error) {
    throw (Error) e;
  }
  return get(ErrorCode.GENERAL_ERROR_1, e, e.toString());
}
org.h2.messageDbExceptionconvertInvocation

Javadoc

Convert an InvocationTarget 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.
  • convertIOException
    Convert an IO 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

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • getSharedPreferences (Context)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Best IntelliJ plugins
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