THank you for reporting. Could you check the kylin.log first?
2017-08-21 11:15 GMT+08:00 程 万胜 <[email protected]>:
>
> 大家好:
>
> 用kylin的JDBC查询,查询条件是date类型的,如果通过prepareStatement、setDate是查询不出数据
> 的,然而直接用SQL可以查出数据
>
> 我用的是kylin版本:apache-kylin-1.6.0-cdh5.7-bin,jdbc版本:kylin-jdbc-1.6.0.jar
> ,java版本:java version "1.8.0_92"
>
>
> 代码1
>
> Driver driver = (Driver) Class.forName("org.apache.
> kylin.jdbc.Driver").newInstance();
>
> Properties info = new Properties();
> info.put("user", "xxx");
> info.put("password", "xxx");
> Connection conn = driver.connect("jdbc:kylin://xxx/learn_kylin",
> info);
> PreparedStatement state = conn.prepareStatement(
> "select " + "part_dt, sum(price) as total_selled,
> count(distinct seller_id) as sellers "
> + "from kylin_sales where part_dt <= '2013-01-01'
> " + "group by part_dt " + "order by part_dt limit 100");
>
> ResultSet resultSet = state.executeQuery();
> System.out.print("结果:");
> while (resultSet.next()) {
> System.out.print(resultSet.getString(1) + "\n");
> }
>
> 运行结果
>
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
> details.
> 结果:2011-12-31
> 2012-01-01
> 2012-01-02
> 2012-01-03
> 2012-01-04
> 2012-01-05
> 2012-01-06
> 2012-01-07
> 2012-01-08
> 2012-01-09
>
> 代码2
>
> Driver driver = (Driver) Class.forName("org.apache.
> kylin.jdbc.Driver").newInstance();
>
> Properties info = new Properties();
> info.put("user", "xxx");
> info.put("password", "xxx");
> Connection conn = driver.connect("jdbc:kylin://xxx/learn_kylin",
> info);
> PreparedStatement state = conn.prepareStatement(
> "select " + "part_dt, sum(price) as total_selled,
> count(distinct seller_id) as sellers "
> + "from kylin_sales where part_dt <= ? " + "group
> by part_dt " + "order by part_dt limit 100");
> SimpleDateFormat simpleTime = new SimpleDateFormat("yyyy-MM-dd");
> java.util.Date passUtilDate = simpleTime.parse("2013-01-01");
> java.sql.Date passSqlDate = new java.sql.Date(passUtilDate.
> getTime());
> System.out.print("条件是:" + passSqlDate + "\n");
> state.setDate(1, passSqlDate);
>
> ResultSet resultSet = state.executeQuery();
> System.out.print("结果:");
> while (resultSet.next()) {
> System.out.print(resultSet.getString(1) + "\n");
> }
>
> 运行结果
>
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
> details.
> 条件是:2013-01-01
> 结果:
>
>
>
>
>