Package lumis.util

Class JdbcUtil


  • public class JdbcUtil
    extends java.lang.Object
    Utility class for JDBC operations.
    Since:
    4.0.0
    Version:
    $Revision: 24813 $ $Date: 2022-01-19 00:05:05 -0300 (Wed, 19 Jan 2022) $
    • Constructor Summary

      Constructors 
      Constructor Description
      JdbcUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.util.List<java.lang.String> fillListString​(java.sql.PreparedStatement statement, java.lang.String fieldName)  
      static java.lang.String[] fillStringArray​(java.sql.PreparedStatement statement, java.lang.String fieldName)  
      static java.lang.String generateInClause​(int numItems)
      Deprecated.
      Since 4.2.2.090330 replaced by generateInClause(String, int).
      static java.lang.String generateInClause​(java.lang.String fieldName, int numItems)
      Generates a SQL IN statement for a field.
      static java.lang.String generateInlineInClause​(java.lang.String fieldName, java.util.Collection<java.lang.String> values)
      Generates a SQL IN statement for a field.
      static java.sql.Timestamp getTimestampByDate​(java.util.Date data)  
      static java.lang.String prepareLargeTextCompareField​(java.lang.String fieldName)
      Properly convert SQL Text fields for comparisons in queries.
      The following conversions apply: Oracle: to_char(fieldName) MSSQL: convert(nvarchar(MAX), fieldName) For all other Databases the fieldName is returned.
      static java.lang.String prepareQueryParameter​(java.lang.String parameter)  
      static void setLargeFetchSize​(java.sql.Statement statement)
      Sets a statement's fetch size to a standard large value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JdbcUtil

        public JdbcUtil()
    • Method Detail

      • prepareQueryParameter

        public static java.lang.String prepareQueryParameter​(java.lang.String parameter)
                                                      throws PortalException
        Throws:
        PortalException
      • getTimestampByDate

        public static java.sql.Timestamp getTimestampByDate​(java.util.Date data)
      • fillStringArray

        public static java.lang.String[] fillStringArray​(java.sql.PreparedStatement statement,
                                                         java.lang.String fieldName)
                                                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • fillListString

        public static java.util.List<java.lang.String> fillListString​(java.sql.PreparedStatement statement,
                                                                      java.lang.String fieldName)
                                                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • generateInClause

        @Deprecated
        public static java.lang.String generateInClause​(int numItems)
        Deprecated.
        Since 4.2.2.090330 replaced by generateInClause(String, int).
      • generateInClause

        public static java.lang.String generateInClause​(java.lang.String fieldName,
                                                        int numItems)
        Generates a SQL IN statement for a field. The IN statement is generated using ? for each parameter, according to the numItems argument.
        Parameters:
        fieldName - the field operand before the IN operator (e.g.: columnName or table.column).
        numItems - the number of parameters to be included in the IN statement.
        Returns:
        the SQL code fragment for the IN statement.
        Since:
        4.2.2.090330
      • generateInlineInClause

        public static java.lang.String generateInlineInClause​(java.lang.String fieldName,
                                                              java.util.Collection<java.lang.String> values)
                                                       throws PortalException
        Generates a SQL IN statement for a field. The IN statement is generated using in-line value for each item, according to the values argument.
        Parameters:
        fieldName - the field operand before the IN operator (e.g.: columnName or table.column).
        values - the values to be included in the IN statement.
        Returns:
        the SQL code fragment for the IN statement.
        Throws:
        PortalException
        Since:
        10.3.0
      • setLargeFetchSize

        public static void setLargeFetchSize​(java.sql.Statement statement)
                                      throws java.sql.SQLException
        Sets a statement's fetch size to a standard large value.
        Parameters:
        statement - the statement.
        Throws:
        java.sql.SQLException - if an thrown by the JDBC driver.
        Since:
        10.0.0
      • prepareLargeTextCompareField

        public static java.lang.String prepareLargeTextCompareField​(java.lang.String fieldName)
        Properly convert SQL Text fields for comparisons in queries.
          The following conversions apply:
        • Oracle: to_char(fieldName)
        • MSSQL: convert(nvarchar(MAX), fieldName)
        • For all other Databases the fieldName is returned.
        Parameters:
        fieldName - the name of the field to be wrapped in the conversion statement, including the table aliases.
        Returns:
        The fieldName wrapped in the conversion statement when applicable
        Since:
        10.0.0