JDBC sequential URL and its usage with singlestore-jdbc-client-1.2.1.jar

have any body used and give me an example of singlestore-jdbc-client-1.2.1.jar i want to enable a failover JDBC connection with my aggregator node as it will be promoted to Master incase of primary failure.

Hi,

An example of such a connection for simple cluster with 1 master and 1 leaf node could be the following:

master node: localhost:3306
leaf node: localhost:3307

        var dbUrl = "jdbc:singlestore:sequential://localhost:3306,localhost:3307/db";
        var properties = new Properties();
        properties.put("user", "root");
        properties.put("password", "root");
        properties.put("retriesAllDown", "10");//number of retries when all hosts are down (default is 120)
        try (com.singlestore.jdbc.Connection conn = (com.singlestore.jdbc.Connection) DriverManager.getConnection(dbUrl, properties)) {
            MultiPrimaryClient client = (MultiPrimaryClient) conn.getClient();
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT 1");
            while (rs.next()) {
                System.out.println(rs.getString(1));
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

When the connector tries to connect, it will always try host1 first (master). If that host is not available, then it will try host2 (leaf node). There is no logging, but you can debug MultiPrimaryClient#connectHost to investigate the behavior.