CData Software hands-on (getting kintone data from Java console application)

CData product to use

Check Java runtime environment

Execute the following command from PowerShell or DOS to check the Java execution environment.

PS C:\> java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

If it is not installed, please download and install the JDK from the link below.

Install CData kintone JDBC Driver

Download the evaluation build from the following site.

Launch the "setup.jar" file in the downloaded ZIP file. (Note) Since online activation will be executed on the way, please do so in an environment where you can access the Internet.

The following installer will start, so check the license agreement and proceed with the installation with the default settings to complete.

image.png

When the installation is complete, the default browser will launch and the product help file will launch. image.png

Registration in system environment variables

Register the bin folder of the installed JDK in the system environment variables.

(Reference) Setting system environment variables "Control Panel> System and Security> System> Advanced System Settings> System Properties> Environment Variables"

Variable name value
Path C:\Program Files\Java\jdk1.8.0_152\bin

(Note) Change the folder name of the JDK to any installed version. (Note) After registering the environment variables, restart PowerShell or DOS. In that case, please start with "Run as administrator".

If you execute the following command from PowerShell or DOS, javac command help will be displayed. You have successfully registered in the system environment variables.

PS C:\> javac
how to use: javac <options> <source files>
The available options are:
  -g Generate all debug information
  -g:none Do not generate debug information
    〜 (abridgement) 〜
  -Quit compilation if Werror warning occurs
  @<filename>Read from file options and filename
PS C:\>

Check Java sample console program

The Java console program "DataBrowser.java" is stored in "" C: \ Program Files \ CData \ CData JDBC Driver for kintone 2017J \ demos \ console \ databrowser "" under the default installation path of CData products. If you check the contents with an editor etc., a little less than 400 lines of Java sample code is stored. This time, I will run this program that can execute SQL from the console.

Compiling Java programs

Change to the directory where "DataBrowser.java" is stored and compile with the javac command. Since this sample program uses the CData kintone JDBC Driver library, specify "cdata.jdbc.kintone.jar" with the classpath (-cp).

PS C:\> cd "C:\Program Files\CData\CData JDBC Driver for kintone 2017J\demos\console\databrowser"
PS C:\Program Files\CData\CData JDBC Driver for kintone 2017J\demos\console\databrowser> javac -cp ".\;../../../lib/cdata.jdbc.kintone.jar" DataBrowser.java

If the compilation is successful, multiple ".class" files will be created in the same directory.

PS C:\Program Files\CData\CData JDBC Driver for kintone 2017J\demos\console\databrowser> dir


directory: C:\Program Files\CData\CData JDBC Driver for kintone 2017J\demos\console\databrowser

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2017/11/06     19:06            256 .classpath
-a----       2017/11/06     19:06            335 .project
-a----       2018/01/14     14:57           2257 ConsoleDemo.class
-a----       2018/01/14     14:57            894 DataBrowser$1.class
-a----       2018/01/14     14:57            686 DataBrowser$2.class
-a----       2018/01/14     14:57            750 DataBrowser$3.class
-a----       2018/01/14     14:57            902 DataBrowser$ERRORS.class
-a----       2018/01/14     14:57           1040 DataBrowser$QUERY_TYPES.class
-a----       2018/01/14     14:57           1333 DataBrowser$TERMS.class
-a----       2018/01/14     14:57          10779 DataBrowser.class
-a----       2017/11/06     19:06          13677 DataBrowser.java
-a----       2017/11/06     19:17           2907 databrowser.properties

PS C:\Program Files\CData\CData JDBC Driver for kintone 2017J\demos\console\databrowser>

Java program execution

Now let's run the sample program. Don't forget to specify the classpath (-cp) as a parameter.

PS C:\Program Files\CData\CData JDBC Driver for kintone 2017J\demos\console\databrowser> java -cp ".\;../../../lib/cdata.jdbc.kintone.jar" DataBrowser

When started, the following console application will start.

