Module bus.pager

Class Early

java.lang.Object
org.miaixz.bus.pager.dialect.auto.Early
All Implemented Interfaces:
AutoDialect<String>

public class Early extends Object implements AutoDialect<String>
Early version default implementation for auto-detecting database dialects. This approach involves obtaining a connection to extract the JDBC URL, which is highly generic but can be less performant and may lead to issues if connections are not properly closed.
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • DEFAULT

      public static final AutoDialect<String> DEFAULT
      Default instance of the Early auto-dialect.
  • Constructor Details

    • Early

      public Early()
  • Method Details

    • extractDialectKey

      public String extractDialectKey(org.apache.ibatis.mapping.MappedStatement ms, DataSource dataSource, Properties properties)
      Extracts the dialect key (JDBC URL) from the DataSource by obtaining a connection. This method is generic but can be less efficient due to connection handling.
      Specified by:
      extractDialectKey in interface AutoDialect<String>
      Parameters:
      ms - the MappedStatement being executed
      dataSource - the DataSource associated with the MappedStatement
      properties - the configuration properties, including "closeConn" to control connection closing
      Returns:
      the JDBC URL as the dialect key
      Throws:
      org.miaixz.bus.core.lang.exception.PageException - if a SQLException occurs while getting the connection or its metadata
    • extractDialect

      public AbstractPaging extractDialect(String dialectKey, org.apache.ibatis.mapping.MappedStatement ms, DataSource dataSource, Properties properties)
      Extracts and returns the appropriate AbstractPaging dialect based on the extracted JDBC URL.
      Specified by:
      extractDialect in interface AutoDialect<String>
      Parameters:
      dialectKey - the JDBC URL obtained from extractDialectKey(org.apache.ibatis.mapping.MappedStatement, javax.sql.DataSource, java.util.Properties)
      ms - the MappedStatement being executed
      dataSource - the DataSource associated with the MappedStatement
      properties - the configuration properties
      Returns:
      an instance of AbstractPaging representing the determined dialect
      Throws:
      org.miaixz.bus.core.lang.exception.PageException - if the database type cannot be automatically obtained or if dialect instantiation fails