Problem
I am trying to create a small ruby ββscript - which will be run using jruby once a day - to connect to the Sybase ASE 12.5.4 database and execute a complex query.
Ultimately, I intend to do some data processing and insert new data into the MySQL table for use in the rails application.
Environment
- jruby v1.4.0
- java v1.6.0_15
- on Ubuntu Karmic
JRuby Mounted Gemstones
- activerecord-jdbc-adapter (0.9.1)
- ActiveRecord-2.3.4
Jruby Lib Catalog
Query
SET rowcount 10
SELECT * FROM TEST_TABLE
Code snippet
require 'java'
require 'jtds-1.2.5.jar'
require 'rubygems'
require 'active_record'
config = {
:username => 'railstest',
:password => 'railstest',
:adapter => 'jdbc',
:dialect => 'sybase',
:host => 'localhost',
:database => 'railstest',
:port => '5000',
:driver => 'net.sourceforge.jtds.jdbc.Driver',
:url => 'jdbc:jtds:sybase://localhost:5000/railstest'
}
ActiveRecord::Base.establish_connection(config).connection.execute(-- QUERY --)
I can confirm that this is a database connection. Although I am having problems just picking 10 rows from the database table.
Gives out
To execute the method :
/usr/local/bin/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log': ActiveRecord::ActiveRecordError: The executeUpdate method must not return a result set.: SET rowcount 10 SELECT * FROM TEST_TABLE (ActiveRecord::StatementInvalid)
from /usr/local/bin/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.2/lib/active_record/connection_adapters/jdbc_adapter.rb:559:in `execute'
from db-test.rb:21
select_rows:
/usr/local/bin/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log': ActiveRecord::ActiveRecordError: The executeUpdate method must not return a result set.: SET rowcount 10 SELECT * FROM TEST_TABLE (ActiveRecord::StatementInvalid)
from /usr/local/bin/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.2/lib/active_record/connection_adapters/jdbc_adapter.rb:559:in `execute'
from /usr/local/bin/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.2/lib/active_record/connection_adapters/jdbc_adapter.rb:629:in `select'
from /usr/local/bin/jruby-1.4.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.2/lib/active_record/connection_adapters/jdbc_adapter.rb:550:in `select_rows'
from db-test.rb:21
, , , , execute, select_rows .. .
, . , , , . Squirrel SQL, . DBI, , -, ?
- ? jTDS?
.