Class SQLManagerImpl

  • All Implemented Interfaces:
    SQLManager

    public class SQLManagerImpl
    extends java.lang.Object
    implements SQLManager
    • Field Detail

      • executorPool

        protected java.util.concurrent.ExecutorService executorPool
    • Constructor Detail

      • SQLManagerImpl

        public SQLManagerImpl​(@NotNull
                              @NotNull javax.sql.DataSource dataSource)
      • SQLManagerImpl

        public SQLManagerImpl​(@NotNull
                              @NotNull javax.sql.DataSource dataSource,
                              @Nullable
                              @Nullable java.lang.String name)
    • Method Detail

      • setDebugMode

        public void setDebugMode​(@NotNull
                                 @NotNull java.util.function.Supplier<@NotNull java.lang.Boolean> debugMode)
        Specified by:
        setDebugMode in interface SQLManager
      • debug

        public void debug​(java.lang.String msg)
      • getLogger

        public java.util.logging.Logger getLogger()
        Specified by:
        getLogger in interface SQLManager
      • getExecutorPool

        public java.util.concurrent.ExecutorService getExecutorPool()
      • getDataSource

        @NotNull
        public @NotNull javax.sql.DataSource getDataSource()
        Description copied from interface: SQLManager
        得到连接池源
        Specified by:
        getDataSource in interface SQLManager
        Returns:
        DataSource
      • getConnection

        @NotNull
        public @NotNull java.sql.Connection getConnection()
                                                   throws java.sql.SQLException
        Description copied from interface: SQLManager
        得到一个数据库连接实例
        Specified by:
        getConnection in interface SQLManager
        Returns:
        Connection
        Throws:
        java.sql.SQLException - 见 DataSource.getConnection()
      • getActiveQuery

        @NotNull
        public @NotNull java.util.Map<java.util.UUID,​SQLQuery> getActiveQuery()
        Description copied from interface: SQLManager
        得到正使用的查询。
        Specified by:
        getActiveQuery in interface SQLManager
        Returns:
        查询列表
      • executeSQL

        public java.lang.Integer executeSQL​(java.lang.String sql)
        Description copied from interface: SQLManager
        执行一条不需要返回结果的SQL语句(多用于UPDATE、REPLACE、DELETE方法) 该方法使用 Statement 实现,请注意SQL注入风险!
        Specified by:
        executeSQL in interface SQLManager
        Parameters:
        sql - SQL语句内容
        Returns:
        更新的行数
        See Also:
        SQLUpdateAction
      • executeSQL

        public java.lang.Integer executeSQL​(java.lang.String sql,
                                            java.lang.Object[] params)
        Description copied from interface: SQLManager
        执行一条不需要返回结果的预处理SQL更改(UPDATE、REPLACE、DELETE)
        Specified by:
        executeSQL in interface SQLManager
        Parameters:
        sql - SQL语句内容
        params - SQL语句中 ? 的对应参数
        Returns:
        更新的行数
        See Also:
        PreparedSQLUpdateAction
      • executeSQLBatch

        public java.util.List<java.lang.Integer> executeSQLBatch​(java.lang.String sql,
                                                                 java.lang.Iterable<java.lang.Object[]> paramsBatch)
        Description copied from interface: SQLManager
        执行多条不需要返回结果的SQL更改(UPDATE、REPLACE、DELETE)
        Specified by:
        executeSQLBatch in interface SQLManager
        Parameters:
        sql - SQL语句内容
        paramsBatch - SQL语句中对应?的参数组
        Returns:
        对应参数返回的行数
        See Also:
        PreparedSQLUpdateBatchAction
      • executeSQLBatch

        public java.util.List<java.lang.Integer> executeSQLBatch​(@NotNull
                                                                 @NotNull java.lang.String sql,
                                                                 java.lang.String... moreSQL)
        Description copied from interface: SQLManager
        执行多条不需要返回结果的SQL。 该方法使用 Statement 实现,请注意SQL注入风险!
        Specified by:
        executeSQLBatch in interface SQLManager
        Parameters:
        sql - SQL语句内容
        moreSQL - 更多SQL语句内容
        Returns:
        对应参数返回的行数
        See Also:
        SQLUpdateBatchAction
      • executeSQLBatch

        @Nullable
        public @Nullable java.util.List<java.lang.Integer> executeSQLBatch​(@NotNull
                                                                           @NotNull java.lang.Iterable<java.lang.String> sqlBatch)
        Description copied from interface: SQLManager
        执行多条不需要返回结果的SQL。
        Specified by:
        executeSQLBatch in interface SQLManager
        Parameters:
        sqlBatch - SQL语句内容
        Returns:
        对应参数返回的行数