From 38ccefb312be0eb0490247b4f11b7a3cfbccaa3b Mon Sep 17 00:00:00 2001 From: vgmartinez Date: Thu, 4 Feb 2016 15:39:21 +0100 Subject: [PATCH 1/8] docs for jdbc --- .../themes/zeppelin/_navigation.html | 1 + docs/interpreter/jdbc.md | 224 ++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 docs/interpreter/jdbc.md diff --git a/docs/_includes/themes/zeppelin/_navigation.html b/docs/_includes/themes/zeppelin/_navigation.html index ed543361bd5..a18e6296680 100644 --- a/docs/_includes/themes/zeppelin/_navigation.html +++ b/docs/_includes/themes/zeppelin/_navigation.html @@ -44,6 +44,7 @@
  • Geode
  • HBase
  • Hive
  • +
  • JDBC
  • Ignite
  • Lens
  • Markdown
  • diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md new file mode 100644 index 00000000000..7742dacc1a7 --- /dev/null +++ b/docs/interpreter/jdbc.md @@ -0,0 +1,224 @@ +--- +layout: page +title: "Generic JDBC Interpreter" +description: "JDBC user guide" +group: manual +--- +{% include JB/setup %} + + +## Generic JDBC Interpreter for Apache Zeppelin + +This interpreter lets you create a JDBC connection to any data source, by now it has been tested with: + +* Postgres +* MySql +* MariaDB +* Redshift +* Hive + +If someone else used another database please report how it works to improve functionality. + +### Create Interpreter + +When create a interpreter by default use PostgreSQL with the next properties: + + + + + + + + + + + + + + + + + + + + + + + + + + +
    namevalue
    common.max_count1000
    default.driverorg.postgresql.Driver
    default.password`********`
    default.driver.namejdbc:postgresql://localhost:5432/
    default.usergpadmin
    + +Is not necessary add jar driver to the classpath for PostgreSQL. + +#### Simple connection + +Before creating the interpreter it is necessary to add to the Zeppelin classpath the path of the JDBC you want to use, to do it you must edit the file `zeppelin-daemon.sh` as shown in the table: + +``` +# Add jdbc connector jar +ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/jdbc/jars/mysql-connector-java-5.1.6.jar" +``` + +For create the interpreter you need to specify connection parameters as shown in the table. + + + + + + + + + + + + + + + + + + + + + + + + + + +
    namevalue
    common.max_count1000
    {prefix}.driverdriver name
    {prefix}.password`********`
    {prefix}.driver.namejdbc url
    {prefix}.useruser name
    + +#### Multiple connections + +This JDBC interpreter also allows connections to multiple data sources. For every connection is necessary a prefix for reference in the paragraph this way `%jdbc(prefix)`. Before creating the interpreter it is necessary to add to the Zeppelin classpath all paths to access to each driver's jar file you want to use, to do it you must edit the file `zeppelin-daemon.sh` as following: + +``` +# Add jdbc connector jar +ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/jdbc/jars/RedshiftJDBC41-1.1.10.1010.jar" +ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/jdbc/jars/mysql-connector-java-5.1.6.jar" +``` +You can add all the jars you need to make multiple connections into the same interpreter. To create the interpreter you must specify the parameters, for example we will create two connections to PostgreSQL and Redshift, the respective prefixes are `default` and `redshift`: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    namevalue
    common.max_count1000
    default.driverorg.postgresql.Driver
    default.password`********`
    default.urljdbc:postgresql://localhost:5432/
    default.usergpadmin
    redshift.drivercom.amazon.redshift.jdbc4.Driver
    redshift.password`********`
    redshift.urljdbc:redshift://examplecluster.abc123xyz789.us-west-2.redshift.amazonaws.com:5439
    redshift.userredshift-user
    + + +### Bind to Notebook +In the `Notebook` click on the `settings` icon at the top-right corner. Use select/deselect to specify the interpreters to be used in the `Notebook`. + +### More Properties +You can modify the interpreter configuration in the `Interpreter` section. The most common properties are as follows, but you can specify other properties that need to be connected. + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Property NameDescription
    {prefix}.urlJDBC URL to connect, the URL must include the name of the database
    {prefix}.userJDBC user name
    {prefix}.passwordJDBC password
    {prefix}.driver.nameJDBC driver name.
    common.max_resultMax number of SQL result to display to prevent the browser overload. This is common properties for all connections
    + +To develop this functionality use this [method](http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.util.Properties). For example if a connection needs a schema parameter, it would have to add the property as follows: + + + + + + + + + + +
    namevalue
    {prefix}.schemaschema_name
    + +### How to use + +#### Reference in paragraph + +Start the paragraphs with the `%jdbc`, this will use the `default` prefix for connection. If you want to use other connection you should specify the prefix of it as follows `%jdbc(prefix)`: + +```sql +%jdbc +SELECT * FROM db_name; + +``` +or +```sql +%jdbc(prefix) +SELECT * FROM db_name; + +``` + +#### Apply Zeppelin Dynamic Forms + +You can leverage [Zeppelin Dynamic Form](../manual/dynamicform.html) inside your queries. You can use both the `text input` and `select form` parametrization features + +```sql +%jdbc(prefix) +SELECT name, country, performer +FROM demo.performers +WHERE name='{{performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}}' +``` + +### Bugs & Contacts +If you find a bug for this interpreter, please create a [JIRA]( https://issues.apache.org/jira/browse/ZEPPELIN-382?jql=project%20%3D%20ZEPPELIN) ticket. From e3653ba4fc109733619277770760505a6766eff1 Mon Sep 17 00:00:00 2001 From: vgmartinez Date: Thu, 4 Feb 2016 15:46:22 +0100 Subject: [PATCH 2/8] fix dead link --- docs/interpreter/jdbc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md index 7742dacc1a7..1c1191fcf17 100644 --- a/docs/interpreter/jdbc.md +++ b/docs/interpreter/jdbc.md @@ -178,7 +178,7 @@ You can modify the interpreter configuration in the `Interpreter` section. The m -To develop this functionality use this [method](http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.util.Properties). For example if a connection needs a schema parameter, it would have to add the property as follows: +To develop this functionality use this [method](http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.util.Properties)). For example if a connection needs a schema parameter, it would have to add the property as follows: From f9f194ecc69074c6aa77c2c5d1aebf1e277ce7b3 Mon Sep 17 00:00:00 2001 From: Victor Manuel Date: Thu, 4 Feb 2016 18:36:22 +0100 Subject: [PATCH 3/8] Update jdbc.md change bad name in property --- docs/interpreter/jdbc.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md index 1c1191fcf17..502dbc5e6ba 100644 --- a/docs/interpreter/jdbc.md +++ b/docs/interpreter/jdbc.md @@ -41,7 +41,7 @@ When create a interpreter by default use PostgreSQL with the next properties: - + @@ -81,7 +81,7 @@ For create the interpreter you need to specify connection parameters as shown in - + @@ -169,7 +169,7 @@ You can modify the interpreter configuration in the `Interpreter` section. The m - + From b973022741a4d3c338e8a66447db5567555f9644 Mon Sep 17 00:00:00 2001 From: Victor Manuel Date: Thu, 4 Feb 2016 22:43:07 +0100 Subject: [PATCH 4/8] change order in link --- docs/_includes/themes/zeppelin/_navigation.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_includes/themes/zeppelin/_navigation.html b/docs/_includes/themes/zeppelin/_navigation.html index a18e6296680..4633b09bb7d 100644 --- a/docs/_includes/themes/zeppelin/_navigation.html +++ b/docs/_includes/themes/zeppelin/_navigation.html @@ -44,8 +44,8 @@
  • Geode
  • HBase
  • Hive
  • -
  • JDBC
  • Ignite
  • +
  • JDBC
  • Lens
  • Markdown
  • Postgresql, hawq
  • From d92d7d85f429a7f6ae5fe509493e5f88f2f90c20 Mon Sep 17 00:00:00 2001 From: Victor Manuel Date: Thu, 4 Feb 2016 22:45:41 +0100 Subject: [PATCH 5/8] add default prefix in simple connection --- docs/interpreter/jdbc.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md index 502dbc5e6ba..b4fd862018e 100644 --- a/docs/interpreter/jdbc.md +++ b/docs/interpreter/jdbc.md @@ -73,19 +73,19 @@ For create the interpreter you need to specify connection parameters as shown in
    - + - + - + - +
    `********`
    default.driver.namedefault.url jdbc:postgresql://localhost:5432/
    `********`
    {prefix}.driver.name{prefix}.url jdbc url
    JDBC password
    {prefix}.driver.name{prefix}.driver JDBC driver name.
    1000
    {prefix}.driverdefault.driver driver name
    {prefix}.passworddefault.password `********`
    {prefix}.urldefault.url jdbc url
    {prefix}.userdefault.user user name
    From cd600200a36e1c248a9e1714305cbb94f7c15fb2 Mon Sep 17 00:00:00 2001 From: Victor Manuel Date: Sun, 7 Feb 2016 12:58:07 +0100 Subject: [PATCH 6/8] delete parentheses... --- docs/interpreter/jdbc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md index b4fd862018e..f1305ff6cfa 100644 --- a/docs/interpreter/jdbc.md +++ b/docs/interpreter/jdbc.md @@ -178,7 +178,7 @@ You can modify the interpreter configuration in the `Interpreter` section. The m -To develop this functionality use this [method](http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.util.Properties)). For example if a connection needs a schema parameter, it would have to add the property as follows: +To develop this functionality use this [method](http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection%28java.lang.String,%20java.util.Properties%29). For example if a connection needs a schema parameter, it would have to add the property as follows: From cee96a69a75117640d3f45b401ee97d672a373d5 Mon Sep 17 00:00:00 2001 From: Victor Manuel Date: Mon, 8 Feb 2016 09:28:28 +0100 Subject: [PATCH 7/8] fix docs and add more details --- docs/interpreter/jdbc.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md index f1305ff6cfa..713d81af041 100644 --- a/docs/interpreter/jdbc.md +++ b/docs/interpreter/jdbc.md @@ -38,7 +38,7 @@ When create a interpreter by default use PostgreSQL with the next properties: - + @@ -50,11 +50,11 @@ When create a interpreter by default use PostgreSQL with the next properties:
    default.password`********`********
    default.url
    -Is not necessary add jar driver to the classpath for PostgreSQL. +Is not necessary add jar driver to the classpath for PostgreSQL or similar. #### Simple connection -Before creating the interpreter it is necessary to add to the Zeppelin classpath the path of the JDBC you want to use, to do it you must edit the file `zeppelin-daemon.sh` as shown in the table: +Before creating the interpreter it is necessary to add to the Zeppelin classpath the path of the JDBC you want to use, to do it you must edit the file `zeppelin-daemon.sh` as shown: ``` # Add jdbc connector jar @@ -78,7 +78,7 @@ For create the interpreter you need to specify connection parameters as shown in default.password - `********` + ******** default.url @@ -116,7 +116,7 @@ You can add all the jars you need to make multiple connections into the same int default.password - `********` + ******** default.url @@ -132,7 +132,7 @@ You can add all the jars you need to make multiple connections into the same int redshift.password - `********` + ******** redshift.url From f9cf4768463800909fb576cfe201ce7b009c1d4e Mon Sep 17 00:00:00 2001 From: Victor Manuel Date: Tue, 9 Feb 2016 00:25:17 +0100 Subject: [PATCH 8/8] Fix comment --- docs/interpreter/jdbc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md index 713d81af041..1099f69794d 100644 --- a/docs/interpreter/jdbc.md +++ b/docs/interpreter/jdbc.md @@ -50,7 +50,7 @@ When create a interpreter by default use PostgreSQL with the next properties: -Is not necessary add jar driver to the classpath for PostgreSQL or similar. +It is not necessary to add driver jar to the classpath for PostgreSQL as it is included in Zeppelin. #### Simple connection