DEV Community

iron_man
iron_man

Posted on

PlanH


public Connection open(String schema, String alias) throws SQLException {
    return open(schema, alias, 30_000);
}

public Connection openForCompilation(String schema, String alias) throws SQLException {
    return open(schema, alias, 600_000); // 10 minutes
}

private Connection open(String schema, String alias, int readTimeoutMs) throws SQLException {
    if (!settings.credentialStrategy().equals("schema-name")) {
        throw new IllegalArgumentException(
                "Configure an approved credential strategy before using Oracle"
        );
    }

    String user = Identifiers.name(schema);

    Properties props = new Properties();
    props.setProperty("user", user);
    props.setProperty("password", user);
    props.setProperty("oracle.net.CONNECT_TIMEOUT", "5000");
    props.setProperty("oracle.jdbc.ReadTimeout", String.valueOf(readTimeoutMs));

    return DriverManager.getConnection(
            "jdbc:oracle:thin:@" + tns.resolve(alias),
            props
    );
}




try (Connection connection = factory.openForCompilation(schema(target), target.alias());



statement.setQueryTimeout(600);






Enter fullscreen mode Exit fullscreen mode

Top comments (0)