Liking cljdoc? Tell your friends :D

Play Framework

Taken from the Play Framework Documentation. Enable the database plugin by adding javaJdbc in your build dependencies:

libraryDependencies += javaJdbc

Then you must configure a connection pool in the conf/application.conf file. By convention the default JDBC data source must be called default, but you can use other names for named databases, in this case we use neo4j

# Neo4j database configuration
db.neo4j.driver=org.neo4j.jdbc.bolt.BoltDriver
db.neo4j.url="jdbc:neo4j:bolt://localhost"
import javax.inject.Inject;

import play.mvc.Controller;
import play.db.NamedDatabase;
import play.db.Database;

// inject "neo4j" database instead of "default"
class JavaNamedDatabase extends Controller {
    private Database db;

    @Inject
    public JavaNamedDatabase(@NamedDatabase("neo4j") Database db) {
        this.db = db;
    }

    // do whatever you need with the db
}

Can you improve this documentation? These fine people already did:
glaggia-larus, Frank Pavageau, Lorenzo Speranzoni & Michael Hunger
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close