Re: Support for H2Database

"hkara1" <[email protected]>
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Hi,

I've been using this just as you described, and it works fine.
Here is the class I use :

package org.hmn.jrsd.demo;

import simpleorm.drivers.SDriverHSQL;
import simpleorm.sessionjdbc.SDriver;

/*
 * 
 * Cree par Harry Karadimas a 9 sept. 08
 */
/**
 * The H2 is mostly HSQL (H2 is a fork, by the original author of HSQLDB)
 */
public class H2Driver
extends SDriverHSQL
{
  @Override
  protected String driverName() {
    return "H2 JDBC Driver";
  }
  
}

To use the driver, it must first be registered when the 
application starts :

    //we register the H2 driver
    new H2Driver().registerDriver();
 
You can then connect to the H2 database as usual :

try {
  Class.forName("org.h2.Driver");
  driverLoaded = true;
}
catch (Exception ex) {
  throw new SQLException("Could not load H2 driver ("+ex+")");
}
Connection cxn = DriverManager.getConnection(url, user, password);

I don't really know if that is the best way to do it, however.

Harry

--- In [email protected], Anthony Berglas <anthony@...> wrote:
>
> Have not done this yet.  But if you copy the HSQL driver it should 
> only require trivial changes.  SimpleORM minimizes database
dependent code.
> 
> If you do this and it runs through the test cases then please post it 
> back to the list and I'll add it to the source.
> 
> Anthony
> 
> At 06:15 AM 23/09/2008, alspaughb wrote:
> >Does SimpleORM support H2Database?  I can't find an SDriver subclass
> >for it.
> >
> >http://www.h2database.com
> >
> >I like the fact that H2 is lightweight, pure Java, and supports multi
> >version concurrency.
> >
> >Bruce
> 
> Dr Anthony Berglas, anthony@...       Mobile: +61 4 4838 8874
> Just because it is possible to push twigs along the ground with ones
nose
> does not necessarily mean that is the best way to collect firewood.
>



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/SimpleORM/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.