Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
[do_jdbc] Fix path handling when connecting with a URI
Browse files Browse the repository at this point in the history
* Normalize the path element when building a java.net.URI:
  the path element should begin with a '/' character to ensure
  that the JDBC URL created internally, and passed to
  java.sql.DriverManager#getConnection, is correctly formatted.

[#1052 state:resolved]

Signed-off-by: Alex Coles <alex@alexcolesportfolio.com>
  • Loading branch information
myabc committed Sep 22, 2009
1 parent 17f0197 commit 64c24dd
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -117,8 +117,14 @@ public URI parseConnectionURI(IRubyObject connection_uri)
if (host != null && !"".equals(host)) {
// a client/server database (e.g. MySQL, PostgreSQL, MS
// SQLServer)
String normalizedPath;
if (path != null && path.length() > 0 && path.charAt(0) != '/') {
normalizedPath = '/' + path;
} else {
normalizedPath = path;
}
uri = new URI(this.jdbcScheme, userInfo.toString(), host, port,
path, query, fragment);
normalizedPath, query, fragment);
} else {
// an embedded / file-based database (e.g. SQLite3, Derby
// (embedded mode), HSQLDB - use opaque uri
Expand Down

0 comments on commit 64c24dd

Please sign in to comment.