josefmezera / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Can't set username/password in connection URL #502

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
jdbc:h2:tcp://localhost/mem:test;USER=sa

Crash:

Caused by: org.h2.jdbc.JdbcSQLException: Duplicate property "USER" [90066-171]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:169)
    at org.h2.message.DbException.get(DbException.java:146)
    at org.h2.engine.ConnectionInfo.readSettingsFromURL(ConnectionInfo.java:269)
    at org.h2.engine.ConnectionInfo.<init>(ConnectionInfo.java:77)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:93)
    at org.h2.Driver.connect(Driver.java:72)
    at org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:181)
    at org.h2.jdbcx.JdbcDataSource.getXAConnection(JdbcDataSource.java:315)
    at bitronix.tm.resource.jdbc.PoolingDataSource.createPooledConnection(PoolingDataSource.java:341)
    at bitronix.tm.resource.common.XAPool.createPooledObject(XAPool.java:283)
    at bitronix.tm.resource.common.XAPool.growUntilMinPoolSize(XAPool.java:400)
    at bitronix.tm.resource.common.XAPool.init(XAPool.java:71)
    at bitronix.tm.resource.common.XAPool.<init>(XAPool.java:64)
    at bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:101)
    at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:88)

The code in JdbcDataSource#getJdbcConnection() already sets an empty 
USER/PASSWORD property, so it can't be reset later on when the URL is parsed.

Original issue reported on code.google.com by christia...@gmail.com on 28 Jul 2013 at 2:26

GoogleCodeExporter commented 9 years ago
Hi,

I'm not sure what the problem is. Couldn't you set the user name in the data 
source? Why do you want to set it in the database URL?

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 28 Jul 2013 at 9:33

GoogleCodeExporter commented 9 years ago
I want my users to specify a database connection by providing a connection URL 
as a system property. If credentials are supported in the URL, I don't have to 
have separate properties for them. This works with Oracle and PostgreSQL, and 
I'd have to make an exception for H2.

Original comment by christia...@gmail.com on 29 Jul 2013 at 4:56

GoogleCodeExporter commented 9 years ago
Hm, if it works for Oracle and PostgreSQL, then we should make it work for H2 
as well. I wonder if the default user name and password could be null in the 
JdbcDataSource.

Original comment by thomas.t...@gmail.com on 29 Jul 2013 at 5:05

GoogleCodeExporter commented 9 years ago
Actually I was wrong, while PostgreSQL like H2 supports credentials in the URL, 
the PGXADataSource doesn't even support a URL property. So it's as bad as Derby 
in that regard. Seriously, URLs have a perfectly established syntax for 
protocol, location or a resource, access credentials, and key/value parameters. 
Why any other property configuration mechanism is required I don't understand 
at all... </rant>

Original comment by christia...@gmail.com on 29 Jul 2013 at 10:51

GoogleCodeExporter commented 9 years ago
Now looking at the code, it might actually simplify things if the user name 
wouldn't be set to an empty string by default (but null would be used instead).

Original comment by thomas.t...@gmail.com on 29 Jul 2013 at 11:30