Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whats the highest Rails version supported? Rails 5.2.2 is not working #9

Open
skoona opened this issue Apr 12, 2019 · 19 comments
Open

Comments

@skoona
Copy link

skoona commented Apr 12, 2019

wrong number of arguments (given 4, expected 1..3) is the general response for every combination of drivers I've attempted. I happy to keep digging, but it seems as lost cause, which is why I ask "What is the highest Rails version supported by active record-jdbcas400-adapter?"

@pierrickrouxel
Copy link
Owner

I don’t know. I don’t do Ruby anymore. When I built this library I was in Rails 4.

@rsov
Copy link
Contributor

rsov commented Apr 12, 2019

@skoona Have you tried activerecord-jdbc-adapter, branch 52-stable?
If that one doesn't work I have a merging_branch for activerecord-jdbc-adapter that has many AS400/Rails 5.2 fixes

@skoona
Copy link
Author

skoona commented Apr 12, 2019

@rsov I will try branch 52-stable in a few minutes and let you know.

Ran out of time on Friday; will try it first thing on Monday. Thanks

@skoona
Copy link
Author

skoona commented Apr 15, 2019

@rsov

FYI:

Rails 5.2.3, JRuby-9.2.7.0, OS/400-7.2

Tried activerecord-jdbc-adapter, branch 52-stable and it gets me past arity error. Have not been successful reading tables yet; seems to be schema related; working on it now.

@rsov
Copy link
Contributor

rsov commented Apr 15, 2019

@skoona If you have same table name in multiple schemas the adapter will get confused. You can specify the table directly like:

class User < ActiveRecord::Base
   self.table_name = 'SCHEMA.USERS'
end

@skoona
Copy link
Author

skoona commented Apr 15, 2019

@rsov It was a schema issue on my end, corrected it and things appear to be working. I will be working closely with it for the next few weeks.

Thanks for you help.

@skoona
Copy link
Author

skoona commented Apr 26, 2019

All the AS400 SQL things I need for this app are accessible (Tables Views StoredProcs), so it's safe to close this issue.

@skoona skoona closed this as completed Apr 26, 2019
@skoona skoona reopened this May 3, 2019
@skoona
Copy link
Author

skoona commented May 3, 2019

Things were going along fine until I attempted to establish an JNDI connection through Tomcat using a Warbler build. Is there a branch on active record-jdbc-adapter or active record-jdbcas400-adapter that has more complete coverage? I realize JNDI takes a different path through this code and I'm available to test any branch that offers a solution to connecting an AS400(7.+) to ActiveRecord(5.2+)

@skoona skoona closed this as completed May 3, 2019
@rsov
Copy link
Contributor

rsov commented May 3, 2019

What is the error you're getting?

@skoona
Copy link
Author

skoona commented May 3, 2019

"wrong number of arguments (given 4, expected 1..3)"

vendor/bundle/bundler/gems/activerecord-jdbc-adapter-a9a1ca49cb26/lib/arjdbc/abstract/core.rb:12:in `initialize'
vendor/bundle/bundler/gems/activerecord-jdbc-adapter-a9a1ca49cb26/lib/arjdbc/jdbc/callbacks.rb:12:in `new'
vendor/bundle/bundler/gems/activerecord-jdbc-adapter-a9a1ca49cb26/lib/arjdbc/jdbc/connection_methods.rb:8:in `jdbc_connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:811:in `new_connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:855:in `checkout_new_connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:834:in `try_to_checkout_new_connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:795:in `acquire_connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:523:in `checkout'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1014:in `retrieve_connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:90:in `connection'
vendor/bundle/gems/activerecord-5.2.3/lib/active_record/migration.rb:554:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
vendor/bundle/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:98:in `run_callbacks'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
vendor/bundle/gems/railties-5.2.3/lib/rails/rack/logger.rb:38:in `call_app'
vendor/bundle/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `block in call'
vendor/bundle/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `block in tagged'
vendor/bundle/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:28:in `tagged'
vendor/bundle/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `tagged'
vendor/bundle/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:in `call'
vendor/bundle/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:27:in `call'
vendor/bundle/gems/rack-2.0.7/lib/rack/method_override.rb:22:in `call'
vendor/bundle/gems/rack-2.0.7/lib/rack/runtime.rb:22:in `call'
vendor/bundle/gems/activesupport-5.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:in `call'
vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb:127:in `call'
vendor/bundle/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
vendor/bundle/gems/webpacker-4.0.2/lib/webpacker/dev_server_proxy.rb:29:in `perform_request'
vendor/bundle/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in `call'
vendor/bundle/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
uri:classloader:/rack/handler/servlet.rb:22:in `call'

@skoona skoona reopened this May 3, 2019
@rsov
Copy link
Contributor

rsov commented May 3, 2019

Does your Gemfile has this?

gem 'activerecord-jdbc-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git', branch: '52-stable'

@skoona
Copy link
Author

skoona commented May 3, 2019

Yes,

# gem 'activerecord-jdbc-adapter', '~> 52.1'
gem 'activerecord-jdbc-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', branch: '52-stable'
gem 'jdbc-as400'

Again, the rails console using adapter: as400 works normally.

@skoona
Copy link
Author

skoona commented May 3, 2019

database.yml: I've cycled through adapters type of 'jndi', 'as400', and 'jdbc'

jndi_defaults: &jndi_defaults
  adapter: jdbc #jndi #as400 
  jndi: java:comp/env/jdbc/myaDataSourceRef
  driver: com.ibm.as400.access.AS400JDBCDriver
  dialect: as400

@rsov
Copy link
Contributor

rsov commented May 3, 2019

Hmmm, it does seem like the issue with jndi

Here's mine

production:
  adapter: as400
  driver: com.ibm.as400.access.AS400JDBCDriver
  url: jdbc:as400://......

@skoona
Copy link
Author

skoona commented May 3, 2019

I would say your config is not running in an Application Server like Tomcat... based the absence of jndi: java:comp/env/jdbc/myaDataSourceRef

@rsov
Copy link
Contributor

rsov commented May 3, 2019

I am, Tomcat 8. Warbled into a .war file

@skoona
Copy link
Author

skoona commented May 3, 2019

I'm tomcat 7. I'll upgrade to 8 today, since this is very early in a new project.

I had understood that JNDI was the only way to engage Tomcat's features, and not using JNDI meant you were bypassing any benefits a AppServer might provide.

Let's see if bypassing works for me on TC-7

@skoona
Copy link
Author

skoona commented May 3, 2019

@rsov Bypassing JNDI, simular to your config, does provide a useable database connection; thanks for the tip. I do note that DB pooling and several DevOps separation will be missing until JNDI is re-enabled. By DevOps..., I mean that things like username/passwords were managed by them and now I will need to put them into codebase or find some side method externalize them.

Anything you can do to restore JNDI will be greatly appreciated. I will commit now to help test!

@rsov
Copy link
Contributor

rsov commented May 3, 2019

I am not too familiar with JNDI or how it works

Configuring pooling and password/username in database.yml config is pretty standard in ruby community. You can use the ENV to pass the data if you don't feel safe keeping it in the codebase.

It would like something like this:

production:
  adapter: as400
  driver: com.ibm.as400.access.AS400JDBCDriver
  url: jdbc:as400:.......;date format=iso
  username: <%= ENV['DATABASE_USERNAME'] %>
  password: <%= ENV['DATABASE_PASSWORD'] %>
  pool: 20

date format=iso is solution to date objects being null before 1940 or after 2039

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants