A Developer's Diary

Oct 22, 2012

Configuring and retrieving a DataSource object

In the JDBC API, a DataSource object is a means to access a database. A DataSource object is identified by set of properties which is used to communicate with the server. These properties include information such as the location of the database server, the name of the database, the protocol used to communicate with the server, the username and password of the privileged database user.
In the application server, a data source is known as JDBC Resource

The rest of the post demonstrates how to configure a JDBC Resource in GlassFish application server and retrieve the same data source using JNDI through a simple web servlet

Read more ...

Oct 8, 2012

Prototype Design Pattern

Definition
A creational pattern which allows creation of new instances by copying existing instance or prototype.

Applicability
1. When the classes to instantiate are specified at the run time
2. When creating a new instance is more expensive due to high computation or a call over the network

Read more ...

Jun 17, 2012

Getting started with Objective C on Ubuntu with GNUStep

Setting up the Environment

1. Install the following packages using the apt-get command.

sudo apt-get install build-essential
sudo apt-get install gnustep
sudo apt-get install gnustep-make
sudo apt-get install gobjc
sudo apt-get install libgnustep-base-dev
sudo apt-get install libgnustep-gui-dev

Read more ...

May 19, 2012

A simple java web application in minutes

You can set up your simple java web application in no time using maven. The application can be downloaded from maven's site.

Maven comes up with a single line command to create Hello World web application for you. The value to the argument archetypeArtifactId identifies that the project to be created is of type web application. In case you are running this command for the first time, it will take some time for the maven to download the dependent plugins first and then create the sample application

Create Web Application Project
mvn archetype:create -DgroupId=com.simple.web -DartifactId=webapp -DarchetypeArtifactId=maven-archetype-webapp
Your sample application is created and ready to be packaged and deployed

Read more ...

May 18, 2012

Maven cheat sheet for the beginners

Maven is a build automation tool used by the java developers. Some of the commands which I use on daily basis are:

Create a Java Project
mvn archetype:create -DgroupId=com.devfaqs.project -DartifactId=MyProject
Above is a single line command to create hello world java project. The command creates the project in a well defined directory structure along with the provision to write and execute junit test cases for the project created

Read more ...