Friday, 9 November 2012

sample mongodb

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.mongodb.Mongo;

public class SpringMongoConfig extends AbstractMongoConfiguration {

public @Bean Mongo mongo() throws Exception {

return new Mongo("localhost");

public @Bean MongoTemplate mongoTemplate() throws Exception {

return new MongoTemplate(mongo(),"blog","users");
} (Main)


import com.mongodb.BasicDBObject;

import com.mongodb.DB;

import com.mongodb.DBCollection;

import com.mongodb.DBCursor;

import com.mongodb.Mongo;

import com.mongodb.MongoException;

public class MongoApp {
public static void main(String[] args) throws UnknownHostException {
try {
// connect to mongoDB
Mongo mongo = new Mongo("localhost", 27017);
// if database doesn't exists, mongoDB will create it
DB db = mongo.getDB("blog");
// Get collection from MongoDB, database named "mydb"
// if collection doesn't exists, mongoDB will create it
DBCollection collection = db.getCollection("users");
// create a document to store attributes
BasicDBObject document = new BasicDBObject();
// save it into collection named "myCollection"
System.out.println( collection.find());

DBCursor cur = collection.find();
while(cur.hasNext()) {
// search query

} catch (MongoException e) {





public class User {
private String id;
private String password;

public User(){};
public User(String id, String password) {
super(); = id;
this.password = password;
public String getId() {
return id;
public void setId(String id) { = id;

     * @return the password
    public String getPassword() {
        return password;

     * @param password the password to set
    public void setPassword(String password) {
        this.password = password;

public String toString() {
return "User [id=" + id + ", firstname=" + password"]";


Just change the groupID by your package name

<project xmlns="" xmlns:xsi=""

<name>Spring Maven MILESTONE Repository</name>


<!-- Spring framework -->


<!-- mongodb java driver -->






Thursday, 8 November 2012

A new site for tutorial on Java ...

Today I was browsing the

I was going through one of the Java champion Lars Vogel is the founder and CEO of vogella GmbH

He has got very good tutorials for Java Based, Android based

Hope this helps someone ...

Wednesday, 31 October 2012

Free Online MongoDB(NOSQL) Training ...

Any one want to do a free course in MongoDB

Sign up then

Thursday, 18 October 2012 down ...

Frankly it shocks me to see one of UK largest main website being down for nearly 12 hours.

I was not able to access HSBC personal banking website from yesterday(18/10/2012) evening 5 PM.

Attaching the screen shot

Frankly the banks should pay consultants (like me :p) to have a proper solution .... Instead of loosing money employing dummers and duffers .... ;)

Tuesday, 2 October 2012

Mac Time Machine Backup

In case you Mac TimeMachine Takes long ... After Mountain Lion the backup takes long ... I think there is a bug in spotlight.

How to solve it ?

Technically stop the spotlight using the command ...

Open up a terminal

> sudo launchctl unload -w /System/Library/LaunchDaemons/

Now the Backup will be faster.

Once done enable the spotlight back

> sudo launchctl load -w /System/Library/LaunchDaemons/

My backup took very long ... got this solution and finished my back up.

Hope this helps ...

Sunday, 23 September 2012

My First Post on Technology


Everyone, this is going to be my main blog for technology update, problems i face and solutions which is used by me to solve the technology problems i face.

Hope you all Join Muy Blog, Like share in Google plus, FaceBook & Twitter ...

Come lets have some fun (in technology)  ...