Posts

String rotation interview question for 5 Years of exprience

After long time I have got time to update my blog and help to the followers. These are the most commonly asking interview questions in string concept in java. String Rotation: How can you find one string is the rotation of another string? As we all know what the rotation means is, moving the first character of the string into last. When you keep doing the same, after certain moves you will get the initial string. This is what String Rotation is. Let say I have two strings as mentioned in the below, String str1 = “ABCDEF”; String str2 = “DEFABC”; Now, apply your logic to find str1 is the rotation of str2 or in reverse. First try your own, if not follow the below logic. This is also one of the CMMI Level5 company interview question. Steps to solve the above problem: If you want to find str1 is the rotation of str2. Let’s do concatenation of str2 with it. Means String str3 = str2+str2; Find the str3 contains the str1 or not by using the contains () method...

Hibernate CRUD operations with example

Read this article to know what is CRUD and how to do CRUD operations in hibernate with example. CRUD stands for Create, Read, Update and Delete. As part of hibernate learning CRUD operations are the most basic operations. In previous examples, I have explained by using the MySQL configuration in Hibernate. But, in the current example, I am explaining by using Oracle as well as MySQL configuration. The choice is yours, use at your convenience. As of you people already know if we have to change the Database vendors no need to rewrite the entire code, it’s just a configuration file change. So, except the hibernate.cfg.xml file remaining all files logic will be common for both of the databases like Oracle or MySQL. Before going to write the hibernate logic, we have small work with the databases either Oracle or MySQL. Execute the below query to create the table in the database. Before going to execute the below query make sure you have connected with the specific Schema in the dat...

Send a mail through core java by using Gmail authentication

Image
In the current post, I am trying to explain how to send a mail through the core java program by using Gmail authentication. The below mentioned only one core program which will contain the source code of mail sender. In the below source you have to place your Gmail username, password and from address and to address.   As we know mail.jar is not present in J2SE, we have to download externally and place it into CLASSPATH. Along with mail.jar download the below list of jars and add it into CLASSPATH to avoid compilation error. dsn-1.5.5.jar gimap-1.5.5.jar imap-1.5.5.jar javax.mail.jar javax.mail-api-1.5.5.jar logging-mailhandler-1.5.5.jar mailapi-1.5.5.jar pop3-1.5.5.jar smtp-1.5.5.jar GoogleMail.java import java.util.Properties ; import javax.mail.Message ; import javax.mail.MessagingException ; import javax.mail.PasswordAuthentication ; import javax.mail.Session ; import javax.mail.Transport ; import javax.mail.internet.InternetAddress...

404 error while Apache Tomcat server start up

Image
When I have tried to start up the Apache tomcat server, it was started properly without showing any exceptions in the console. But, when I have tried running the URL in the browser I got the 404 -server start up issue. This is the problem occurred when I tried Apache tomcat server start up from the eclipse server tab. When I have tried running the server through command line, it was working as expected without any issues. When I have tried server start up from the eclipse as per the console not prints the any exceptions. It has showed the message as server started. Below is the console information. Dec 08, 2015 4:51:17 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\i...

GWT auto generated application with source

Image
While creating the GWT application GWT plugin will generate the "GWT Hello" auto generated source. That will gives you an idea about end-to-end GWT application. If you are new to GWT better first read about GWT and GWT plugin installation. In this page I am going to explain about the auto generated source with the source code. While creating the project you have to select the generate automatic application source in the options. After creating the project, project folder structure looks like below, In normal Java/JEE applications for UI we have used JSP's mostly. But, in GWT UI and Server source it should be in Java file only. The EntryPoint RootPanel loading will be happened by using an HTML/JSP file(Only one per module or project). The GWT plugin under the project package it auto generate 3 other directories which contains the Client, Server and Shared files. Client directory contains the EntryPoint class along with the Service and ServiceAsync files. S...