Skip to main content

Posts

Showing posts from August, 2016

How to convert String to Integer or int in Java?

There a two ways to convert String object to integer value. 1. Using Integer.parseInt() This method takes a String object as parameter and returns it primitive type int value. String s = "100"; int i = Integer.parseInt(s); System.out.println("Integer value is " + i); 2. Using Integer.valueOf() This method takes a String object as parameter and returns an object of Integer class. String s = "100"; Integer i = Integer.valueOf(s); System.out.println("Integer value is " + i);

How to pass JVM arguments to Tomcat when running as a service?

In your <Tomcat_Home>/bin folder, you should have a tomcat7w.exe admin app. Open the app and go to the Java tab. Add the arguments in the "Java Options:" box.

How to change folder location of Google Drive on Windows?

Many of the times we after installing Google Drive, we realize that we want to change the folder location where Google Drive syncs it's documents. It's not very straight forward to change the location. We have to disconnect Google Drive and then login again to change folder location. Disconnect account. Delete or rename the existing "Google Drive" folder. Click the drive icon and select sign in. After sign in, it will show a first-time tutorial. Click 'Next' through them all, but DO NOT click 'Done' on the last. There will be a button on the last page called "Sync Options". In here, there is the option to point to a different location.

Use Spring Data to connect to MongoDB using SSL connection.

This post is in continuation to my earlier post on How to enable SSL in MongoDB Community version . Once we have enabled SSL connection on MongoDB server, how can we connect to MongoDB server using Spring Java application. In a Spring application connection to MongoDB is controlled by MongoClient and MongoClientOptions classes. Follow below steps to connect Java Spring application running on Windows server to a MongoDB instance using secure SSL connection. 1. Copy client-cert.crt and mongodb-cert.crt files to Client machine. You need to copy client-cert.crt and mongodb-cert.crt files used for setting up MongoDB server to machine that will be running your Spring application. (Refer: How to enable SSL in MongoDB Community version ) 2. Import client and server certificate files to keystore. Use below command to import MongoDB certificate. keytool -import -alias "MongoDB-cert" -file C:\Users\abc\ssl\mongodb-cert.crt -keystore truststore.ts -noprompt and below comma

How to enable SSL in MongoDB Community version

If we want to connect to a MongoDB instance running on one machine from a different machine (over internet), it would be more than advisable to secure the communication using SSL encryption. Fortunately MongoDB has in-built support for SSL and its very straight forward to enable it. We can setup SSL connection using a certificate issues by a Certificate Authority or by using a self-signed certificate. In this post we will cover steps for setting up SSL connection using a self-signed certificate on Ubuntu machine. Follow below steps to setup self-signed SSL secured connection to MongoDB server from a remote machine. 1. Verify that your MongoDB installation supports SSL connection. Run following command from command line mongod --version It should give output like: db version v3.2.8 git version: ed70e33130c977bda0024c125b56d159573dbaf0 OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014 allocator: tcmalloc modules: none build environment:     distmod: ubuntu1404     distarc