Is it possible to know when I client disconnects from the TCP Server?
Jeffrey
You can get quite a bit of information if you query the
INFORMATION_SCHEMA tables - I query INFORMATION_SCHEMA.SESSIONS to
find out which sessions are open on the TCP/IP server.
Perhaps you can open the database in a database explorer and view all
the different tables under INFORMATION_SCHEMA, there's a lot of
information there.
I hope that helps.
Regards
Ewald
What is your use case?
> if there are clients connected to a TCP Server
It's possible, but not an official feature, and not documented. As you
already know, there is an in-memory "management_db_<port>" for each
TCP server. This database has a SESSIONS table. This table contains
one row for each connected session (this does work for me).
> when I client disconnects from the TCP Server
You could create a trigger on the SESSIONS table.
Regards,
Thomas
Hi,
What is your use case?
It's possible, but not an official feature, and not documented. As you
> if there are clients connected to a TCP Server
already know, there is an in-memory "management_db_<port>" for each
TCP server. This database has a SESSIONS table. This table contains
one row for each connected session (this does work for me).
You could create a trigger on the SESSIONS table.
> when I client disconnects from the TCP Server
> Is this different than the SESSIONS table in the INFORMATION_SCHEMA of the
> TCP connected database?
Yes. This table is in the PUBLIC schema. You can add triggers. But
what you want to do (at least it sounds like that's the case) is just
call SELECT * FROM SESSIONS.
> I would not know what connection was broken, just that *a* connection was
> broken. I need to know what connection was broken so I can remove records
> from a memory database that may pertain the that connection.
Connections don't have a "good" unique identifier except toString().
How could you find out which one? Maybe using a debugger.
> I was thinking that maybe the DatabaseEventListener could have a
> connectionStarted(<Session ID>) and connectionStopped(<Session ID>).
I will add a feature request for
"DatabaseEventListener.openConnection(id) and closeConnection(id)."
However I will not have time to implement that currently.
> Is there any way to get the <Session ID> for the current connection?
conn.toString()
Regards,
Thomas
> Is this different than the SESSIONS table in the INFORMATION_SCHEMA of the
> TCP connected database?
Yes. This table is in the PUBLIC schema. You can add triggers. But
what you want to do (at least it sounds like that's the case) is just
call SELECT * FROM SESSIONS.
Connections don't have a "good" unique identifier except toString().
> I would not know what connection was broken, just that *a* connection was
> broken. I need to know what connection was broken so I can remove records
> from a memory database that may pertain the that connection.
How could you find out which one? Maybe using a debugger.
I will add a feature request for
> I was thinking that maybe the DatabaseEventListener could have a
> connectionStarted(<Session ID>) and connectionStopped(<Session ID>).
"DatabaseEventListener.openConnection(id) and closeConnection(id)."
However I will not have time to implement that currently.
> I am running with 1.2.37 and the SESSIONS table is in the INFORMATION_SCHEME
> of the connected database. Am I looking at incorrect data?
There is *also* a table called INFORMATION_SCHEMA.SESSIONS, but that's
not the table I'm talking about. I'm talking about PUBLIC.SESSION.
As you already know, there is an in-memory database
"management_db_<port>" for each TCP server. This database has a
PUBLIC.SESSIONS table. You need to open that database within the
server, not the client. Maybe add ;IFEXISTS=TRUE to the database URL
to ensure you don't create a new database without knowing. For me, the
database URL is:
jdbc:h2:tcp://localhost/mem:management_db_9092;ifexists=true (user sa,
and password empty unless you set the password when starting the TCP
server).
Regards,
Thomas