Category Archives: Programming

Java – Replace First Occurrence of String without Regular Expression

Java – Replace First Occurrence of String without Regular Expression

           The String class in Java has a method replaceFirst(String regex, String replacement) which replaces first occurrence of given regular expression with given replacement string. If you want to replace first occurrence of any given string (with Regular Expression), use the following code. Sample Code: package test; import java.util.regex.Pattern; public class test{… Read More »

Send EMail (GMail/Google Mail) using Java Mail API

Send EMail (GMail/Google Mail) using Java Mail API

           This article details on how to send mail (GMail/Google Mail) using Java API. Google by default does not allow any 3rd party applications to access GMail account from any programming language. Google provide an option to turn on Less secure apps to get access from external applications. The following program works if… Read More »

Execute Raw Elasticsearch Query using Transport Client – Java API

Execute Raw Elasticsearch Query using Transport Client – Java API

           The following sample program details on how to execute raw Elasticsearch query using Transport Client (Java API).  Maven Dependencies: <dependencies> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>1.5.0</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20140107</version> </dependency> </dependencies>            Add the above MAVAN dependencies to the POM file or add the JARs specified in… Read More »

Setup Quartz Scheduler with MYSQL Database

Setup Quartz Scheduler with MYSQL Database

Setup Quartz Scheduler with MYSQL Database

Setup Quartz Scheduler with MYSQL Database

This article details on how to setup Quartz server with MYSQL database. Setup MYSQL Download the latest version of Quartz distribution from the website http://quartz-scheduler.org/downloads and extract it. The distribution will be in TAR format. Install MYSQL and go to command line interface to create the required database and tables. Create a database named quartz. Now use… Read More »

Import Data from Mongo DB to Elasticsearch using Elasticsearch River

Import Data from Mongo DB to Elasticsearch using Elasticsearch River

Import Data from Mongo DB to Elasticsearch using Elasticsearch River

Import Data from Mongo DB to Elasticsearch using Elasticsearch River

           Importing data from Mongo DB to Elasticsearch requires Mongo DB to have replica set enabled. Once the replica set is enabled, Mongo DB populates the oplog (operation log) as and when we add documents to the collection in the database (except database named local, which is used by Mongo DB to… Read More »