{"action":"created","issue":{"url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/issues/621","labels_url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/issues/621/labels{/name}","comments_url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/issues/621/comments","events_url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/issues/621/events","html_url":"https://github.com/jruby/activerecord-jdbc-adapter/issues/621","id":58115798,"number":621,"title":"(NoMethodError) undefined method `newConnection' for ActiveRecord::ConnectionAdapters::JdbcConnection::JdbcConnectionFactoryImpl","user":{"login":"donv","id":57275,"avatar_url":"https://avatars.githubusercontent.com/u/57275?v=3","gravatar_id":"","url":"https://api.github.com/users/donv","html_url":"https://github.com/donv","followers_url":"https://api.github.com/users/donv/followers","following_url":"https://api.github.com/users/donv/following{/other_user}","gists_url":"https://api.github.com/users/donv/gists{/gist_id}","starred_url":"https://api.github.com/users/donv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donv/subscriptions","organizations_url":"https://api.github.com/users/donv/orgs","repos_url":"https://api.github.com/users/donv/repos","events_url":"https://api.github.com/users/donv/events{/privacy}","received_events_url":"https://api.github.com/users/donv/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/labels/rails-4.x","name":"rails-4.x","color":"6439f9"},{"url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/labels/sqlite3","name":"sqlite3","color":"84C9EC"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-18T19:32:41Z","updated_at":"2015-02-19T19:51:49Z","closed_at":null,"body":"Hi!\r\n\r\nI am  upgrading an Android app from ActiveRecord 3.2.19 to 4.0.13 using ARJDBC 1.3.14.  I encountered and fixed a problem with thread_safe which is tracked as https://github.com/ruby-concurrency/thread_safe/pull/4 .  I have now encountered a problem with the sqlite connection.  There are many components involved (ActiveRecord, ARJDBC, SQLDroid, etc), but I think tracking it here is a good place until we know more.\r\n\r\nOne question:  In the code below we check if ```ActiveRecord::Base.connected?``` is true directly after calling ```ActiveRecord::Base.establish_connection```.  It returns ```false```.  Should it be ```true```?\r\n\r\nThe code to connect and execute a statement is like this:\r\n\r\n```ruby\r\nrequire 'active_record'\r\n\r\nDB_DIR = 'read/writable/file'\r\nDB_DIR_AUDIT_LOG = 'read/writable/file'\r\nENVIRONMENT = 'development'\r\n\r\nconnection_options = {\r\n    :adapter => 'jdbcsqlite3',\r\n    :driver => 'org.sqldroid.SQLDroidDriver',\r\n    :url => \"jdbc:sqldroid:#{DB_DIR}?timeout=60000&retry=1000\",\r\n    :database => DB_DIR,\r\n    :pool => 20,\r\n}\r\n\r\naudit_log_connection_options = {\r\n    :adapter => 'jdbcsqlite3',\r\n    :driver => 'org.sqldroid.SQLDroidDriver',\r\n    :url => \"jdbc:sqldroid:#{DB_DIR_AUDIT_LOG}?timeout=5000&retry=1000\",\r\n    :database => DB_DIR_AUDIT_LOG,\r\n    :pool => 20,\r\n}\r\n\r\nActiveRecord::Base.configurations = {\r\n    ENVIRONMENT => connection_options,\r\n    \"#{ENVIRONMENT}_audit_log\" => audit_log_connection_options,\r\n}\r\n\r\norg.sqldroid.Log.LEVEL = android.util.Log::VERBOSE\r\n\r\nputs 'connecting...'\r\nActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ENVIRONMENT])\r\nputs \"ActiveRecord::Base.connected?: #{ActiveRecord::Base.connected?}\"\r\nAuditLog.establish_connection(ActiveRecord::Base.configurations[\"#{ENVIRONMENT}_audit_log\"])\r\nputs \"AuditLog.connected?: #{ActiveRecord::Base.connected?}\"\r\n\r\nlogger.info 'Generating new audit log database'\r\nAuditLog.connection.execute %q{CREATE TABLE \"audit_logs\" (\"id\" integer primary key autoincrement not null, \"operation\" varchar(6) NOT NULL, \"model_name\" varchar(32) NOT NULL, \"record_id\" varchar(22) NOT NULL, \"new_values\" text, \"source\" varchar(255) NOT NULL, \"user_id\" varchar(255), \"expired\" boolean DEFAULT 'f' NOT NULL, \"flush\" boolean, \"created_at\" datetime, \"updated_at\" datetime)}\r\n```\r\n\r\nThis gives the following output:\r\n\r\n```\r\nI/Nettbuss( 1759): Using database at: /data/data/no.datek.nettbuss.operator/files/sqlite-production_test\r\nI/System.out( 1759): connecting...\r\nD/dalvikvm( 1759): GC_CONCURRENT freed 1843K, 59% free 46022K/110535K, paused 1ms+3ms\r\nD/dalvikvm( 1759): GC_CONCURRENT freed 1860K, 59% free 46210K/110535K, paused 1ms+4ms\r\nD/dalvikvm( 1759): GC_CONCURRENT freed 1702K, 58% free 46547K/110535K, paused 0ms+3ms\r\nD/dalvikvm( 1759): GC_CONCURRENT freed 1695K, 58% free 46899K/110535K, paused 1ms+13ms\r\nD/dalvikvm( 1759): GC_FOR_ALLOC freed 2094K, 58% free 46853K/110535K, paused 74ms\r\nD/dalvikvm( 1759): GC_CONCURRENT freed 1841K, 58% free 47050K/110535K, paused 1ms+2ms\r\nD/dalvikvm( 1759): GC_CONCURRENT freed 1812K, 58% free 47285K/110535K, paused 1ms+2ms\r\nD/dalvikvm( 1759): GC_CONCURRENT freed 1886K, 58% free 47447K/110535K, paused 1ms+2ms\r\nI/System.out( 1759): ActiveRecord::Base.connected?: false\r\nI/System.out( 1759): AuditLog.connected?: false\r\nI/Nettbuss( 1759): Generating new audit log database\r\nW/System.err( 1759): org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `newConnection' for #<ActiveRecord::ConnectionAdapters::JdbcConnection::JdbcConnectionFactoryImpl:0xa2fb20e8>\r\nW/System.err( 1759): \tat org.jruby.RubyBasicObject.method_missing(org/jruby/RubyBasicObject.java:1494)\r\nW/System.err( 1759): \tat RUBY.method_missing(file:/data/app/no.datek.nettbuss.operator-2.apk!/ruboto/base.rb:22)\r\nW/System.err( 1759): \tat arjdbc.jdbc.RubyJdbcConnection.init_connection(arjdbc/jdbc/RubyJdbcConnection.java:450)\r\nW/System.err( 1759): \tat RUBY.initialize(/data/app/no.datek.nettbuss.operator-2.apk!/arjdbc/jdbc/connection.rb:15)\r\nW/System.err( 1759): \tat RUBY.initialize(/data/app/no.datek.nettbuss.operator-2.apk!/arjdbc/jdbc/adapter.rb:68)\r\nW/System.err( 1759): \tat RUBY.jdbc_connection(/data/app/no.datek.nettbuss.operator-2.apk!/arjdbc/jdbc/connection_methods.rb:12)\r\nW/System.err( 1759): \tat RUBY.sqlite3_connection(/data/app/no.datek.nettbuss.operator-2.apk!/arjdbc/sqlite3/connection_methods.rb:24)\r\nW/System.err( 1759): \tat RUBY.new_connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:440)\r\nW/System.err( 1759): \tat RUBY.checkout_new_connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:450)\r\nW/System.err( 1759): \tat RUBY.acquire_connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:421)\r\nW/System.err( 1759): \tat RUBY.checkout(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:356)\r\nW/System.err( 1759): \tat RUBY.mon_synchronize(/data/app/no.datek.nettbuss.operator-2.apk!/jruby.home/lib/ruby/1.9/monitor.rb:211)\r\nW/System.err( 1759): \tat RUBY.checkout(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:355)\r\nW/System.err( 1759): \tat RUBY.connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:265)\r\nW/System.err( 1759): \tat RUBY.mon_synchronize(/data/app/no.datek.nettbuss.operator-2.apk!/jruby.home/lib/ruby/1.9/monitor.rb:211)\r\nW/System.err( 1759): \tat RUBY.connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:264)\r\nW/System.err( 1759): \tat RUBY.retrieve_connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_adapters/abstract/connection_pool.rb:546)\r\nW/System.err( 1759): \tat RUBY.retrieve_connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_handling.rb:79)\r\nW/System.err( 1759): \tat RUBY.connection(/data/app/no.datek.nettbuss.operator-2.apk!/active_record/connection_handling.rb:53)\r\nW/System.err( 1759): \tat RUBY.(root)(/data/app/no.datek.nettbuss.operator-2.apk!/setup_activerecord_sqlite.rb:43)\r\nW/System.err( 1759): \tat org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1071)\r\nW/System.err( 1759): \tat RUBY.(root)(file:/data/app/no.datek.nettbuss.operator-2.apk!/active_support/dependencies.rb:1)\r\nW/System.err( 1759): \tat RUBY.require(file:/data/app/no.datek.nettbuss.operator-2.apk!/active_support/dependencies.rb:229)\r\nW/System.err( 1759): \tat RUBY.load_dependency(file:/data/app/no.datek.nettbuss.operator-2.apk!/active_support/dependencies.rb:214)\r\nW/System.err( 1759): \tat RUBY.require(file:/data/app/no.datek.nettbuss.operator-2.apk!/active_support/dependencies.rb:229)\r\nW/System.err( 1759): \tat org.jruby.RubyProc.call(org/jruby/RubyProc.java:271)\r\nW/System.err( 1759): \tat RUBY.initialize(file:/data/app/no.datek.nettbuss.operator-2.apk!/startup_sequence.rb:72)\r\nW/System.err( 1759): \tat org.jruby.RubyProc.call(org/jruby/RubyProc.java:271)\r\nW/System.err( 1759): \tat RUBY.initialize(file:/data/app/no.datek.nettbuss.operator-2.apk!/splash.rb:13)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/issues/comments/75123117","html_url":"https://github.com/jruby/activerecord-jdbc-adapter/issues/621#issuecomment-75123117","issue_url":"https://api.github.com/repos/jruby/activerecord-jdbc-adapter/issues/621","id":75123117,"user":{"login":"kares","id":45967,"avatar_url":"https://avatars.githubusercontent.com/u/45967?v=3","gravatar_id":"","url":"https://api.github.com/users/kares","html_url":"https://github.com/kares","followers_url":"https://api.github.com/users/kares/followers","following_url":"https://api.github.com/users/kares/following{/other_user}","gists_url":"https://api.github.com/users/kares/gists{/gist_id}","starred_url":"https://api.github.com/users/kares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kares/subscriptions","organizations_url":"https://api.github.com/users/kares/orgs","repos_url":"https://api.github.com/users/kares/repos","events_url":"https://api.github.com/users/kares/events{/privacy}","received_events_url":"https://api.github.com/users/kares/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T19:51:49Z","updated_at":"2015-02-19T19:51:49Z","body":"@donv cool! ... also moved the javax.naming references (loaded when RubyJdbcConnection does) : \r\n0ac2f63d4eb749a488b17391b083aa47981239d5 should be enough - most JNDI code resides in *src/java/arjdbc/jdbc/DataSourceConnectionFactory.java* which should not get loaded on Android. let me know if you run into more issues - SQLite support is still \"hacky\" from time to time esp. since the new sqlite-jdbc release(s) introduced some new bugs to work-around."}}