I already know that what I've got is wrong. When I try to instantiate
my class, the create_table method results in the following (truncated)
stacktrace:
org.hsqldb.jdbc.Util:-1:in `sqlException': java.sql.SQLException:
Unexpected token: BEGIN in statement [BEGIN] (NativeException)
from org.hsqldb.jdbc.jdbcStatement:-1:in `fetchResult'
from org.hsqldb.jdbc.jdbcStatement:-1:in `execute'
from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke'
from sun/reflect/DelegatingMethodAccessorImpl.java:25:in
`invoke'
from java/lang/reflect/Method.java:585:in `invoke'
from org/jruby/javasupport/JavaMethod.java:298:in
`invokeWithExceptionHandling'
from org/jruby/javasupport/JavaMethod.java:259:in `invoke'
... 67 levels...
from C:/sw/jruby/lib/ruby/gems/1.8/gems/sequel-2.8.0/lib/
sequel_core/adapters/jdbc.rb:185:in `transaction'
from call.rb:70:in `initialize'
from call.rb:86
Complete Java stackTrace
java.sql.SQLException: Unexpected token: BEGIN in statement [BEGIN]
Does this error mean anything to anyone?
Thanks,
Lee
On Dec 30, 7:10 am, greymatter <[email protected]> wrote:
> I'm trying to understand how to architect an app that needs to have
> two separate database connections, both managed by Sequel. Some model
> classes will go into one database while others go into the other
> database.
>
> I've got a couple of global variables that I'm using to store the two
> connections, although I'm not really sure where they should live. I'm
> using the optional argument to Sequel::Model, hoping to specify which
> database that model belongs in. I believe that I have no choice but
> to explicitly include the table name, as well.
>
> So, one of my classes looks like this:
>
> require 'rubygems'
> require 'sequel'
>
> $transientdb = Sequel.connect('jdbc:hsqldb:mem:testmem') if
> $transientdb == nil
> $permanentdb = Sequel.connect('jdbc:hsqldb:file:testfile') if
> $permanentdb == nil
>
> class Call < Sequel::Model($transientdb[:calls])
> set_schema do
> primary_key :id
> ...
> end
>
> def initialize
> $transientdb.transaction do
> puts "Creating table 'calls'\n"
> Call.create_table
> end unless Call.table_exists?
> end
> end
>
> A table that is intended to live in the permanent database might be
> declared
>
> class Message < Sequel::Model($permanentdb[:messages])
> ...
>
> Am I going about this the right way? I'm open to suggestions for a
> better approach, as I'm learning as I go.
>
> Thanks!
>
> --Lee
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---