Thursday, September 18, 2014

How to resolve merge conflicts after git rebase ?

Have you faced a merge conflict while performing git rebase operation ? This is quite possible  if two commits modify the same line in the same file. Now git is confused which change to apply.
Git gives us several options in such a case :
  • git rebase --continue
  • git rebase --abort
  • git rebase --skip
1. git rebase --continue
Used in case if you have manually corrected the conflicted files. So after resolving the merge issues manually , use command rebase --continue so that git can continue processing the rest of the rebase.

2. git rebase --abort
Use this command if you want to completely undo the rebase. So the branch will return to the state that was before rebase was called.

3. git rebase --skip
Used to completely skip the commit. None of the changes introduced by the commit will be included.

Happy Learning !!!


Monday, September 1, 2014

How to open or Untar a ".tar.gz" file in Ubuntu ?

Lets say that the name of file is - test.tar.gz
  1. From the terminal, change to the directory where tar file is located.
  2. Now to extract the file to the current directory , run the command 
  3.  tar -zxvf test.tar.gz

    To extract the file to a specific directory , run
    tar -C /directory_name -zxvf test.tar.gz

    NOTE : The extensions .tgz and .tar.gz are equivalent and both signify that a tar file zipped with gzip.
How to Untar a ".tar" file ?
  1. From the terminal, change to the directory where tar file is located.
  2. Now to extract the file to the current directory , run the command 
  3. tar -xvf test.tar

    To extract the file to a specific directory , run
    tar -C /directory_name -xvf test.tar

Tar Usage and Options
  • c – create a archive file.
  • x – extract a archive file.
  • v – show the progress of archive file.
  • f – filename of archive file.
  • t – viewing content of archive file.
  • j – filter archive through bzip2.
  • z – filter archive through gzip.
  • r – append or update files or directories to existing archive file.
  • W – Verify a archive file.
  • wildcards – Specify patters in unix tar command.
 


     

Thursday, May 1, 2014

How to amend the last commit in Git ?


Have you ever faced a situation where you left something out of your last commit ? It may be a file or an extra change to a file you just committed. 

Such kind of scenarios can easily be handled with Git amend command .

How does it work ?
1. Just add the file using git add ( Like what we do for         normal commit ).
    git add <file>

2. Now commit the changes with -amend argument.
    git commit --amend

    If you don't specify a commit message with -m , git picks the previous commit message as    a default.

How to see the amended commit ?
We can use git log --stat to see the amended commit with extra change .

You can also see this page for more information on git commit.

Tuesday, April 29, 2014

Unbound Classpath Variable M2_REPO error in Eclipse

Problem Description :

My Eclipse IDE gives errors whenever I try to build the project . The problems tab shows the message as given below

Unbound classpath variable: 'M2_REPO/...'



Solution :
M2_REPO is a classpath variable that tells eclipse where maven repository is on your disk .


Setting M2_REPO 

  • Open Eclipse Preferences [Window -> Preferences]
  • Go to [Java -> Build Path -> Classpath Variables]
  • Click New and set its name as M2_REPO
  • Click Folder and select your Maven repository directory on your machine . For example,on my machine , its H:\WDP\.m2\repository
  • Rebuild the Project.
  • DONE.








Sunday, March 30, 2014

What is JDBC RowSet ?

A RowSet ( javax.sql.RowSet ) is an object that encapsulates a set of rows from either Java Database Connectivity (JDBC) result sets or tabular data sources like a file or spreadsheet. RowSets support component-based development models like JavaBeans, with a standard set of properties and an event notification mechanism.

Interfaces that extends RowSet are  :
  • JdbcRowSet
  • CachedRowSet
  • WebRowSet
  • JoinRowSet
  • FilteredRowSet

Benefits :
Beside sharing the capabilities of a ResultSet , RowSet adds the following new capabilities :

1.  Function as JavaBeans Component
That means RowSet objects have properties with corresponding getter and setter methods that can be exposed to builder tools (such as those that come with the IDEs JDveloper and Eclipse) that provides the capability to visually manipulate the beans.

In addition , RowSet objects use the JavaBeans event model, in which registered components are notified when certain events occur. The events that trigger notifications are :
  • A cursor movement
  • The update, insertion, or deletion of a row
  • A change to the entire RowSet contents

2.  Add Scrollability or Updatability
If a database driver does not have the ability to scroll or update result sets, RowSet object can be used for the same . A RowSet object is scrollable and updatable by default, so by populating a RowSet object with the contents of a result set, you can effectively make the result set scrollable and updatable.


Types of Rowset :
There are two types of RowSet :
  • Connected - A connected RowSet object connects to the database once and remains connected until the application terminates. Only one of the standard RowSet implementations is a connected RowSet object - JdbcRowSet.
  • Disconnected - A disconnected RowSet object connects to the database, executes a query to retrieve the data from the database and then closes the connection. A program may change the data in a disconnected RowSet while it is disconnected. Modified data can be updated in the database after a disconnected RowSet reestablishes the connection with the database.Disconnected RowSet objects are lightweight and  serializable, and it makes them ideal for sending data over a network. They can even be used for sending data to thin clients such as PDAs and mobile phones.

Saturday, March 29, 2014

How to run a standalone OSGi server

This post shows how to run Equinox as an OSGi stand-alone runtime.

Download org.eclipse.osgi_.jar from here. The same jar exists in eclipse installation directory ( plugin folder ). Copy the jar and paste into a new directory.
Example - C:\osgi\org.eclipse.osgi_3.9.1.v20140110-1610.jar

Starting the OSGi server :
java -jar org.eclipse.osgi_3.9.1.v20140110-1610.jar -console                                                                                                                
starting osgi server

Basic commands to start with :
  • install - Installs the bundle from the given URL
  • start - Starts the bundle with the given numeric or symbolic id.
  • stop - Stops the bundle with the given numeric or symbolic id.
  • ss - Reports a summary status of all installed bundles
  • diag - Reports any resolution problems for the bundle with the given numeric or symbolic id.

Understanding the JDBC architecture.

The JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases.

The JDBC driver manager ensures that the correct driver is used to access each data source.



      
The JDBC Architecture consists of two layers:
  • The JDBC API , which provides the application-to-JDBC Driver Manager connection.
  • The JDBC Driver API , which supports the JDBC Manager-to-Driver Connection.

JDBC Architecture