Class JdbcUtils

java.lang.Object
scriptella.jdbc.JdbcUtils

public final class JdbcUtils extends Object
Utility class JDBC related operations.
Version:
1.0
Author:
Fyodor Kupolov
  • Method Details

    • getUrlDescription

      public static String getUrlDescription(URL url)
      Returns a credential-safe description of an input/output URL. Only the protocol is included; authority, path, query and fragment are omitted.
      Parameters:
      url - resolved URL, or null for console I/O
      Returns:
      a source description without connection details
    • sanitize

      public static Throwable sanitize(Throwable source, URL url)
      Copies an exception graph with source URL credentials removed from messages. Causes, suppressed exceptions, stack traces and SQL diagnostics are retained; repeated/cyclic references never attach an original exception to the copy.
      Parameters:
      source - exception to report
      url - source URL, or null for console I/O
      Returns:
      sanitized diagnostic copy
    • closeSilent

      public static void closeSilent(Connection con)
      Silently closes a connection.
      Parameters:
      con - connection to close. Nulls allowed.
    • closeSilent

      public static void closeSilent(Statement s)
      Silently closes a statement.
      Parameters:
      s - statement to close. Nulls allowed.
    • closeSilent

      public static void closeSilent(ResultSet rs)
      Silently closes a result set.
      Parameters:
      rs - result set to close. Nulls allowed.