Thanks Michael,

One of the system tables has this information.

The query below returns the database access mode in the 'DATABASE' row:

select value from system_sessioninfo where key = 'DATABASE'

This always starts with res:, mem:, file:, hsql: or  http: (also hsqls: and
https:)

To find out if it is a server modes, you can check if the VALUE column
returned is one of the last four. Do not check for res:, mem: or file: as
there will be additional protocols added to the list of in-process ones.

Fred Toussi


----- Original Message ----- 
From: "Michael Hart" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 16 August 2004 07:28
Subject: [Hsqldb-developers] SQL check for In-Process?


Hi Guys,

After looking through the HSQLDB 1.7.2 code, I'm pretty sure there's no
way to do this, but I'd better ask first: Is there any way via an SQL
call to determine if the DB was started using the "In-Process
(Standalone)" mode?

As of 1.7.2, the server must be explicitly closed with a "SHUTDOWN"
command when in this mode, otherwise subsequent processes that try to
access it will be denied. This causes trouble when using tools like
Torque that maintain DB independence by relying on Velocity templates to
generate their SQL (and subsequently execute this SQL) because there's
no way to include an SQL statement to shutdown the DB if it's running in
In-Process mode. Torque could explicitly check to see if it's running
HSQLDB in In-Process mode in its Java code, but this is ugly as it
breaks the DB independence of the code - it would make much more sense
if this could be included in the HSQLDB-specific SQL templates that
Torque generates. Also, you don't want to include a SHUTDOWN statement
without any checks as this would shutdown a DB if it was running in
server mode, which may be undesirable.

Something like this would be perfect:

CALL CASE WHEN "org.hsqldb.Library.connectionType"() = 'file:' THEN
SHUTDOWN END

(Although I'm not sure if this syntax is correct)

There are many properties that can be gleaned about the current session
using HSQLDB - either from the various SYSTEM_* tables, or from some of
the org.hsqldb.Library functions, however it doesn't seem that the
connection type is one of them (it's one of the properties of the set
passed into the org.hsqldb.jdbcConnection constructor).

It looks from the code that including this in either a Library call, or
a system table shouldn't be too difficult and I could have a go at
coding it up - however, I figured I'd ask here first for suggestions on
how to best deal with this situation.

Would adding such a function be desirable - or would it even solve my
problem? Would I need a new SHUTDOWNIF function or similar? It just
seems that this change in behaviour with 1.7.2 has created a problem
with no obvious solution.

Cheers,

Michael

P.S. I'm looking into this not only to get Torque compatible with HSQLDB
1.7.2, but also OJB.


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
hsqldb-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hsqldb-developers



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
hsqldb-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hsqldb-developers

Reply via email to