val mysqlDriver = new DriverManagerDataSource(sys.env("SQL_URL"))
mysqlDriver.setDriverClassName("com.mysql.cj.jdbc.Driver")
val mysqlTemplate = new JdbcTemplate(mysqlDriver)
val neo4jDriver = new DriverManagerDataSource(sys.env("NEO4J_URL"), sys.env("NEO4J_USER"), sys.env("NEO4J_PASSWORD"))
neo4jDriver.setDriverClassName("org.neo4j.jdbc.bolt.BoltDriver")
val neo4jTemplate = new JdbcTemplate(neo4jDriver)
But when I run this application, I get the following error message:
migration_1 | Exception in thread "main" java.lang.reflect.InvocationTargetException
migration_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
migration_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
migration_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
migration_1 | at java.lang.reflect.Method.invoke(Method.java:498)
migration_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
migration_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
migration_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
migration_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
migration_1 | Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: JDBC URL is not correct.
migration_1 | A valid URL format is: 'jdbc:neo4j:http://<host>:<port>'
migration_1 | at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
migration_1 | at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:394)
migration_1 | at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:474)
migration_1 | at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:484)
migration_1 | at org.springframework.jdbc.core.JdbcTemplate.queryForList(JdbcTemplate.java:510)
migration_1 | at Importer$.delayedEndpoint$Importer$1(Importer.scala:21)
migration_1 | at Importer$delayedInit$body.apply(Importer.scala:8)
migration_1 | at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
migration_1 | at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
migration_1 | at scala.App$$anonfun$main$1.apply(App.scala:76)
migration_1 | at scala.App$$anonfun$main$1.apply(App.scala:76)
migration_1 | at scala.collection.immutable.List.foreach(List.scala:381)
migration_1 | at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
migration_1 | at scala.App$class.main(App.scala:76)
migration_1 | at Importer$.main(Importer.scala:8)
migration_1 | at Importer.main(Importer.scala)
migration_1 | ... 8 more
migration_1 | Caused by: java.sql.SQLException: JDBC URL is not correct.
migration_1 | A valid URL format is: 'jdbc:neo4j:http://<host>:<port>'
migration_1 | at org.neo4j.jdbc.http.HttpDriver.connect(HttpDriver.java:68)
migration_1 | at java.sql.DriverManager.getConnection(DriverManager.java:664)
migration_1 | at java.sql.DriverManager.getConnection(DriverManager.java:208)
migration_1 | at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153)
migration_1 | at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144)
migration_1 | at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:196)
migration_1 | at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:159)
migration_1 | at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
migration_1 | at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
migration_1 | ... 23 more
What confuses me is, that there is A valid URL format is: 'jdbc:neo4j:http://<host>:<port>' which indicates the HttpDriver and not the BoltDriver....
Hey,
maybe my setup is quite special, but I do have issues when I use more than one jdbc driver at once.
I configured the mysql jdbc driver and the BoltDriver for my neo4j jdbc connection. You can find the code here: https://github.com/unterstein/neo4j-beer-demo/blob/master/src/main/scala/Importer.scala
and a configuration as shown here:
But when I run this application, I get the following error message:
What confuses me is, that there is
A valid URL format is: 'jdbc:neo4j:http://<host>:<port>'
which indicates theHttpDriver
and not theBoltDriver
....You can run my setup as described here: https://github.com/unterstein/neo4j-beer-demo
In my other demos, I fixed this issue by using the neo4j java driver without jdbc, but I would love to be able to use the jdbc driver as well :)
Thanks Johannes