Class JDBCUtils

java.lang.Object
org.exoplatform.services.database.utils.JDBCUtils

public class JDBCUtils extends Object
Version:
$Id: JDBCUtils.java 34360 2009-07-22 23:58:59Z tolusha $
Author:
Anatoliy Bazko
  • Field Details

  • Method Details

    • tableExists

      public static boolean tableExists(String tableName, Connection con)
      Indicates whether or not a given table exists
      Parameters:
      tableName - the name of the table to check
      con - the connection to use
      Returns:
      true if it exists, false otherwise
    • getFullMessage

      public static String getFullMessage(SQLException exception)
      Retrieves the full message from SQLException.
      Parameters:
      exception - SQLException which will be parsed
    • cleanWhitespaces

      public static String cleanWhitespaces(String string)
      Replace whitespace characters with space character.
    • splitWithSQLDelimiter

      public static String[] splitWithSQLDelimiter(String resource)
      Split string resource with SQL Delimiter. Delimiter can be taken from resource at the begining of the first line. It surrounded with SQL_DELIMITER_COMMENT_PREFIX and SQL_DELIMITER_COMMENT_SUFFIX. Otherwise the default delimiter will be used SQL_DELIMITER.
    • getAppropriateBlobType

      public static String getAppropriateBlobType(DataSource dataSource) throws SQLException
      Returns appropriate blob type field for specific database.
      Throws:
      SQLException
    • getAppropriateTimestamp

      public static String getAppropriateTimestamp(DataSource dataSource) throws SQLException
      Returns appropriate timestamp type field for specific database.
      Throws:
      SQLException
    • getAppropriateCharType

      public static String getAppropriateCharType(DataSource dataSource) throws SQLException
      Returns appropriate char type field for specific database.
      Throws:
      SQLException
    • resolveDialect

      public static String resolveDialect(DataSource dataSource) throws SQLException
      Returns dialect one of dialect DialectConstants based on DataSource name.
      Throws:
      SQLException
    • freeResources

      public static void freeResources(ResultSet resultSet, Statement statement, Connection conn)
      Closes database related resources.