Using the JDBC OrientDB Driver with ActiveRecord

What is the correct way to use the OrientDB JDBC driver with ActiveRecord?

I am trying to connect a Rails 3.2 application to OrientDB 1.4. I installed gem activerecord-jdbc-adapter and configured 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 JDBC driver as follows:

 # in config/application.rb: require '/home/myuser/jars/orientdb-jdbc-1.4.0-all.jar' 

When the application starts (using rails s ), the following exception occurs:

 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 something missing in my configuration? What is the correct way to use the OrientDB JDBC driver with ActiveRecord?

+8
ruby-on-rails activerecord jruby jdbc orientdb
source share
1 answer

Although activerecord-jdbc-adapter (theoretically) supports any JDBC compiler, it uses an API and makes a few assumptions that may not work well for some. Especially with not quite compatible drivers, such as orientdb-jdbc (at least version 1.4).

In this case, AR-JDBC tries to resolve the supported types from the DB metadata: http://git.io/s7g47A , but since metadata.getTypeInfo() returns an unexpected null instead of the actual ResulSet everything fails. This can be improved by handling the "null" types by overriding the native_database_types method in Ruby and / or some additional code on the AR-JDBC side, although it may still not be enough for the OrientDB driver to fully use it with AR-JDBC ... sounds very good for the AR-JDBC extension (assuming OrientDB can handle the SQL that ActiveRecors / AREL generates).

+1
source share

All Articles