Issues with the activerecord-sybase-adapter

76 views
Skip to first unread message

Trevoke

unread,
Sep 8, 2009, 11:23:28 AM9/8/09
to Ruby On Rails Sybase Developers
I'm on Windows XP, trying to connect to Sybase ASE 12.
Here's what I get:

Here's what I have:
Ruby 1.8.7
Rails 2.3.3 (activerecord 2.3.3, etc)
activerecord-sybase-adapter ( http://itsignals.cascadia.com.au/?p=23 )

Here is the base code (login info was changed to protect me)
require 'rubygems'
require 'activerecord'

a = ActiveRecord::Base.establish_connection(
:adapter => "sybase",
:host => "localhost",
:port => 123,
:username => "read_only",
:password => "read_only",
:database => "mydb"
)

puts a
puts

a.connection
_________
Here is the output:

#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x3e1b740>

c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/sybct.rb:27:in `connect':
connect failed (RuntimeError)
from c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/sybct.rb:27:in
`open'
from c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/sybsql.rb:
269:in
`initialize'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-sybase-adapter-1.0.0.9250/
lib/active_record/connection_adapters/sybase_adapter.rb:46:in
`new'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-sybase-adapter-1.0.0.9250/
lib/active_record/connection_adapters/sybase_adapter.rb:46:in
`sybase_connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:223:in
`send'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:223:in
`new_connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:245:in
`checkout_new_connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:188:in
`checkout'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:184:in
`loop'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:184:in
`checkout'
from c:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:183:in
`checkout'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/connection_pool.rb:98:in
`connection'
from C:/scripts/OneOffs/lib/TalkingToPacs.rb:16

___

sybase_adapter.rb, line 45:
ConnectionAdapters::SybaseAdapter.new(
SybSQL.new({'S' => host, 'U' => username, 'P' => password},
ConnectionAdapters::SybaseAdapterContext), database, config,
logger)

___

sybct.rb (line 27 is indicated)

class SybConnection
def SybConnection.open (*args)
conn = nil
raise("illegal args count") if( args.length < 3 )
ctx = args[0]
srv = args[1]
user = args[2]
psw = "" ; appname = nil; hname = nil;
psw = args[3] if(args.length >= 4 )
appname = args[4] if(args.length >= 5 )
hname = args[5] if(args.length >= 6 )
begin
conn = SybConnection.new( ctx )
if( hname != nil ) then
raise("NG: setprop(hostname)") unless( conn.setprop
(CS_HOSTNAME,hname
))
end
# Open a Server connection.
conn.connect( ctx, srv, user, psw, appname ) ## THIS IS LINE 27
##
rescue
conn.delete if( conn.kind_of?( SybConnection ) )
conn = nil # No use ( for GC or callback ??? )
raise # Regenerates exception
end
return conn
end
end

___

I am out of my league when it comes to drivers, so I don't know the
next
steps to take to troubleshoot this. Ideas are very welcome. DLL
suggestions, etc etc, are also welcome :) Getting this to work would
help me immensely (and possibly the community, too).

Trevoke

unread,
Sep 8, 2009, 1:17:44 PM9/8/09
to Ruby On Rails Sybase Developers
I was told to set some information in my c:\sybase\ini\sql.ini file
(like port information, or instance). I did. I previously did not have
a connection pre-set in the sql.ini file. The connection looks like
this:
[PACS]
master=NLWNSCK,localhost,20000
query=NLWNSCK,localhost,20000

Connection with isql was successful, and I was able to run a query:
select * from event where event_dttm > '2009-09-07'
go

That worked.

Connection in Ruby with:
require 'rubygems'
require 'sybsql'
SybSQL.new({'S' => 'myserver', 'U' => 'read_only', 'P' =>
'read_only'})

Gave me an acceptable result (a non-error connection string)

Now...
____________
require 'rubygems'
require 'activerecord'

a = ActiveRecord::Base.establish_connection(
:adapter => "sybase",
:host => "PACS",
:username => "read_only",
:password => "read_only",
:database => "ims"
)


begin
b = a.connection
puts b.execute "select * from event where event_dttm > '2009-09-08'"
rescue RuntimeError => e
puts e
end
_____________

c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/sybct.rb:69: [BUG]
Segmentation fault
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-mswin32]


This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.

______________

Line 69 of sybct is :
def fetchloop ( maxrows=0, strip=true, max_bind_column=nil,
rowproc=nil )
$stderr.print("FetchLoop in\n") if( $DEBUG)
rcnt = 0
rowlist = []
columns = self.bind_columns( max_bind_column)
unless ( columns) then
self.cancel( CS_CANCEL_CURRENT)
return false
end

# fetch loop
while( true )
(fetch_status, row) = self.fetch(strip) ## THIS IS LINE 69 ##
....
....
....
What next? I'm glad I was able to move forward a step already!

Trevoke

unread,
Sep 11, 2009, 12:54:50 PM9/11/09
to Ruby On Rails Sybase Developers
Reply all
Reply to author
Forward
0 new messages