datamapper / dm-oracle-adapter

Oracle Adapter for DataMapper
http://datamapper.org/
MIT License
18 stars 8 forks source link

Problems with jdbc URIs #13

Open tillsc opened 11 years ago

tillsc commented 11 years ago

OJDBC needs URIs in form of:

 jdbc:oracle:thin:@[Host][:Port]/SID

The Problem is the @character in the URIs which is required in the ODJBC URIs. It is present in the URI if you specify a Host.

Examples (JDBC-URI visible by accessing the do_jdbc Connection directly):

DataMapper.setup(:default, {:adapter => "oracle", :database => "MY_SID"})
# => JdbcURI: "jdbc:oracle:thin:MY_SID" (lacking the "@")

DataMapper.setup(:default, {:adapter => "oracle", :database => "@MY_SID"})
# => JdbcURI: "jdbc:oracle:thin:@MY_SID" (Yay!)

The last Hack seems to do the trick, BUT DataMapper seems to find the "@" in it's internal DM-URI and is assuming the credentials are already specified somewhere else. So it will ignore the :username and :password parameters seen in the following example:

DataMapper.setup(:default, {:adapter => "oracle", :database => "@MY_SID", :username => "SCOTT", :password => "TIGER"})
# No Username and password arriving in do_jdbc Connection

DataMapper.setup(:default, {:adapter => "oracle", :database => "SCOTT/TIGER@MY_SID"})
# Works! But I hate it :-)

For completeness reasons the jdbc URI with :host parameter:

DataMapper.setup(:default, {:adapter => "oracle", :database => "MY_SID", :host => "localhost", :username => "SCOTT", :password => "TIGER"})
# => JdbcURI: "jdbc:oracle:thin:@//localhost/MY_SID" (looks a bit strange but works)
tillsc commented 11 years ago

I'm not sure where exactly this problem is located (dm-oracle-adapter, do_oracle or do_jdbc). If somebody could give me a hint I would try to fix it.