Search code examples
ruby-on-railsactiverecordjdbcjrubyjtds

Cannot query table in SYSDBA table using activerecord-jdbcmssql-adapter and jdbc-jtds


I have an 1.9.3 that I am converting to jRuby. The main DB is MySql and I am having no problems using the activerecord jdbc adapter. The app also connects to a local SalesLogix DB running MS SQL and pulls data from it. For some reason, all of the tables are under the SYSDBA schema.

I can connect to the server without issue, however, whenever I attempt to query the one table it needs to query, I get the following error:

ActiveRecord::JDBCError: table: sysdba].[userinfo does not exist

If I do a find_by_sql and pass in the select statement, connects and pull data base no problem.

Here is my connection info from database.yml:

saleslogix:
    adapter: jdbcmssql
    driver: net.sourceforge.jtds.jdbc.Driver
    url: 'jdbc:jtds:sqlserver://saleslogix2:1433/DBNAME'
    username: DBUSER
    password: DBPASS

Here is the model declaration:

module SalesLogix
    class UserInfo < ActiveRecord::Base
        establish_connection :saleslogix
        set_table_name "sysdba.userinfo"
        set_primary_key :USERID

Solution

  • Turns out this was a bug. Submitted a pull request which will be merged into version 1.3:

    https://github.com/jruby/activerecord-jdbc-adapter/pull/574