Wednesday, September 19, 2012

Create Unity Eclipse launcher.

Create a text file named eclipse.desktop inside /home/youruser/.local/share/applications directory, with this content


[Desktop Entry]
Type=Application
Name=Eclipse Juno
Comment=Eclipse Juno
Exec="/pathtoeclipse/eclipse"
Icon=/pathtoeclipse/icon.xpm
Categories=Application;Development;Java;IDE
Version=1.0
Type=Application
Terminal=0

Just reset unity. You should get Eclipse Juno icon on the Dash. To add it to launcher, just drag-n-drop the eclipse.desktop file from Nautilus to Unity launcher, and that is it.

Monday, January 16, 2012

Nice way to clean up JDBC resources in JDBC 4.1 (Java 7)

I was working on a small prototype of an application and had the luxury of working on top of Java 7. I was struck by how much boiler plate code we can avoid when working with JDBC.

Following is the code sample to read from a table using PreparedStatement.

try(
 Connection connection = ServiceLocator.getConnection;
 PreparedStatement stmnt = connection.prepareStatement(YOUR_SELECT_QUERY_HERE);
){
   stmnt.setString( 1, parameterValue1);
   stmnt.setString( 2, parameterValue2);


   ResultSet rs = stmnt.executeQuery();
   while(rs.next()){
   ......

   }
}


And this is it. No long, ugly and trite finally blocks to close connection, statements and resultsets.

Wednesday, February 16, 2011

Trying my hands on Scala.

Finally taken up Scala. I am very interested in learning the functional programming, there seems to be lots of languages available. I choose Scala because it is a typed language and run on JVM, and, of course, few people also suggested it to me.

Hello to the blog world.

I am going to be posting stuff going on in my life, or something I find interesting around. This blog is just sort of an online diary for myself.