> -----Original Message-----
> From: Thomas Mahler [mailto:[EMAIL PROTECTED]
> Sent: 12 April 2004 07:06
> To: OJB Users List
> Subject: Re: HSQLDB Issue
[...]
> > The other issue is that I can't seem to find a way to get
> OJB to find
> > the hsqldb script and data files directly within the exploded war
> > directory. What's the trick there? I want to be able to
> deliver a war
> > file to users, have it explode, then the app is just up and
> running with
> > no configuration necessary... what's the trick?
>
> This is not an OJB issue, it's caused by HSQLDB.
> I've been looking for this feature for ages! This would make usage of
> hsqldb extremely simple in web apps!
> The bad news is that I don't think that it is possible with current
> versions of HSQLDB.
> You have to use the complete filesystem path in the OJB connection
> descriptor.
I am sure I'm missing something, but couldn't you just use the classloader
to find the location of the database ?
Assuming the database was called "mydb", I believe the following should work
out the jdbc URL of the HSQL DB :
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url = cl.getResource("mydb.properties");
/* URL probably is file://pathtothefile */
if(url!=null){
/* Get rid of the leading '/' - probably not required on non-windows
os's */
String path = url.getPath().substring(1);
/* Remove the .properties from the end */
path = path.substring(0, path.lastIndexOf('.'));
String databaseUrl = "jdbc:hsqldb:" + path;
}
You could then dynamically modify the Connection descriptor in the metadata.
I, myself, think it's a bit dodgy to assume that the WAR file is definitely
exploded. I would suggest that you use the classloader (and a bit more
jiggery-pokery) to copy the database from the WAR to a temporary directory -
a bit more complex, but probably safer (but then, what happens when the
OS/restarts ? the db disappears.)
Cheers,
Charles.
>
> :-( Maybe we should approach the hsqldb guys to add this feature?
>
> cheers,
> Thomas
>
>
> > [ERROR] SequenceManagerHighLowImpl - -Can't lookup new
> HighLowSequence
> > for field browserID using sequence name SEQ_CDPCNO_BROWSERS
> > <org.apache.ojb.broker.PersistenceBrokerException: Can't lookup a
> > connection: Can't get connection from DBCP-DataSource:
> > java.util.NoSuchElementException>java.sql.SQLException:
> > java.util.NoSuchElementException
> > at
> >
> org.apache.commons.dbcp.PoolingDataSource.getConnection(Poolin
> gDataSource.java:112)
> >
> > at
> >
> org.apache.ojb.broker.accesslayer.ConnectionFactoryDBCPImpl.ge
> tConnectionFromPool(ConnectionFactoryDBCPImpl.java:56)
> >
> > at
> >
> org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImp
> l.lookupConnection(ConnectionFactoryAbstractImpl.java:101)
> >
> > at
> >
> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.getCon
> nection(ConnectionManagerImpl.java:144)
> >
> > at
> >
> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.localB
> egin(ConnectionManagerImpl.java:186)
> >
> >
> > The sql for the tables is, maybe I got the wrong ones? (Got
> them from
> > the OJB samples)
> >
> > CREATE TABLE OJB_HL_SEQ(TABLENAME VARCHAR(175) NOT NULL,FIELDNAME
> > VARCHAR(70) NOT NULL,MAX_KEY INTEGER,GRAB_SIZE INTEGER,VERSION
> > INTEGER,CONSTRAINT SYS_PK_OJB_HL_SEQ PRIMARY
> KEY(TABLENAME,FIELDNAME))
> > CREATE TABLE OJB_LOCKENTRY(OID_ VARCHAR(250) NOT NULL,TX_ID
> VARCHAR(50)
> > NOT NULL,TIMESTAMP_ TIMESTAMP,ISOLATIONLEVEL INTEGER,LOCKTYPE
> > INTEGER,CONSTRAINT SYS_PK_OJB_LOCKENTRY PRIMARY KEY(OID_,TX_ID))
> > CREATE TABLE OJB_NRM(NAME VARCHAR(250) NOT NULL PRIMARY KEY,OID_
> > LONGVARBINARY)
> > CREATE TABLE OJB_DLIST(ID INTEGER NOT NULL PRIMARY
> KEY,SIZE_ INTEGER)
> > CREATE TABLE OJB_DLIST_ENTRIES(ID INTEGER NOT NULL PRIMARY
> KEY,DLIST_ID
> > INTEGER,POSITION_ INTEGER,OID_ LONGVARBINARY)
> > CREATE TABLE OJB_DSET(ID INTEGER NOT NULL PRIMARY KEY,SIZE_ INTEGER)
> > CREATE TABLE OJB_DSET_ENTRIES(ID INTEGER NOT NULL PRIMARY
> KEY,DLIST_ID
> > INTEGER,POSITION_ INTEGER,OID_ LONGVARBINARY)
> > CREATE TABLE OJB_DMAP(ID INTEGER NOT NULL PRIMARY KEY,SIZE_ INTEGER)
> > CREATE TABLE OJB_DMAP_ENTRIES(ID INTEGER NOT NULL PRIMARY
> KEY,DMAP_ID
> > INTEGER,KEY_OID LONGVARBINARY,VALUE_OID LONGVARBINARY)
> >
> >
> > TIA
> > R
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
___________________________________________________________
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]