Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#92 DB connection as URI

open
None
5
2012-09-14
2009-01-13
Alex Fabijanic
No

Add support for DB connection URI. Example:

Session sess(SessionFactory::instance().create("odbc:///ConnectionString"));
assert ("odbc" == sess.impl()->connector());
assert ("ConnectionString" == sess.impl()->connectionString());
assert ("odbc:///ConnectionString" == sess.uri());

To remain RFC 3986 compliant, this also implies storing connector names in lowercase only. Framework remains case-insensitive with regard to connector names. Those, however, are internally kept and returned in lowercase only. Connection string case remain intact as supplied by the user.

Rationale for this is to provide a built-in key to discriminate session pools in the session pool container.

The question remains whether to go further and get involved into something of this sort:

connector://[user[:password]]@[host[:port]]/[database]?ConnectionString

With user,password,host,port and database being optional info. Since automatic parsing of all possible connection strings may be too much of a challenge and forcing clients to provide redundant information potentially error-prone and counter-productive, the question is whether it's worth it at all.

Something else to consider would be extension with URI query portion being SQL query (append SQL query after ).

Comments welcome.

Discussion

  • Alex Fabijanic
    Alex Fabijanic
    2009-01-13

    Code is in the SVN trunk, rev. 1017