******************************************************************
kintone 2017J demo
This demo uses the CData JDBC Driver For kintone 2017J.
******************************************************************
Please enter the connection properties below.

Url:

Please set the following items.

Kintone connection information Setting items
Site URL including kintone subdomain (eg https://****.cybozu.com) Url
User ID User
password Password

A list of commands that can be used with this console application is displayed.

Executable command:
(SELECT|INSERT|UPDATE|DELETE) <formula>
DESCRIBE <tablename>
SHOW TABLES
QUIT
HELP
>

The "SHOW TABLES" command will display a list of apps in kintone.

>SHOW TABLES
+-----------+
| Tables    |
+-----------+
| Apps      |
| Comments  |
|Matter information|
|Matter information_Opportunity history|
|Customer information|
+-----------+
>
>SHOW TABLES
+-----------+
| Tables    |
+-----------+
| Apps      |
| Comments  |
|Matter information|
|Matter information_Opportunity history|
|Customer information|
+-----------+
>

The data in the matter information application is displayed by the "select * from matter information;" command.

>select *from Matter information;
+----------+----------+-------+--------------------------+---------+-------+---------------------------+------+------+------------+--------+-----------------------------------------------------+
| RecordId | Revision | AppId |Customer name|Department name|Person in charge|Project Title|Details|Order accuracy|Expected order date|Order amount|Sales representative Aggregate|
+----------+----------+-------+--------------------------+---------+-------+---------------------------+------+------+------------+--------+-----------------------------------------------------+
| 12       | 2        | 402   |Hands-on Construction Co., Ltd.| NULL    | NULL  | CData API Server          | NULL |Unofficial announcement| 2018-01-30 | 100000 | NULL                                                |
| 11       | 1        | 402   |Hands-on Construction Co., Ltd.| NULL    | NULL  | CData Twitter ODBC Driver | NULL |Approval| 2018-02-02 | 100000 | NULL                                                |
| 10       | 1        | 402   |Hands-on Trading Co., Ltd.| NULL    | NULL  | CData API Server          | NULL |Unofficial announcement| 2018-01-31 | 100000 | NULL                                                |
| 9        | 1        | 402   |Hands-on Trading Co., Ltd.| NULL    | NULL  | CData Kintone ODBC Driver | NULL |Approval| 2018-02-02 | 100000 | NULL                                                |
| 8        | 1        | 402   |Hands-on Industrial Co., Ltd.| NULL    | NULL  | CData API Server          | NULL |Unofficial announcement| 2018-01-31 | 300000 | NULL                                                |
| 7        | 1        | 402   |Hands-on Industrial Co., Ltd.| NULL    | NULL  | CData Kintone JDBC Driver | NULL |Approval| 2018-02-02 | 200000 | NULL                                                |
| 2        | 1        | 402   |CData Software Japan GK|Technical department|Date Masamune| CData Kintone ODBC Driver | NULL |Approval| 2018-02-02 | 100000 | {    "code": "cdatademo",    "name": "cdatademo"  } |
| 1        | 1        | 402   |CData Software Japan GK|Technical department|Date Masamune| CData API Server          | NULL |Unofficial announcement| 2018-01-31 | 100000 | {    "code": "cdatademo",    "name": "cdatademo"  } |
+----------+----------+-------+--------------------------+---------+-------+---------------------------+------+------+------------+--------+-----------------------------------------------------+
>

If you want to close this console application, enter the "QUIT" command. I was able to get kintone data from a Java console application.

Recommended Posts

CData Software hands-on (getting kintone data from Java console application)
CData Software Hands-on (Get Twitter data from Java console application)
Akka hands-on preparation procedure from Java
Access Teradata from a Java application
Data processing using stream API from Java 8
Use PostgreSQL data type (jsonb) from Java
Getting Started with Java Starting from 0 Part 1
Kinesis Data Streams from zero Java experience (3.1)
Kinesis Data Streams from zero Java experience (3.2)