Skip to content
Sandny Blog
  • Home
  • Java
  • JavaScript
  • AWS
  • Embedded
  • About
neo4j boltdriver Java

How to create a neo4j BoltDriver Datasource and connect…

  • October 19, 2017November 21, 2019
  • by Coder Kai

I wanted to test the neo4j database access using a data source defined in Wildfly server. I used Wildfly 10.1.0 release. I wanted to use the driver with bolt protocol to observe the performance when using it.

First, you need to download the neo4j BoltDriver and add into the library path of wildlfy. Download the latest jdbc driver for neo4j from release page https://github.com/neo4j-contrib/neo4j-jdbc/releases. You can see more details about the bolt protocol in https://boltprotocol.org/ website. I used https://github.com/neo4j-contrib/neo4j-jdbc/releases/download/3.1.0/neo4j-jdbc-driver-3.1.0.jar. It contains the BoltDriver as well.

Create the folder structure as follows wildfly-10.1.0.Final/modules/system/layers/base/org/neo4j/main

Then add the module.xml file with the following content. Copy the driver jar package to the same folder.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.neo4j">
    <resources>
        <resource-root path="neo4j-jdbc-driver-3.1.0.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="sun.jdk"/>
    </dependencies>
</module>

Now you can define the driver and the data source in the standalone-full.xml. Browse into wildfly-10.1.0.Final/standalone/configuration and edit the configuration file with a text editor. I used vim.

vim standalone-full.xml

Afterwards, add the datasource and neo4j connector to standalone-full.xml file.

            <datasources>
               <datasource jndi-name="java:jboss/datasources/neo4jTestDS" pool-name="neo4jTestDS" enabled="true" use-java-context="true">
                   <connection-url>jdbc:neo4j:bolt://localhost:7687/</connection-url>
                   <driver>neo4j</driver>
                   <security>
                       <user-name>username</user-name>
                       <password>password</password>
                   </security>
               </datasource>
               <drivers>
                   <driver name="neo4j" module="org.neo4j">
                       <xa-datasource-class>org.neo4j.jdbc.bolt.BoltDriver</xa-datasource-class>
                   </driver>
               </drivers>
           </datasources>

Now the server configuration is done. Next step is to access this datasource in your service app or web app.

@Resource(mappedName = "java:jboss/datasources/Neo4jDS")
private DataSource dataSource;

You can use the datasource in a DAO or a Repository service or directly inject into whatever the service you want.
Enjoy!

 

 

Adaptation of js apps and how predesigned abstractions could burn you
How to create a Vertx EventBus js client and use it with a web server with CORS
Coder Kai
A humble developer
BoltDriver datasource Jboss JDBC neo4j Widlfly

Related articles

String.lines()
How to convert a string…
How to avoid NullPointerException in Java
How to avoid NullPointerException in…
The new features in Java 14
JDK 14 – The new…
Java 13 features
Java 13 (JDK 13) -The…
Java 13 Switch Expressions
How to enable preview feature in Java 13 with maven.
Enable the Preview Feature in…
AWS Ingress ALB with EKS
How to use AWS Ingress…
modular approach to create API
A Modular Approach to create…
nodemon to build api
babel + express.js + node.js…
create a Vertx Eventbus js client
How to create a Vertx…
wildfly 10 xa datasource
How to create a XA…
Servlet File Upload
Servlet File Upload
Java RMI Slider
JAVA RMI Observer Slider

Categories

  • android 3
  • Apollo Client 1
  • AWS 8
    • AppSync 5
    • EC2 1
    • EKS 1
    • Route53 1
    • S3 1
  • AWS Amplify 1
  • Chakra UI 1
  • Docker 1
  • Embedded 1
  • EmberJS 1
  • FCM 1
  • Godaddy 1
  • GraphQL 3
  • ios 1
  • Jasper 1
  • Java 10
    • Java 11 1
    • Java 14 1
  • JavaEE 2
  • JavaScript 39
    • Express.js 4
    • Javascript Guide 7
    • Node.js 3
    • react-native 4
    • React.js 17
    • Typescript 1
  • Kubernetes 1
  • machine learning 1
  • Maven 2
  • OCaml 3
  • PostgreSQL 1
  • Python 2
  • react-native 4
  • ReactJS 3
  • sass 1
  • Server 6
  • spark 1
  • Terraform 2
  • Ubuntu 4
  • Uncategorized 1
  • webpack 2

Recent Comments

  • binance register on Chakra UI Animations
  • binance account on SSL Websocket proxy with Nginx for Graphql Subscriptions
  • Binance Pag-signup on How to fetch data with useEffect

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Archives

  • October 2022 3
  • September 2022 7
  • May 2022 1
  • December 2021 1
  • August 2021 1
  • July 2021 6
  • June 2021 3
  • February 2021 1
  • July 2020 1
  • December 2019 5
  • November 2019 6
  • October 2019 3
  • August 2019 1
  • March 2019 1
  • February 2019 1
  • January 2019 2
  • December 2018 1
  • September 2018 2
  • August 2018 1
  • June 2018 1
  • February 2018 1
  • November 2017 2
  • October 2017 5
  • September 2017 1
  • June 2017 1
  • May 2017 10
Sandny Blog space
Theme by Colorlib Powered by WordPress