congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
DbException.toSQLException
Code IndexAdd Tabnine to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew ArrayList()
  • Codota Iconnew LinkedList()
  • Smart code suggestions by Tabnine
}
origin: com.h2database/h2

/**
 * Wrap a SQL exception that occurred while accessing a linked table.
 *
 * @param sql the SQL statement
 * @param ex the exception from the remote database
 * @return the wrapped exception
 */
public static DbException wrapException(String sql, Exception ex) {
  SQLException e = DbException.toSQLException(ex);
  return DbException.get(ErrorCode.ERROR_ACCESSING_LINKED_TABLE_2,
      e, sql, e.toString());
}
origin: com.h2database/h2

/**
 * Searches from the full text index for this database.
 * The returned result set has the following column:
 * <ul><li>QUERY (varchar): the query to use to get the data.
 * The query does not include 'SELECT * FROM '. Example:
 * PUBLIC.TEST WHERE ID = 1
 * </li><li>SCORE (float) the relevance score. This value is always 1.0
 * for the native fulltext search.
 * </li></ul>
 *
 * @param conn the connection
 * @param text the search query
 * @param limit the maximum number of rows or 0 for no limit
 * @param offset the offset or 0 for no offset
 * @return the result set
 */
public static ResultSet search(Connection conn, String text, int limit,
    int offset) throws SQLException {
  try {
    return search(conn, text, limit, offset, false);
  } catch (DbException e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

/**
 * Searches from the full text index for this database. The result contains
 * the primary key data as an array. The returned result set has the
 * following columns:
 * <ul>
 * <li>SCHEMA (varchar): the schema name. Example: PUBLIC </li>
 * <li>TABLE (varchar): the table name. Example: TEST </li>
 * <li>COLUMNS (array of varchar): comma separated list of quoted column
 * names. The column names are quoted if necessary. Example: (ID) </li>
 * <li>KEYS (array of values): comma separated list of values. Example: (1)
 * </li>
 * <li>SCORE (float) the relevance score. This value is always 1.0
 * for the native fulltext search.
 * </li>
 * </ul>
 *
 * @param conn the connection
 * @param text the search query
 * @param limit the maximum number of rows or 0 for no limit
 * @param offset the offset or 0 for no offset
 * @return the result set
 */
public static ResultSet searchData(Connection conn, String text, int limit,
    int offset) throws SQLException {
  try {
    return search(conn, text, limit, offset, true);
  } catch (DbException e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

/**
 * Dumps the contents of a database to a SQL script file.
 *
 * @param dir the directory
 * @param db the database name (null for all databases)
 */
public static void execute(String dir, String db) throws SQLException {
  try {
    new Recover().process(dir, db);
  } catch (DbException e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

/**
 * Create a new server for the given service.
 *
 * @param service the service
 * @param args the command line arguments
 */
public Server(Service service, String... args) throws SQLException {
  verifyArgs(args);
  this.service = service;
  try {
    service.init(args);
  } catch (Exception e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

/**
 * Backs up database files.
 *
 * @param zipFileName the name of the target backup file (including path)
 * @param directory the source directory name
 * @param db the source database name (null if there is only one database,
 *            and and empty string to backup all files in this directory)
 * @param quiet don't print progress information
 */
public static void execute(String zipFileName, String directory, String db,
    boolean quiet) throws SQLException {
  try {
    new Backup().process(zipFileName, directory, db, quiet);
  } catch (Exception e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

@Override
public void runTool(String... args) throws SQLException {
  String zipFileName = "backup.zip";
  String dir = ".";
  String db = null;
  boolean quiet = false;
  for (int i = 0; args != null && i < args.length; i++) {
    String arg = args[i];
    if (arg.equals("-dir")) {
      dir = args[++i];
    } else if (arg.equals("-db")) {
      db = args[++i];
    } else if (arg.equals("-quiet")) {
      quiet = true;
    } else if (arg.equals("-file")) {
      zipFileName = args[++i];
    } else if (arg.equals("-help") || arg.equals("-?")) {
      showUsage();
      return;
    } else {
      showUsageAndThrowUnsupportedOption(arg);
    }
  }
  try {
    process(zipFileName, dir, db, quiet);
  } catch (Exception e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

/**
 * Change the whitespace characters. The whitespace characters are used to
 * separate words. If indexes already exist at the time this list is
 * changed, reindex must be called.
 *
 * @param conn the connection
 * @param whitespaceChars the list of characters
 */
public static void setWhitespaceChars(Connection conn,
    String whitespaceChars) throws SQLException {
  try {
    init(conn);
    FullTextSettings setting = FullTextSettings.getInstance(conn);
    setting.setWhitespaceChars(whitespaceChars);
    PreparedStatement prep = conn.prepareStatement("MERGE INTO " +
        SCHEMA + ".SETTINGS VALUES(?, ?)");
    prep.setString(1, "whitespaceChars");
    prep.setString(2, whitespaceChars);
    prep.execute();
  } catch (DbException e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

/**
 * Change the ignore list. The ignore list is a comma separated list of
 * common words that must not be indexed. The default ignore list is empty.
 * If indexes already exist at the time this list is changed, reindex must
 * be called.
 *
 * @param conn the connection
 * @param commaSeparatedList the list
 */
public static void setIgnoreList(Connection conn, String commaSeparatedList)
    throws SQLException {
  try {
    init(conn);
    FullTextSettings setting = FullTextSettings.getInstance(conn);
    setIgnoreList(setting, commaSeparatedList);
    Statement stat = conn.createStatement();
    stat.execute("TRUNCATE TABLE " + SCHEMA + ".IGNORELIST");
    PreparedStatement prep = conn.prepareStatement("INSERT INTO " +
        SCHEMA + ".IGNORELIST VALUES(?)");
    prep.setString(1, commaSeparatedList);
    prep.execute();
  } catch (DbException e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

/**
 * Changes the password for a database. The passwords must be supplied as
 * char arrays and are cleaned in this method. The database must be closed
 * before calling this method.
 *
 * @param dir the directory (. for the current directory)
 * @param db the database name (null for all databases)
 * @param cipher the cipher (AES)
 * @param decryptPassword the decryption password as a char array
 * @param encryptPassword the encryption password as a char array
 * @param quiet don't print progress information
 */
public static void execute(String dir, String db, String cipher,
    char[] decryptPassword, char[] encryptPassword, boolean quiet)
    throws SQLException {
  try {
    new ChangeFileEncryption().process(dir, db, cipher,
        decryptPassword, encryptPassword, quiet);
  } catch (Exception e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

throw DbException.toSQLException(e);
throw DbException.toSQLException(e);
origin: com.h2database/h2

  process(dir, db, cipher, decryptPassword, encryptPassword, quiet);
} catch (Exception e) {
  throw DbException.toSQLException(e);
origin: com.h2database/h2

/**
 * Open a database connection.
 * This method should not be called by an application.
 * Instead, the method DriverManager.getConnection should be used.
 *
 * @param url the database URL
 * @param info the connection properties
 * @return the new connection or null if the URL is not supported
 */
@Override
public Connection connect(String url, Properties info) throws SQLException {
  try {
    if (info == null) {
      info = new Properties();
    }
    if (!acceptsURL(url)) {
      return null;
    }
    if (url.equals(DEFAULT_URL)) {
      return DEFAULT_CONNECTION.get();
    }
    Connection c = DbUpgrade.connectOrUpgrade(url, info);
    if (c != null) {
      return c;
    }
    return new JdbcConnection(url, info);
  } catch (Exception e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

throw DbException.toSQLException(e);
origin: com.h2database/h2

throw DbException.toSQLException(e);
origin: com.h2database/h2

/**
 * Log an exception and convert it to a SQL exception if required.
 *
 * @param ex the exception
 * @return the SQL exception object
 */
protected SQLException logAndConvert(Throwable ex) {
  SQLException e = null;
  try {
    e = DbException.toSQLException(ex);
    if (trace == null) {
      DbException.traceThrowable(e);
    } else {
      int errorCode = e.getErrorCode();
      if (errorCode >= 23000 && errorCode < 24000) {
        trace.info(e, "exception");
      } else {
        trace.error(e, "exception");
      }
    }
  } catch(Throwable ignore) {
    if (e == null) {
      e = new SQLException("", "HY000", ex);
    }
    e.addSuppressed(ignore);
  }
  return e;
}
origin: com.h2database/h2

  e.printStackTrace(out);
} else {
  throw DbException.toSQLException(e);
origin: com.h2database/h2

/**
 * Tries to start the server.
 * @return the server if successful
 * @throws SQLException if the server could not be started
 */
public Server start() throws SQLException {
  try {
    started = true;
    service.start();
    String name = service.getName() + " (" + service.getURL() + ")";
    Thread t = new Thread(this, name);
    t.setDaemon(service.isDaemon());
    t.start();
    for (int i = 1; i < 64; i += i) {
      wait(i);
      if (isRunning(false)) {
        return this;
      }
    }
    if (isRunning(true)) {
      return this;
    }
    throw DbException.get(ErrorCode.EXCEPTION_OPENING_PORT_2,
        name, "timeout; " +
        "please check your network configuration, specially the file /etc/hosts");
  } catch (DbException e) {
    throw DbException.toSQLException(e);
  }
}
origin: com.h2database/h2

private void sendErrorResponse(Exception re) throws IOException {
  SQLException e = DbException.toSQLException(re);
  server.traceError(e);
  startMessage('E');
  write('S');
  writeString("ERROR");
  write('C');
  writeString(e.getSQLState());
  write('M');
  writeString(e.getMessage());
  write('D');
  writeString(e.toString());
  write(0);
  sendMessage();
}
origin: com.h2database/h2

  throw DbException.toSQLException(e);
} finally {
  if (script != null) {
org.h2.messageDbExceptiontoSQLException

Javadoc

Convert an exception to a SQL exception using the default mapping.

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.
  • convertToIOException
    Convert an exception to an IO exception.
  • getCause
  • getErrorCode
    Get the error code.
  • getInvalidValueException
    Gets a SQL exception meaning this value is invalid.
  • getErrorCode,
  • getInvalidValueException,
  • getJdbcSQLException,
  • getMessage,
  • getSQLException,
  • getSource,
  • getSyntaxError,
  • printStackTrace,
  • setSource

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (Timer)
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • JFrame (javax.swing)
  • 21 Best IntelliJ 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