This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
M2MovieRecommander/src/main/java/com/camillepradel/movierecommender/controller/Neo4jConnector.java

47 lines
1.2 KiB
Java
Raw Normal View History

2016-11-14 15:52:26 +00:00
/*
* 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 com.camillepradel.movierecommender.controller;
import java.net.ConnectException;
import org.neo4j.driver.v1.*;
import org.neo4j.driver.v1.exceptions.Neo4jException;
/**
*
* @author renando
*/
public class Neo4jConnector {
private static Neo4jConnector INSTANCE = null;
private static Session session = null;
private static Driver driver = null;
private Neo4jConnector() {
}
public static synchronized Neo4jConnector getInstance()
{
if (INSTANCE == null)
{
INSTANCE = new Neo4jConnector();
2016-11-30 11:02:59 +00:00
2016-11-14 15:52:26 +00:00
}
return INSTANCE;
}
public Session getConnection() throws ConnectException {
2016-11-30 11:02:59 +00:00
this.driver = GraphDatabase.driver( "bolt://localhost", AuthTokens.basic( "neo4j", "root1234" ) );
this.session = driver.session();
2016-11-14 15:52:26 +00:00
return this.session;
}
2016-11-30 11:02:59 +00:00
public void close() {
this.session.close();
this.driver.close();
2016-11-14 15:52:26 +00:00
}
}