arkadiyk / ar-sybase-jdbc-adapter Goto Github PK
View Code? Open in Web Editor NEWMy attempt to fix limit and offset for Rails 3 / JRuby / JDBC and Sybase ASE
License: MIT License
My attempt to fix limit and offset for Rails 3 / JRuby / JDBC and Sybase ASE
License: MIT License
Hi,
Kudos for the effort to make Rails and ActiveRecord talk to the Sybase database.
I know that this project is already abandoned and probably there won't be any attention paid to this discussion at all, but still I would like to take my shot.
I am trying to make a very simple Rails application work with the Sybase adapter. I am using a relatively old Rails - version 2.3.11, and the latest Sybase ASE 15.7, and I am stuck at the db:migrate execution: I get this error
rake aborted!
uninitialized constant ActiveRecord::ConnectionAdapters::SybaseJdbcConnection
Could you please elaborate with which versions of the Rails framework, and the 'parent' ActiveRecord-JDBC Adapter is the Sybase adapter compatible with ? It seems that when using other version of the AR-JDBC adapter than 1.1.3, I get
Unable to activate ar-sybase-jdbc-adapter-0.2.2, because activerecord-jdbc-adapter-1.2.2.1 conflicts with activerecord-jdbc-adapter (~> 1.1.1)
But the 1.1.3 version itself yields the other problem.
Cheers,
Krum.
I'm trying to setup JRuby on Rails work with Sybase using ar-sybase-jdbc-adapter & activerecord-jdbc-adapter, it shows the existing data in table properly, but if I try to add/edit/delete any data, it throws the following error. The table has a primary key column which is not called as 'id', but I modified the model to specify the primary key -
ActiveRecord::JDBCError (Catalog procedure 'sp_pkeys' can not be run in a transaction.):
arjdbc/jdbc/RubyJdbcConnection.java:121:in columns' activerecord-jdbc-adapter (1.1.3) lib/arjdbc/jdbc/adapter.rb:227:in
jdbc_columns'
arel (2.0.10) lib/arel/table.rb:97:in columns' arel (2.0.10) lib/arel/table.rb:104:in
[]'
activerecord (3.0.8) lib/active_record/base.rb:1727:in arel_attributes_values' org/jruby/RubyArray.java:1615:in
each'
activerecord (3.0.8) lib/active_record/base.rb:1718:in arel_attributes_values' activerecord (3.0.8) lib/active_record/persistence.rb:269:in
create'
activerecord (3.0.8) lib/active_record/timestamp.rb:47:in create' activerecord (3.0.8) lib/active_record/callbacks.rb:277:in
create'
activesupport (3.0.8) lib/active_support/callbacks.rb:429:in _run_create_callbacks' activerecord (3.0.8) lib/active_record/callbacks.rb:277:in
create'
activerecord (3.0.8) lib/active_record/persistence.rb:250:in create_or_update' activerecord (3.0.8) lib/active_record/callbacks.rb:273:in
create_or_update'
activesupport (3.0.8) lib/active_support/callbacks.rb:429:in _run_save_callbacks' activerecord (3.0.8) lib/active_record/callbacks.rb:273:in
create_or_update'
activerecord (3.0.8) lib/active_record/persistence.rb:40:in save' activerecord (3.0.8) lib/active_record/validations.rb:43:in
save'
activerecord (3.0.8) lib/active_record/attribute_methods/dirty.rb:21:in save' activerecord (3.0.8) lib/active_record/transactions.rb:240:in
save'
activerecord (3.0.8) lib/active_record/transactions.rb:292:in with_transaction_returning_status' activerecord (3.0.8) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
transaction'
Hi Arkadiy,
I would like to ask you a consulting question about the Sybase adapter, no particular bug is being observed.
I managed to rewrite my small Rails 2 application to be Rails 3 - based, and luckily those Arel-based issues are gone indeed.
I had some difficulties with setting up my landscape, so for the sake of sharing my experience, I will just list them briefly:
Okay, and thus I was able to connect to the Sybase ASE database. When I executed 'rake db:migrate' I got an ActiveRecord::JDBCError because the SQL statement produced was obviously wrong for Sybase. What puzzles me here is the output I got when I reexecuted the task with the '--trace' option: the stacktrace shown did not contain any traces from using the 'ar-sybase-jdbc-adapter' gem. All the files that were shown were either in the ActiveRecord framework, or in the activerecord-jdbc-adapter gem. I guess that because of some reason the Sybase adapter didn't get called ? Shouldn't 'db:migrate' go through the Sybase adapter ?
What's even more strange is the use of the 'mssql' adapter:
arjdbc/jdbc/RubyJdbcConnection.java:321:in execute_update' c:/jruby-1.7.2/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/mssql/adapter.rb:386:in
_execute'
c:/jruby-1.7.2/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:209:in execute' c:/jruby-1.7.2/lib/ruby/gems/shared/gems/activerecord-3.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:280:in
log'
Could you please give some hint/advise here ? Why does the workflow go through the mssql adapter, and not through the Sybase one ? Indeed, database.yml contains the 'adapter: jdbc' line, which additionally puzzles me - shouldn't the adapter be loaded by its own dedicated name, like the other ones ? I see that it uses some different mechanism instead - by specifying a 'dialect' property and using some generic jTds driver. The 'Sybase native JDBC' driver 'com.sybase.jdbc4.jdbc.SybDriver' which comes with the sample Java snippets of the Sybase ASE installation, is never used.
I just found the following, inside 'C:\jruby-1.7.2\lib\ruby\gems\shared\gems\ar-sybase-jdbc-adapter-0.2.0\lib\arjdbc\sybase_jtds.rb':
def supports_migrations?
false
end
Does that mean that the Sybase adapter does not support migrations ?
Thanks and Kindest Regards,
Krum.
Test
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.