jdbc连接presto/trino,报错IllegalArgumentException: The datetime zone id ‘GMT+08:00‘ is not recognised

使用jdbc连接trino时遇到了一个报错:

java.lang.IllegalArgumentException: The datetime zone id 'GMT+08:00' is not recognised

 

官方github的issues给出了解决方案:

GMT+08:00 is accepted as a zone identifier by Java Time, but is not accepted by Joda Time, which we use internally for performance reasons.
Please use +08:00 instead.

 

所以需要在jdbc代码里改变datetime zone,

TimeZone.setDefault(TimeZone.getTimeZone("+08:00"));

 

附上我的完整代码:

Class.forName("io.trino.jdbc.TrinoDriver");
        TimeZone.setDefault(TimeZone.getTimeZone("+08:00"));
        String url = "jdbc:trino://192.168.2.90:8080";
        Properties properties = new Properties();
        properties.setProperty("user", "trino");
        properties.setProperty("password", "");
//        properties.setProperty("SSL", "true");
        Connection connection = DriverManager.getConnection(url, properties);
        Statement statement = connection.createStatement();
        String sql = "select * from myclickhouse.yisa_oe.student as a left join hive.default.student2 as b on a.id=b.id";
//        String sql = "select * from default.student2";
        ResultSet rs = statement.executeQuery(sql);
        while (rs.next()) {
            System.out.println(rs.getString(1) + " " + rs.getString(2) + " ||| " +
                    rs.getString(3) + " " + rs.getString(4));
        }

 

你可能感兴趣的:(大数据,presto)