Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 554975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:46:02+00:00 2026-05-13T11:46:02+00:00

Problem I am trying to build a small ruby script – which will be

  • 0

Problem

I am trying to build a small ruby script – which will be run using jruby once a day – to connect to a Sybase ASE 12.5.4 database and perform a complex query.

Ultimately I intend to do some processing on the data and insert the new data in a MySQL table for use within a rails application.

Environment

  • jruby v1.4.0
  • java v1.6.0_15
  • on Ubuntu Karmic

JRuby Installed Gems

  • activerecord-jdbc-adapter (0.9.1)
  • activerecord-2.3.4

Jruby Lib Directory

  • jtds-1.2.5

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 this connects to the DB. Although I am having issues just selecting 10 rows from a database table.

Produces

For execute 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

For select_rows 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 /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

The error states that I should not return a results set but it doesn’t matter which method I use, execute, select_rows etc nothing works.

One more thing regarding queries. My original query is rather complex, I decalre variables, drop temporary tables and create temporary tables as well as populate and select from them. Using Squirrel SQL I can execute once and gain a result. Using DBI I was unable to do this in one execution, does anyone know if I can just execute the whole thing once or will I have to split it up?

Would anyone be able to give me any assistance please? Am I using jTDS properly?
Many thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:46:02+00:00Added an answer on May 13, 2026 at 11:46 am

    I had been using the Sybase drivers for sometime as suggested by @lollipopman which was helpful in getting going but as I built more complex queries I kept running into issues so I tried to revisit the original problem and with an hour or so I go it working.

    Find the open source jTDS drivers here

    require java
    require jtds-1.2.5.jar
    require rubygems
    require dbi
    
    dbh = DBI.connect('dbi:Jdbc:jtds:sybase://<host>:<port>/<db>', <username>, <password>, {'driver' => 'net.sourceforge.jtds.jdbc.Driver'} )
    

    And that is all that is needed to connect to your Sybase Database with JRuby and DBI

    Hope this helps someone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 311k
  • Answers 311k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The # character isn’t valid in a fragment identifier, so… May 13, 2026 at 10:20 pm
  • Editorial Team
    Editorial Team added an answer Problem solved. The call to the static Thread.sleep method inside… May 13, 2026 at 10:20 pm
  • Editorial Team
    Editorial Team added an answer Dependency injection springs to mind. May 13, 2026 at 10:20 pm

Related Questions

Say you have a bunch of files. Say you can store meta data to
So I'm trying to build a small 3D engine as an exercise on VC++
I have a DBAdmin class that connects to the database, and then some other
We have a few C++ solutions and we run some build scripts using batch
I am trying to build an web image server. It serves images to lots

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.