Jeremy,

Apparently the native JDBC adapter is going to have to be extended to
JDBC::Sybase.  I immediately ran into a problem with getting 1 record
back.

DB[:table].first
Model.first
Model[0]
Model[:id => 1]

All give this:

Sequel::DatabaseError: NativeException:
com.sybase.jdbc2.jdbc.SybSQLException: ASA Error -131: Syntax error
near 'LIMIT'
 on line 1
        from com/sybase/jdbc2/tds/Tds.java:2884:in `processEed'
        from com/sybase/jdbc2/tds/Tds.java:2206:in `nextResult'
        from com/sybase/jdbc2/jdbc/ResultGetter.java:69:in
`nextResult'
        from com/sybase/jdbc2/jdbc/SybStatement.java:220:in
`nextResult'
        from com/sybase/jdbc2/jdbc/SybStatement.java:203:in
`nextResult'
        from com/sybase/jdbc2/jdbc/SybStatement.java:1596:in
`queryLoop'
        from com/sybase/jdbc2/jdbc/SybStatement.java:1581:in
`executeQuery'
        from com/sybase/jdbc2/jdbc/SybStatement.java:419:in
`executeQuery'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/sql.rb:67:in `execute'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/database.rb:450:in `log_yield'
        from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/adapters/jdbc.rb:190:in `execute'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/connection_pool/threaded.rb:84:in `hold'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/database.rb:553:in `synchronize'
        from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/adapters/jdbc.rb:186:in `execute'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/dataset/actions.rb:384:in `execute'
        from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/adapters/jdbc.rb:529:in `fetch_rows'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/dataset/actions.rb:92:in `each'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/dataset/actions.rb:319:in `single_record'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/dataset/actions.rb:139:in `first'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/dataset/actions.rb:21:in `[]'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/model/base.rb:475:in `primary_key_lookup'
        from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
sequel/model/base.rb:94:in `[]'
        from (irb):2>>



Is there a way to see the sql generated and not to execute it?

If I start to create a JDBC:Sybase adapter, where is the best place to
start?  What other JDBC adapter tests and code should I look at to
mimic?


Sorry about the stupid questions, but it looks like I'll have to do
this since I don't think anyone else is going to and we are going to
need this here if we are ever going to use the kewl kids' tools.

Thanks,

GregD


On May 20, 12:31 pm, GregD <[email protected]> wrote:
> Update:
>
> connected.  I had it correct.  The DB was really old and was not using
> jconn3.  It was a Sybase 9 DB and not a Sybase 11 DB.  I really did
> not expect that since most everyone of our DBs are Sybase 11 and a few
> are Sybase 10.  This particular DB is about 5 years old and has not
> been upgraded yet.
>
> Sorry, about that.
>
> As far as a native Sybase adapter, is there any docs out there to help
> in creating one?  Could I look at one of the existing adapters like
> DB2 or Oracle?  I'm a little cautious on using jruby vs MRI ruby
> because of gem support.
>
> Thanks Jeremy.
>
> GregD
>
> On May 20, 11:58 am, Jeremy Evans <[email protected]> wrote:
>
>
>
>
>
> > On May 20, 8:37 am, GregD <[email protected]> wrote:
>
> > > Jeremy,
>
> > > Well, I guess I have the connection string wrong then because the
> > > jconn3.jar is correct.
>
> > > When I do:
>
> > > DB = Sequel.connect("jdbc:sybase:Tds:host:port?blah..blah)
>
> > > and then do
>
> > > DB.tables
>
> > > I get:
>
> > > Sequel::DatabaseConnectionError: NoMethodError: undefined method `new'
> > > for nil:NilClass
> > >         from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/adapters/jdbc.rb:170:in `connect'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/database.rb:91:in `initialize'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool.rb:91:in `call'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool.rb:91:in `make_new'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool/threaded.rb:126:in `make_new
> > > '
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool/threaded.rb:112:in `availabl
> > > e'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool/threaded.rb:102:in `acquire'
>
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool/threaded.rb:146:in `sync'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool/threaded.rb:146:in `sync'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool/threaded.rb:101:in `acquire'
>
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/connection_pool/threaded.rb:74:in `hold'
> > >         from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/database.rb:553:in `synchronize'
> > >         from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/adapters/jdbc.rb:366:in `metadata'
> > >         from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/sequel-3.11.0/lib/
> > > sequel/adapters/jdbc.rb:254:in `tables'
> > >         from (irb):31
>
> > > Any clues?  How do I know it is using the jconn3.jar to try the
> > > connection?
>
> > > Thank,
>
> > > GregD
>
> > > On May 20, 11:21 am, Jeremy Evans <[email protected]> wrote:
>
> > > > On May 20, 8:10 am, GregD <[email protected]> wrote:
>
> > > > > I finally got around to trying this with jruby and I'm having no
> > > > > success.  Can anyone help me please?
>
> > > > > In jirb,  I do the following:
> > > > > require 'java'
> > > > > require 'rubygems'
> > > > > require 'sequel'
>
> > > > > Now comes the interesting part:  which Sybase jar file to require?
> > > > > jconn3.jar or jodbc.jar
>
> > > > > require '<path-to-Sybase-Java-lib>/jconn3.jar'
>
> > > > > Now what?
>
> > > > > I tried all kinds of connections strings based on Jconnect format
> > > > > similar to:
>
> > > > > jdbc:sybase:Tds:host:port?
> > > > > ServiceName=database&user=user&password=password
>
> > > > > Does anybody have any experience doing this?  Could someone please
> > > > > help?
>
> > > > > Is jtds driver possible?
>
> > > > > I'd like to use all the ruby goodies to test existing java code like
> > > > > rspec, machinist/factory girl, maybe cucumber with swinger.  However,
> > > > > I don't have a Sybase JDBC adapter for sequel.  Active Record is too
> > > > > hard/too painful to extract from rails.  It looks like Datamapper may
> > > > > not have support either.
>
> > > > > If I have to write an adapter myself, where do I begin?  But, I really
> > > > > don't feel comfortable doing that at this moment.
>
> > > > Sequel passes JDBC connection strings directly to JDBC.  So as long as
> > > > you have a valid JDBC connection string and have loaded the necessary
> > > > jars, it should work with Sequel.  This means that if it is not
> > > > working, you probably don't have a valid JDBC connection string or
> > > > have not loaded the necessary jars.
>
> > > > If you use JTDS, Sequel will attempt to load the jdbc-jtds gem
> > > > automatically, so you may want to try that. When you use JTDS, it
> > > > assumes you are connecting to SQL Server, so it uses SQL Server
> > > > syntax.  Sequel doesn't currently have any special syntax settings for
> > > > Sybase, but you don't need to worry about that until after you can
> > > > connect.
>
> > That's what you get if there is an error when connecting.  You used to
> > get a more descriptive error message, I'll see if I can modify the
> > JDBC adapter to fix that.
>
> > I'd give JTDS a shot and see if you have more luck.  I test with the
> > JTDS driver on MSSQL, so I know that it works.
>
> > Jeremy
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sequel-talk" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/sequel-talk?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sequel-talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/sequel-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to