Java -Save the results of select for MySQL into a file No.85

In this blog, how to save the results of select for MySQL on Ubuntu into a file is shown. ▼1. Prerequisites 1-1. Install MySQL and create a table with some records Java – Connect to MySQL on Ubuntu and run select query No.80 # Create a table with some records mysql> CREATE DATABASE testdb; mysql> USE testdb; mysql> create table testtbl (c1 int, c2 int); mysql> insert testtbl values(1,1),(2,2),(3,3); mysql> select * from testtbl; +——+——+ | c1 | c2 | +——+——+ | 1 | 1 | | 2 | 2 | | 3 | 3 | +——+——+ 3 rows in set (0.00 sec) ▼2. Save the results of select for … Continue reading “Java -Save the results of select for MySQL into a file No.85”

Scala – Visual Studio Code on Ubuntu No.83

How to execute Scala application in Visual Studio Code on Ubuntu is shown in this blog. ▼1. Run Scala code in Visual Studio Code on Ubuntu Scala or PySpark application on Apache Spark cluster is generally used. how to deploy Scala application in Visual Studio Code on Ubuntu is helpful for the deployment of application on Spark cluster. ▼2. Prerequisites 2-1. Install Ubuntu 20.04.2 LTS https://releases.ubuntu.com/20.04/ 2-2. Install Visual Studio Code https://code.visualstudio.com/docs/setup/linux 2-3. Install JDK Install Java 8 openjdk x64 of zulu Set environment variables for the installed JDK Adding below at the end of ~/.bashrc (vi ~/.bashrc) export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-x64/ Checking if $JAVA_HOME is correctly updated. 2-4. Install Maven Apache … Continue reading “Scala – Visual Studio Code on Ubuntu No.83”

Java – Search YouTube using YouTube Data API on Ubuntu No.82

In this blog, how to search YouTube videos using YouTube Data API on Ubuntu is shown. Java application is executed in Visual Studio Code on Ubuntu. ▼1. How to get API Key for YouTube Data API After creating a project and enabling YouTube Data API v3 API, API key can be generated. please refer to the following documents or another blogs. ▼2. Prerequisites 2-1. Install JDK Install Java 8 openjdk x64 of zulu Set environment variables Use vi editor like “vi ~/.bashrc” and add below in ~/.bashrc export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-x64/ Check the value of $JAVA_HOME 2-2. Install Visual Studio Code https://code.visualstudio.com/docs/setup/linux 2-3. Install Maven Apache Kafka Word Count – Java No.44 “2-3. … Continue reading “Java – Search YouTube using YouTube Data API on Ubuntu No.82”

Java – Put CPU % into a local file by Cron job No.81

How to save the current CPU % on Ubuntu into a local file by Cron job with an execution of Jar is shown in this blog. ▼1. How to export the current CPU % on Ubuntu The command “top -b -n 1” is executed by Java and save only CPU % into a file. ▼2. Prerequisites This blog is based on Java – Capture CPU,Memory,Network info on Ubuntu No.79. ▼3. Java code to export the current CPU % on Ubuntu 3-1. Develop perfch2.java “perfch2.java” run the command “top -b -n 1” and save only CPU % into a file by Java. the file name of output is CPU{epochmilliseconds}.txt when file … Continue reading “Java – Put CPU % into a local file by Cron job No.81”

Java – Connect to MySQL on Ubuntu and run select query No.80

How to connect to MySQL and run select query is shown in this blog. ▼1. What is MySQL? MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by Oracle Corporation. MySQL is available on some cloud services such as Azure, AWS, Oracle etc. ▼2. Prerequisites 2-1. Install JDK Install Java 8 openjdk x64 of zulu Set environment variables Use vi editor like “vi ~/.bashrc” and add below in ~/.bashrc export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-x64/ Check the value of $JAVA_HOME 2-2. Install Visual Studio Code https://code.visualstudio.com/docs/setup/linux 2-3. Install Maven Apache Kafka Word Count – Java No.44 “2-3. Installing Apache Maven” 2-4. Install the latest version of MySQL # … Continue reading “Java – Connect to MySQL on Ubuntu and run select query No.80”

Java – Capture CPU,Memory,Network info on Ubuntu No.79

