All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.centit.support.database.utils.QueryLogUtils Maven / Gradle / Ivy

Go to download

数据库操作通用方法和函数,从以前的util包中分离出来,并且整合了部分sys-module中的函数

There is a newer version: 5.3.2302
Show newest version
package com.centit.support.database.utils;

import com.alibaba.fastjson.JSON;
import com.centit.support.algorithm.DatetimeOpt;
import org.slf4j.Logger;

public abstract class QueryLogUtils {

    private QueryLogUtils() {
        throw new IllegalAccessError("Utility class");
    }

    public static boolean jdbcShowSql = false;
    public static boolean userLog4jInfo = true;

    public static void setUserLog4j(boolean userLog4j) {
        QueryLogUtils.userLog4jInfo = userLog4j;
    }

    public static void setJdbcShowSql(boolean jdbcShowSql) {
        QueryLogUtils.jdbcShowSql = jdbcShowSql;
    }

    public static void printSql(Logger logger, String sql){
        if(jdbcShowSql) {
            if(userLog4jInfo) {
                logger.info(sql );
            }else{
                System.out.println(DatetimeOpt.currentDatetime()
                        + " 语句: "+ sql);
            }
        }
    }

    public static void printSql(Logger logger, String sql, Object param){
        if(jdbcShowSql) {
            if(userLog4jInfo) {
                logger.info(sql + ":" + JSON.toJSONString(param));
            }else{
                System.out.println(DatetimeOpt.currentDatetime()+ " 语句: "+
                        sql + "参数为: "+JSON.toJSONString(param) );
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy