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

ai.platon.pulsar.ql.common.H2Config Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package ai.platon.pulsar.ql.common;

import org.h2.engine.SysProperties;
import org.h2.util.JdbcUtils;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Custom H2 config, must be called on both server and client side
 * */
public class H2Config {
    private static AtomicBoolean configured = new AtomicBoolean();

    public static void config() {
        if (configured.getAndSet(true)) {
            return;
        }

        // From java doc:
        // "On the client side, this setting is required to be disabled"
        SysProperties.serializeJavaObject = false;
        JdbcUtils.serializer = new PulsarObjectSerializer();

        String dataTypeHandler = System.getProperty("h2.customDataTypesHandler");
        if (dataTypeHandler == null) {
            JdbcUtils.customDataTypesHandler = new PulsarDataTypesHandler();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy