Using activerecord-jdbc-adapter to connect to db2 and specifying schema

I am converting my rails application(working fine) to jruby. I am using
db2 database, and connecting to it through activerecord-jdbc-adapter
gem. My db2 database has many schemas, and I have to query tables in
different schemas. My database.ywml file declares production environment
as :

adapter: jdbc
url: jdbc:db2://
username: uname
password: pwd

My questions is where can I specify the schema for my tables. e.g I have
a model like this

class User < ActiveRecord::Base


and when I query for this model, the query generated is
select * from uname.user
but table ‘user’ is located in ‘myschema’, and it has assumed to use
‘uname’ schema for the user ‘uname’. How, can i change configuration so
that query generated by adatper is
select * from myschema.user

any suggestion?


using set_table_name method has fixed the problem.

class User < ActiveRecord::Base

but what if I have to work with two different schemas in same

You should be able to append the currentSchema variable to the URL.
Don’t forget the semicolon at the end:

url: jdbc:db2://;