0
votes

I'm using Neo4J Community Edition 3.0.4 for the Mac. Within the plugins folder I've got apoc and the mysql connector for Java.

I would like to connect to MySQL on localhost using JDBC.

I've created an alias in the .neo4j.conf file using.

apoc.jdbc.mysql_basemodel.url=jdbc:mysql://localhost:3306/basemodel?user=fred&password=pw

In the browser I've tried to test the connection using:

CALL apoc.load.jdbc("mysql_basemodel","t_object") YIELD row
RETURN count(*);

but get the error

Failed to invoke procedure apoc.load.jdbc: Caused by: > java.lang.RuntimeException: No apoc.jdbc.mysql_basemodel.url jdbc url specified

It's almost as if Neo4J is not reading the .neo4j.conf file with the alias defined.

If, however, I skip the alias and put the full connection string is I get the error:

Failed to invoke procedure apoc.load.jdbc: Caused by: java.lang.RuntimeException: Cannot execute SQL statement SELECT * FROM t_object. Error: No suitable driver found for jdbc:mysql://localhost:3306/basemodel?user=...

which seems to suggest that the mysql JDBC driver isn't found.

What am I doing wrong?

2

2 Answers

1
votes

You first need to register the JDBC driver for MySQL:

CALL apoc.load.driver("com.mysql.jdbc.Driver");

Once you've registered the MySQL JDBC driver your statements using apoc.load.jdbc will make use of this this driver when connecting to MySQL.

More information available in the docs here.

0
votes

Download the mysql JDBC driver (e.g. from http://mvnrepository.com/artifact/mysql/mysql-connector-java) and drop it into the /plugins folder - same location like apoc's jar file.