org.h2.message
Class Message

java.lang.Object
  extended by org.h2.message.Message

public class Message
extends java.lang.Object

Messages used in the database engine. Use the PropertiesToUTF8 tool to translate properties files to UTF-8 and back. If the word 'SQL' appears then the whole SQL statement must be a parameter, otherwise this may be added: '; SQL statement: ' + sql


Method Summary
static java.sql.SQLException addSQL(java.sql.SQLException e, java.lang.String sql)
          Attach a SQL statement to the exception if this is not already done.
static java.sql.SQLException convert(java.lang.Exception e)
          Convert an exception to a SQL exception using the default mapping.
static java.sql.SQLException convert(java.lang.Exception e, java.lang.String sql)
          Convert an exception to a SQL exception using the default mapping.
static java.sql.SQLException convert(java.lang.StackOverflowError e)
          Convert a stack overflow error.
static java.sql.SQLException convertIOException(java.io.IOException e, java.lang.String message)
          Convert an IO exception to a SQL exception.
static java.sql.SQLException convertThrowable(java.lang.Throwable e)
          Convert a throwable to an SQL exception using the default mapping.
static InternalException convertToInternal(java.lang.Exception e)
          Convert an exception to an internal runtime exception.
static java.io.IOException convertToIOException(java.lang.Throwable e)
          Convert an exception to an IO exception.
static java.lang.Error getInternalError(java.lang.String s, java.lang.Exception e)
          Gets an internal error.
static JdbcSQLException getInvalidValueException(java.lang.String value, java.lang.String param)
          Gets a SQL exception meaning this value is invalid.
static JdbcSQLException getSQLException(int errorCode)
          Gets the SQL exception object for a specific error code.
static JdbcSQLException getSQLException(int errorCode, java.lang.String... params)
          Gets the SQL exception object for a specific error code.
static JdbcSQLException getSQLException(int errorCode, java.lang.String p1)
          Gets the SQL exception object for a specific error code.
static JdbcSQLException getSQLException(int errorCode, java.lang.Throwable cause, java.lang.String... params)
          Gets the SQL exception object for a specific error code.
static java.sql.SQLException getSyntaxError(java.lang.String sql, int index)
          Constructs a syntax error SQL exception.
static java.sql.SQLException getSyntaxError(java.lang.String sql, int index, java.lang.String expected)
          Constructs a syntax error SQL exception.
static JdbcSQLException getUnsupportedException(java.lang.String message)
          Gets a SQL exception meaning this feature is not supported.
static java.lang.RuntimeException throwInternalError()
          Throw an internal error.
static java.lang.RuntimeException throwInternalError(java.lang.String s)
          Throw an internal error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSQLException

public static JdbcSQLException getSQLException(int errorCode,
                                               java.lang.String p1)
Gets the SQL exception object for a specific error code.

Parameters:
errorCode - the error code
p1 - the first parameter of the message
Returns:
the SQLException object

getSQLException

public static JdbcSQLException getSQLException(int errorCode,
                                               java.lang.Throwable cause,
                                               java.lang.String... params)
Gets the SQL exception object for a specific error code.

Parameters:
errorCode - the error code
cause - the cause of the exception
params - the list of parameters of the message
Returns:
the SQLException object

getSQLException

public static JdbcSQLException getSQLException(int errorCode,
                                               java.lang.String... params)
Gets the SQL exception object for a specific error code.

Parameters:
errorCode - the error code
params - the list of parameters of the message
Returns:
the SQLException object

getSyntaxError

public static java.sql.SQLException getSyntaxError(java.lang.String sql,
                                                   int index)
Constructs a syntax error SQL exception.

Parameters:
sql - the SQL statement
index - the position of the error in the SQL statement
Returns:
the SQLException object

getSyntaxError

public static java.sql.SQLException getSyntaxError(java.lang.String sql,
                                                   int index,
                                                   java.lang.String expected)
Constructs a syntax error SQL exception.

Parameters:
sql - the SQL statement
index - the position of the error in the SQL statement
expected - the expected keyword at the given position
Returns:
the SQLException object

getSQLException

public static JdbcSQLException getSQLException(int errorCode)
Gets the SQL exception object for a specific error code.

Parameters:
errorCode - the error code
Returns:
the SQLException object

getUnsupportedException

public static JdbcSQLException getUnsupportedException(java.lang.String message)
Gets a SQL exception meaning this feature is not supported.

Parameters:
message - what exactly is not supported
Returns:
the SQLException object

getInvalidValueException

public static JdbcSQLException getInvalidValueException(java.lang.String value,
                                                        java.lang.String param)
Gets a SQL exception meaning this value is invalid.

Parameters:
value - the value passed
param - the name of the parameter
Returns:
the SQLException object

throwInternalError

public static java.lang.RuntimeException throwInternalError(java.lang.String s)
Throw an internal error. This method seems to return an exception object, so that it can be used instead of 'return', but in fact it always throws the exception.

Parameters:
s - the message
Returns:
the RuntimeException object
Throws:
java.lang.RuntimeException - the exception

throwInternalError

public static java.lang.RuntimeException throwInternalError()
Throw an internal error. This method seems to return an exception object, so that it can be used instead of 'return', but in fact it always throws the exception.

Returns:
the RuntimeException object

getInternalError

public static java.lang.Error getInternalError(java.lang.String s,
                                               java.lang.Exception e)
Gets an internal error.

Parameters:
s - the message
e - the root cause
Returns:
the error object

addSQL

public static java.sql.SQLException addSQL(java.sql.SQLException e,
                                           java.lang.String sql)
Attach a SQL statement to the exception if this is not already done.

Parameters:
e - the original SQL exception
sql - the SQL statement
Returns:
the error object

convert

public static java.sql.SQLException convert(java.lang.Exception e,
                                            java.lang.String sql)
Convert an exception to a SQL exception using the default mapping.

Parameters:
e - the root cause
sql - the SQL statement or null if it is not known
Returns:
the SQL exception object

convert

public static java.sql.SQLException convert(java.lang.StackOverflowError e)
Convert a stack overflow error.

Parameters:
e - the root cause
Returns:
the SQL exception object

convert

public static java.sql.SQLException convert(java.lang.Exception e)
Convert an exception to a SQL exception using the default mapping.

Parameters:
e - the root cause
Returns:
the SQL exception object

convertThrowable

public static java.sql.SQLException convertThrowable(java.lang.Throwable e)
Convert a throwable to an SQL exception using the default mapping. For out of memory errors, this will first try to free up some memory, and if not possible it will re-throw the error. All errors except the following are re-thrown: StackOverflowError, LinkageError.

Parameters:
e - the root cause
Returns:
the SQL exception object

convertIOException

public static java.sql.SQLException convertIOException(java.io.IOException e,
                                                       java.lang.String message)
Convert an IO exception to a SQL exception.

Parameters:
e - the root cause
message - the message
Returns:
the SQL exception object

convertToInternal

public static InternalException convertToInternal(java.lang.Exception e)
Convert an exception to an internal runtime exception.

Parameters:
e - the root cause
Returns:
the error object

convertToIOException

public static java.io.IOException convertToIOException(java.lang.Throwable e)
Convert an exception to an IO exception.

Parameters:
e - the root cause
Returns:
the IO exception