Wednesday, February 26, 2014

Eclipse IDE and One Tip

Eclipse is an integrated development environment (IDE). It contains a base workspace and an extensible plug-in system for customizing the environment. Written mostly in Java, Eclipse can be used to develop applications [From Wikipedia].

Major Flavors of Eclipse

The Spring Tool Suite is an Eclipse-based development environment that is customized for developing Spring applications. It provides a ready-to-use environment to implement, debug, run, and deploy your Spring applications, including integrations for Pivotal tc Server, Pivotal Cloud Foundry, Git, Maven, AspectJ, and more.

The Groovy/Grails Tool Suite™ (GGTS) provides the best Eclipse-powered development environment for building Groovy and Grails applications.


How do I turn off "Automatically Switch to Debug Perspective" mode in Eclipse or its flavours?

1. Go to Preferences -> Run/Debug -> Perspectives -> 

2. Select 'NEVER' for the option of 'Open the associated perspective when application suspends'

Reading a Record/Row from SQLServer Database Using C#

First, Set up your connectionString and use the following code snippet in a method.

using (SqlConnection con = new SqlConnection(connectionString))


    SqlCommand cmd = new SqlCommand("SELECT userid, username, email, city FROM USERS where username=@username and password=@password", con);
    cmd.Paramters.AddWithValue("@username", username);
    cmd.Parameters.AddWithValue("@password", password);
    cmd.CommandType = CommandType.Text;

    UserInfo info = new UserInfo();

    using (SqlDataReader rdr = cmd.ExecuteReader())

        if (rdr.HasRows)
            rdr.Read(); // get the first row

            info.UserID = rdr.GetInt32(0);
            info.UserName = rdr.GetString(1);
            info.Email = rdr.GetString(2);
            info.City = rdr.GetString(3);
Acknowledgement to: Tim of

Wednesday, February 19, 2014

Apache Struts 2: Redirecting to a link and another Action

Apache Struts is a project developing an open-source web application framework for Java EE web application development that promotes a model–view–controller (MVC) architectural approach through extensions the Java Servlet web API. [Definition from Wikipedia]

To know more about Apache Struts 2, click here.

Redirect to JSP page

It is very simple to redirect to a JSP(JavaServer Pages) which is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types.

<action name="login" class="LoginAction">

<result name="input">login.jsp</result>


Tuesday, February 18, 2014

A one liner code to convert comma separated Strings to List in Java

No talking! Let's just do the code.

// String that is comma separated
String listOfUserIds = "10,11,12,13";

// The magic that converts it to list
List<String> userIds = new ArrayList<String>(Arrays.asList(listOfUserIds.split(",")));


Friday, February 14, 2014

Grails: Solving "Failed to resolve dependencies" exception

When upgrading grails to version 2.3.0, I got the following error.
Failed to resolve dependencies ... org.grails.plugins:tomcat:2.3.0 ...
hibernate:2.3.0 ...

This is because as of Grails 2.3.0, the tomcat and hibernate plugins (as well as the scaffolding and webflow plugins) have been split out as completely independent plugins and are no longer versioned with Grails. You need to use explicit versions now instead of using $grailsVersion.

Tuesday, February 4, 2014

How to remove empty or blank lines in Microsoft Word document

If multiple line blank spaces appear in your Microsoft Word document, (when you copy and paste from a PDF document or from some website), 

  1. Press Ctrl + F in the document
  2. Go to the Replace tab
  3. Replace double paragraph mark (i.e. ^p^p) through a single one (^p).
  4. Press 'Replace All'