br.edu.ifpb.bdnc.mongodb.Connectmongo.java Source code

Java tutorial

Introduction

Here is the source code for br.edu.ifpb.bdnc.mongodb.Connectmongo.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.ifpb.bdnc.mongodb;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

/**
 *
 * @author Julierme Heinstein
 */
public class Connectmongo {

    /* Classe que realiza a conexo com o MongoDB */
    MongoClient mongoClient;
    MongoDatabase database;

    /* Construtor responsvel pela conexo */
    public MongoDatabase Connectmongo() {
        mongoClient = new MongoClient("localhost", 27017);
        database = mongoClient.getDatabase("ativBDNC");
        return database;
    }
}