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

com.undefinedlabs.scope.rules.sql.provider.internal.PreparedStatementQueryUtils Maven / Gradle / Ivy

Go to download

Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly identify, troubleshoot and fix failed builds. This artifact contains the classes to instrument the Java SQL package.

There is a newer version: 0.15.1-beta.2
Show newest version
package com.undefinedlabs.scope.rules.sql.provider.internal;

import com.undefinedlabs.scope.rules.sql.model.PreparedStatementQueryParameter;
import com.undefinedlabs.scope.tracing.sender.internal.serializers.ObjectMapperFactory;

import java.io.IOException;
import java.util.Map;

public enum PreparedStatementQueryUtils {

    INSTANCE;

    public String generateParamKey(final int sqlParamIndex) {
        return "?".concat(String.valueOf(sqlParamIndex));
    }

    public String extractSqlMethod(final String sqlStatement) {
        final String[] chuncks = sqlStatement.split(" ", 2);
        return chuncks.length > 0 ? chuncks[0] : "";
    }

    public String generateSqlParamsAsString(final Map map) {
        try {
            return ObjectMapperFactory.newConfiguredObjectMapper().writeValueAsString(map);
        } catch(IOException e){
            throw new RuntimeException(e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy