What is the proper way of using OrientDB's JDBC driver with ActiveRecord?
I am trying to connect a Rails 3.2 application to OrientDB 1.4. I installed the gem activerecord-jdbc-adapter
, and configured the database.yml
as follows:
development:
adapter: jdbc
username: admin
password: admin
driver: com.orientechnologies.orient.jdbc.OrientJdbcDriver
url: jdbc:orient:local:db/test_db2
I load the OrientDB's JDBC driver as follows:
# in config/application.rb:
require '/home/myuser/jars/orientdb-jdbc-1.4.0-all.jar'
The following exception is being thrown when the application starts (using rails s
):
java.lang.NullPointerException
at arjdbc.jdbc.RubyJdbcConnection.unmarshalResult(RubyJdbcConnection.java:1187)
at arjdbc.jdbc.RubyJdbcConnection.set_native_database_types(RubyJdbcConnection.java:537)
at arjdbc.jdbc.RubyJdbcConnection$INVOKER$i$0$0$set_native_database_types.call(RubyJdbcConnection$INVOKER$i$0$0$set_native_database_types.gen)
...
Is there something missing in my configuration? What is the proper way of using OrientDB's JDBC driver with ActiveRecord?
While activerecord-jdbc-adapter
(theoretically) supports any JDBC compilant driver, it uses APIs and makes a few assumptions that might work not so well for a few. Esp. with not-fully compliant drivers such as orientdb-jdbc (at least version 1.4) is.
In this case AR-JDBC tries to resolve supported types from the DB meta-data: http://git.io/s7g47A but since metadata.getTypeInfo()
returns an unexpected null
instead of an actual ResulSet
object all fails badly. This might be improved by handling "null" types by overriding native_database_types
method in Ruby and/or some additional code on AR-JDBC's side - although for OrientDB's "driver" it still might not be enough to get it fully functional with AR-JDBC ... sounds like a pretty good fit for an AR-JDBC extension (assuming OrientDB can handle the SQL that ActiveRecors/AREL will generate).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With