Forward to mailing list for further support.

Thanks.




On 2/27/15, 12:01, "cc mac" <[email protected]> wrote:

> 
>
>@Test
>    public void testWithCubeData() throws SQLException,
>InstantiationException, IllegalAccessException, ClassNotFoundException {
>        Driver driver = (Driver)
>Class.forName("com.kylinolap.jdbc.Driver").newInstance();
>        Properties info = new Properties();
>        info.put("user", "ADMIN");
>        info.put("password", "KYLIN");
>        Connection conn =
>driver.connect("jdbc:kylin://localhost/default", info);
>
>        ResultSet catalogs = conn.getMetaData().getCatalogs();
>        while (catalogs.next()) {
>            System.out.println(catalogs.getString("TABLE_CAT"));
>        }
>
>        ResultSet schemas = conn.getMetaData().getSchemas();
>        while (schemas.next()) {
>            System.out.println(schemas.getString(1));
>            System.out.println(schemas.getString(2));
>        }
>
>        ResultSet tables = conn.getMetaData().getTables(null, null, null,
>null);
>        while (tables.next()) {
>            String tableName = tables.getString(3);
>            assertEquals(tables.getString("TABLE_NAME"), tableName);
>            ResultSet columns = conn.getMetaData().getColumns(null, null,
>tableName, null);
>
>            while (columns.next()) {
>                System.out.println(columns.getString("COLUMN_NAME"));
>                String column = "";
>                for (int i = 0; i < 23; i++) {
>                    column += columns.getString(i + 1) + ", ";
>                }
>
>                System.out.println("Column in table " + tableName + ": "
>+ column);
>            }
>        }
>
>        for (int j = 0; j < 3; j++) {
>            Statement state = conn.createStatement();
>            ResultSet resultSet = state.executeQuery("select * from
>test_kylin_fact");
>
>            ResultSetMetaData metadata = resultSet.getMetaData();
>            System.out.println("Metadata:");
>
>            for (int i = 0; i < metadata.getColumnCount(); i++) {
>                String metaStr = metadata.getCatalogName(i + 1) + " " +
>metadata.getColumnClassName(i + 1) + " " +
>metadata.getColumnDisplaySize(i + 1) + " " + metadata.getColumnLabel(i +
>1) + " " + metadata.getColumnName(i + 1) + " " + metadata.getColumnType(i
>+ 1) + " " + metadata.getColumnTypeName(i + 1) + " " +
>metadata.getPrecision(i + 1) + " " + metadata.getScale(i + 1) + " " +
>metadata.getSchemaName(i + 1) + " " + metadata.getTableName(i + 1);
>                System.out.println(metaStr);
>            }
>
>            System.out.println("Data:");
>            while (resultSet.next()) {
>                String dataStr = resultSet.getFloat(1) + " " +
>resultSet.getInt(2) + " " + resultSet.getInt(3) + " " +
>resultSet.getLong(4) + " " + resultSet.getDate(5) + " " +
>resultSet.getString(6);
>                System.out.println(dataStr);
>            }
>        }
>    }

Reply via email to