Hi, The DatabaseEventListener is create on the server side. To transfer the data to the client, you would need a different connection from the client to the server. Possible the DatabaseEventListener could add the events to the database (in a small in-memory table for example) that can then be queried. You probably need to use the multi-threading option to make that work, and you need to make sure there is no recursion.
Regards, Thomas On Thu, May 10, 2012 at 9:34 PM, Lizard Lizard <[email protected]> wrote: > Let me apologize for resending this, if others have received it. It > did not show up in my inbox along with other list emails, so I was > concerned it may have never made it to the list, for one reason or > another. It is not my intent to spam, or to pester the people who are > volunteering their time and knowledge. > ============ > OK, I'm having a bit of a quandary, which is probably obviously simple > to everyone else. > > I start up an H2 server from the command line, thus: java -cp > h2-latest.jar org.h2.tools.Server -tcp -tcpPort 9091 -tcpAllowOthers > > In my application (currently being debugged in Eclipse, but it > shouldn't matter), I connect to the server thus: > URL="jdbc:h2:tcp://192.168.0.102:9091/file://C:\Development\VARisk > Related Files\workspace\TC_VARisk\VARiskDB"; (It's not actually > hard-coded in the app, this is a sample of a generated URL to make it > clear.) > Connection conn=conn = DriverManager.getConnection(URL, "sa", ""); > > This has been working fine for a long time now. > > I created a very basic stub class that implemented > DatabaseEventListener, with a few printlns to show that it was > working, etc. > > The first thing I tried was changing my code for the URL to include > ";DATABASE_EVENT_LISTENER='"+H2DBListener.class.getName()+"'" > > This threw "class not found" exceptions. I tried a lot of variants on > this theme before the caffeine hit and I figured it out. Once I was > done bashing my head on the desk, I built a .jar containing my > H2DBListener class, and added it to the classpath for the H2Server > startup. > > This stopped the "class not found" errors. Unfortunately, the Listener > is outputting information to the server console, not the Eclipse > console. I need it tied to the connection I create internally to my > app. > > Further, I really need to be able to create an object of the > H2DBListener class, attach it during particular processes I care about > listening to, and then detach it. Is there a way to do something like: > H2DBListener h=new H2DBListener(); > SetDatabaseEventListener(h); > > I noticed that there is a SQL command to set the DBEvent listener, but > it also sets it to a class, not an instance. > > To be clear as to my long term goals, what I mostly want/need is to be > able to do something like this: > > class someLongProcess implements DatabaseEventListener > { > ProgressBar pb=new ProgressBar(); > ... > public void DoSomething() > { > //here's where I'd like to attach the listener > query="Select * from HugeDatabase"; > executeQuery(); > //here's where I detach the listener > } > > public void setProgress(int state, String name, int x, int max) > { > if(state==valueICareAbout) > { > pb.update(x,max); > } > } > } > > To make matters more interesting, my app runs (when doing real work) > in multiple VMs. It's a very simple work splitting model, using Cajo > to coordinate the small amount of state I need to share -- and of > course part of that state is "how far long are we?". Currently, I > probably don't need to use DatabaseEventListener, because progress on > the main function of the application is already being tracked and > shared, but I see a future time when I might need to implement it, so > I wanted to bring it up. What happens if/when multiple connections to > the same server set or unset the Listener class? If it's tied to the > connection, that's likely no issue; each class that creates a > connection and needs a listener ought to be fairly atomic in what it's > doing and what it's listening for. I want to be sure that if class foo > calls SET DATABASE_EVENT_LISTENER, it won't be affected by what class > bar, running in a different thread in the same VM, or in another VM > entirely, does. > > Thank you for your patience with what are probably self-evident questions. > > Also, I normally only edit in plain text in gmail, but to make the > code more readable, I had to switch to rich formatting. I hope it > actually is formatted clearly on other people's systems. > ============= > > -- > ======================= > Personal Blog: http://www.xanga.com/lizard_sf > Facebook: http://www.facebook.com/lizard_sf > MrLizard: Gaming and Geekery: http://www.mrlizard.com > > -- > You received this message because you are subscribed to the Google Groups "H2 > Database" 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/h2-database?hl=en. > -- You received this message because you are subscribed to the Google Groups "H2 Database" 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/h2-database?hl=en.
