Re: Connection Properties

139 views
Skip to first unread message

Thomas Mueller

unread,
Jun 26, 2012, 2:56:13 PM6/26/12
to h2-da...@googlegroups.com
Hi,

> Is there any way to access the value of a connection property via H2's SQL
> grammar?

Yes, most settings can be read using:

select * from information_schema.settings

Regards,
Thomas

Jon Freedman

unread,
Jul 12, 2012, 1:04:23 PM7/12/12
to h2-da...@googlegroups.com
In this case I'm trying to access a property I've passed through

Thomas Mueller

unread,
Jul 13, 2012, 1:32:04 PM7/13/12
to h2-da...@googlegroups.com
Hi,

> In this case I'm trying to access a property I've passed through

Sorry I don't understand.

Regards,
Thomas

Jon Freedman

unread,
Jul 17, 2012, 4:22:43 AM7/17/12
to h2-da...@googlegroups.com
We're using commons-dbcp BasicDataSource and calling #addConnectionProperty to see appName which SqlServer displays as ProgramName when running sp_who2

Ideally I'd like to be able to query that value using SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME = 'appName' rather than using reflection to access connectionProperties within BasicDataSource

Thomas Mueller

unread,
Jul 20, 2012, 11:58:35 AM7/20/12
to h2-da...@googlegroups.com
Hi,

I don't know how commons-dbcp works internally. Maybe it ignores it, because H2 doesn't support it, or H2 ignores it? If that's the case I guess there is no way to exact the setting as it never arrieved in H2. But you could set a session variable in the database URL, as follows:

    jdbc:h2:~/test;init=set @abc='123'

and then query the setting using

    select @abc;

Regards,
Thomas






--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/Sxa6ZKiIfwYJ.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

Jon Freedman

unread,
Jan 23, 2017, 5:41:25 AM1/23/17
to H2 Database
A few years later, but more details:

My property is passed into org.h2.Driver#connect inside the info Properties object.
org.h2.engine.ConnectionInfo#readProperties ignores this.
org.h2.engine.Engine#openSession could be modified to handle these and set them as properties

Cheers

Jon
To unsubscribe from this group, send email to h2-database+unsubscribe@googlegroups.com.

Thomas Mueller Graf

unread,
Feb 23, 2017, 11:30:47 AM2/23/17
to h2-da...@googlegroups.com
Hi,

If you have a patch (with test case) then we can have a look at it.

Regards,
Thomas
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscribe@googlegroups.com.

To post to this group, send email to h2-da...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages