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

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

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

import org.h2.tools.SimpleResultSet;
import org.h2.value.DataType;
import org.h2.value.Value;

import java.sql.ResultSet;

public class ResultSets {
    public static void addColumn(SimpleResultSet rs, String name) {
        rs.addColumn(name, DataType.convertTypeToSQLType(Value.STRING), 0, 0);
    }

    public static void addColumns(SimpleResultSet rs, String... names) {
        for (String name : names) {
            rs.addColumn(name, DataType.convertTypeToSQLType(Value.STRING), 0, 0);
        }
    }

    public static void addColumns(SimpleResultSet rs, Iterable names) {
        for (String name : names) {
            rs.addColumn(name, DataType.convertTypeToSQLType(Value.STRING), 0, 0);
        }
    }

    public static ResultSet newResultSet() {
        SimpleResultSet rs = new SimpleResultSet();
        rs.setAutoClose(false);
        return rs;
    }

    public static SimpleResultSet newSimpleResultSet() {
        SimpleResultSet rs = new SimpleResultSet();
        rs.setAutoClose(false);
        return rs;
    }

    public static SimpleResultSet newSimpleResultSet(Iterable names) {
        SimpleResultSet rs = newSimpleResultSet();
        rs.setAutoClose(false);
        addColumns(rs, names);
        return rs;
    }

    public static SimpleResultSet newSimpleResultSet(String... names) {
        SimpleResultSet rs = newSimpleResultSet();
        rs.setAutoClose(false);
        addColumns(rs, names);
        return rs;
    }

    public static SimpleResultSet newSimpleResultSet(int columnCount) {
        SimpleResultSet rs = newSimpleResultSet();
        rs.setAutoClose(false);
        for (int i = 0; i < columnCount; i++) {
            addColumns(rs, "C" + (i + 1));
        }
        return rs;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy