Forum: Ruby MSSQL DB connection, multiplatform, NextRecordSet

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joseph S. (Guest)
on 2009-02-20 22:30
I'm trying to find a way to use ruby to connect to a MS SQL database.

I need it to be as simple I can to run on both windows and linux
systems. So if they require different things to make them work, I want
to have the smallest difference in code that I can.

I also need to support stored procedures returning multiple record sets
so something like .NextRecordSet needs to be supported.

I can get a connection using: require 'dbi' and ODBC BUT ODBC doesn't
appear to support multiple record sets.
I've been attempting to get ADO to fall in line but, my understanding,
is that it's not very happy with linux.

So in summary:
-MSSQL DB connection
-Must be usable across Linux and Windows with minimal changes
-Must allow for multiple record sets


Does anyone have suggestions for me?

Thanks in advance.
~Makkur
Choi, Junegunn (Guest)
on 2009-02-22 11:18
(Received via mailing list)
2009/2/21 Joseph S. <removed_email_address@domain.invalid>:
>
> So in summary:
> -MSSQL DB connection
> -Must be usable across Linux and Windows with minimal changes
> -Must allow for multiple record sets
>

Hi, If it's ok to use JRuby, you can try JDBC with JRuby. I have no
experience in MSSQL and ADO, but i'm sure MSSQL provides JDBC driver
and JDBC is inherently compatible across different platforms. And if I
understood your point correctly, it supports multiple record sets as
well. The following JRuby code works with my PostgreSQL database.

stmt.execute 'select * from test_a; select * from test_b'
rset = stmt.get_result_set
while rset.next
    puts rset.get_long(1)
end

stmt.get_more_results
rset = stmt.get_result_set
while rset.next
    puts rset.get_long(1)
end
Joseph S. (Guest)
on 2009-02-23 16:25
> Hi, If it's ok to use JRuby, you can try JDBC with JRuby. I have no
> experience in MSSQL and ADO, but i'm sure MSSQL provides JDBC driver
> and JDBC is inherently compatible across different platforms. And if I
> understood your point correctly, it supports multiple record sets as
> well. The following JRuby code works with my PostgreSQL database.
>
> stmt.execute 'select * from test_a; select * from test_b'
> rset = stmt.get_result_set
> while rset.next
>     puts rset.get_long(1)
> end
>
> stmt.get_more_results
> rset = stmt.get_result_set
> while rset.next
>     puts rset.get_long(1)
> end

I'm not familiar with JRuby.
I'm fairly open to options so I'll take a look at it.
Just that it supports multiple record sets is a step forward.

Thanks for the heads up.
This topic is locked and can not be replied to.