Repository: kylin Updated Branches: refs/heads/document 2a282eeb8 -> 770287871
added Chinese version of howto_jdbc Signed-off-by: Billy Liu <billy...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/77028787 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/77028787 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/77028787 Branch: refs/heads/document Commit: 77028787153a153116d5aefe7b43342f8ad027ca Parents: 59d169c Author: link3280 <491325...@qq.com> Authored: Sun Oct 22 14:09:35 2017 +0800 Committer: Billy Liu <billy...@apache.org> Committed: Fri Jan 26 13:09:53 2018 +0800 ---------------------------------------------------------------------- website/_docs21/howto/howto_jdbc.cn.md | 92 +++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/77028787/website/_docs21/howto/howto_jdbc.cn.md ---------------------------------------------------------------------- diff --git a/website/_docs21/howto/howto_jdbc.cn.md b/website/_docs21/howto/howto_jdbc.cn.md new file mode 100644 index 0000000..bd137be --- /dev/null +++ b/website/_docs21/howto/howto_jdbc.cn.md @@ -0,0 +1,92 @@ +--- +layout: docs21 +title: Kylin JDBC Driver +categories: å¸®å© +permalink: /cn/docs21/howto/howto_jdbc.html +--- + +### è®¤è¯ + +###### åºäºApache Kylin认è¯RESTFULæå¡ãæ¯æçåæ°ï¼ +* user : ç¨æ·å +* password : å¯ç +* ssl: trueæfalseã é»è®¤ä¸ºflasï¼å¦æä¸ºtrueï¼ææçæå¡è°ç¨é½ä¼ä½¿ç¨httpsã + +### è¿æ¥urlæ ¼å¼ï¼ +{% highlight Groff markup %} +jdbc:kylin://<hostname>:<port>/<kylin_project_name> +{% endhighlight %} +* 妿âsslâ为trueï¼âportâåºè¯¥æ¯Kylin serverçHTTPS端å£ã +* 妿âportâæªè¢«æå®ï¼driverä¼ä½¿ç¨é»è®¤ç端å£ï¼HTTP 80ï¼HTTPS 443ã +* å¿ é¡»æå®âkylin_project_nameâå¹¶ä¸ç¨æ·éè¦ç¡®ä¿å®å¨Kylin serverä¸åå¨ã + +### 1. 使ç¨Statementæ¥è¯¢ +{% highlight Groff markup %} +Driver driver = (Driver) Class.forName("org.apache.kylin.jdbc.Driver").newInstance(); + +Properties info = new Properties(); +info.put("user", "ADMIN"); +info.put("password", "KYLIN"); +Connection conn = driver.connect("jdbc:kylin://localhost:7070/kylin_project_name", info); +Statement state = conn.createStatement(); +ResultSet resultSet = state.executeQuery("select * from test_table"); + +while (resultSet.next()) { + assertEquals("foo", resultSet.getString(1)); + assertEquals("bar", resultSet.getString(2)); + assertEquals("tool", resultSet.getString(3)); +} +{% endhighlight %} + +### 2. 使ç¨PreparedStatementvæ¥è¯¢ + +###### æ¯æçPreparedStatementåæ°ï¼ +* setString +* setInt +* setShort +* setLong +* setFloat +* setDouble +* setBoolean +* setByte +* setDate +* setTime +* setTimestamp + +{% highlight Groff markup %} +Driver driver = (Driver) Class.forName("org.apache.kylin.jdbc.Driver").newInstance(); +Properties info = new Properties(); +info.put("user", "ADMIN"); +info.put("password", "KYLIN"); +Connection conn = driver.connect("jdbc:kylin://localhost:7070/kylin_project_name", info); +PreparedStatement state = conn.prepareStatement("select * from test_table where id=?"); +state.setInt(1, 10); +ResultSet resultSet = state.executeQuery(); + +while (resultSet.next()) { + assertEquals("foo", resultSet.getString(1)); + assertEquals("bar", resultSet.getString(2)); + assertEquals("tool", resultSet.getString(3)); +} +{% endhighlight %} + +### 3. è·åæ¥è¯¢ç»æå æ°æ® +Kylin jdbc driveræ¯æå æ°æ®åè¡¨æ¹æ³ï¼ +éè¿sql模å¼è¿æ»¤å¨ï¼æ¯å¦ %ï¼ååºcatalogãschemaãtableåcolumnã + +{% highlight Groff markup %} +Driver driver = (Driver) Class.forName("org.apache.kylin.jdbc.Driver").newInstance(); +Properties info = new Properties(); +info.put("user", "ADMIN"); +info.put("password", "KYLIN"); +Connection conn = driver.connect("jdbc:kylin://localhost:7070/kylin_project_name", info); +Statement state = conn.createStatement(); +ResultSet resultSet = state.executeQuery("select * from test_table"); + +ResultSet tables = conn.getMetaData().getTables(null, null, "dummy", null); +while (tables.next()) { + for (int i = 0; i < 10; i++) { + assertEquals("dummy", tables.getString(i + 1)); + } +} +{% endhighlight %}