In this blog, how to capture CPU, Memory, Disk, Network information by Java is shown.it would be helpful if you need narrow down the issue about connection failure to Database to find a root cause. ▼1. How to know CPU, Memory, Network status on Ubuntu We can know CPU, Memory, Network, Disk usage on Ubuntu to run the following commands. ▼2. Prerequisite 2-1. Install JDK Install Java 8 openjdk x64 of zulu Set environment variables Run vi command (vi ~/.bashrc) and update ~/.bashrc file as below. export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-x64/bin/ Check $JAVA_HOME 2-2. Install Visual Studio Code https://code.visualstudio.com/docs/setup/linux 2-3. Install Maven Apache Kafka Word Count – Java No.44 “2-3. Installing Apache Maven” … Continue reading “Java – Capture CPU,Memory,Network info on Ubuntu No.79”

Java – Connect to Azure Cosmos DB (SQL API) No.11

In this blog, how to connect to Cosmos DB SQL API by Java is shown. ▼1. Connect to Azure Cosmos DB Azure Cosmos DB is NoSQL Database. it is not Relational Database. we don’t need to set schema and table beforehand. we need to set partition key for a collection of a container to distribute data into the partitions. ▼2. Prerequisites 2-1. Prepare for a trial free Azure Cosmos DB Account, not necessary for a subscription https://cosmos.azure.com/try/ 2-2. Enable Maven auto-import in IntelliJ IDEA Enable auto-import on IntelliJ IDEA No.13 2-3. Update Pom.xml Please change the latest version each libraries. (a part of pom.xml) <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.30</version> </dependency> … Continue reading “Java – Connect to Azure Cosmos DB (SQL API) No.11”

Apache Kafka – Develop Producer Java application No.66

How to develop Producer application by Java on Visual Studio Code is shown in this blog. ▼1. Apache Kafka Ref: Apache Kafka ▼2. Prerequisites Install Apache Kafka 4 nodes No.42 Apache Kafka Word Count – Java No.44“2-3. Installing Apache Maven” ▼3. Develop Producer Java application This producer Java application write events from 1 to 100 into a topic. 3-1. Make a directoryMake a directory to develop an application. 3-2. Create a project using Apache Maven 3-3. Remove the App.java and AppTest.java files 3-4. Update pom.xml file Adding below in pom.xml(a part of pom.xml) Dependency Analytics Extension need to be installed on VS Code to check and update dependencies automatically. 3-5. … Continue reading “Apache Kafka – Develop Producer Java application No.66”

Java – Visual Studio Code on Ubuntu No.24

In this blog, How to run Java on Visual Studio Code on Ubuntu is shown. ▼1. Run Java using Visual Studio Code on Ubuntu Visual Studio Code is the developer tool provided by Microsoft. Visual Studio Code works on both Windows and Linux OS. in this case, VS Code is used on Ubuntu. ▼2. Prerequisites 2-1.Install Ubuntu Ubuntu 20.04.5 LTS 2-2. Setup Visual Studio Code 2-3. Install Java Extension Pack 2-4. Install JDK (OpenJDK 15) In this case, jdk-15.0.2+7 is under /home/user/Downloads/ path. 2-5. Set Environment variables for java.configuration.runtimes and java.home (e.g) { “java.home”:”/home/user/Downloads/jdk-15.0.2+7″, “java.configuration.runtimes”: [ { “name”:”JavaSE-15″, “path”:”/home/user/Downloads/jdk-15.0.2+7″ } ] } ▼3. Show Hello World by Java 3-1. Create … Continue reading “Java – Visual Studio Code on Ubuntu No.24”

Install IntelliJ IDEA on Ubuntu No.43

How to install IntelliJ IDEA on Ubuntu is shown in this blog. ▼1. What is IntelliJ IDEA? IntelliJ IDEA is a developer tool. Java, Kotlin, Groovy, Scala languages etc are available. there are 2 types Edition, Ultimate Edition and Community Edition for Free. ▼2. Installing IntelliJ IDEA 2-1. Download IntelliJ IDEA Community Edition We can download IntelliJ IDEA from this site Download IntelliJ IDEA. in this case, idealC-2021.2.3.tar.gz is used on Ubuntu 21.04. 2-2. Unzip downloaded IntelliJ IDEA Community Edition 2-3. Run idea.sh to start IntelliJ IDEA 2-4. Install Java 8 JDK Azul Zulu OpenJDK Java 8 (LTS) is used in this blog. How to install this JDK is shown … Continue reading “Install IntelliJ IDEA on Ubuntu No.43”