Fail to establish connection

62 views
Skip to first unread message

David Holmes

unread,
Nov 6, 2009, 1:27:57 PM11/6/09
to Oracle enhanced adapter for ActiveRecord
Exception:
java.sql.SQLException: Io exception: The Network Adapter could not
establish the connection

The JDBC URL looks like this:
jdbc:oracle:thin:@(description=(address_list=(address=
(host=somehostname1)(protocol=tcp)(port=1521))(address=
(host=somehostname2)(protocol=tcp)(port=1521))(load_balance=yes)
(failover=yes))(connect_data=(service_name=someservicename)))

database.yml
adapter: oracle_enhanced
host: somehostname1
database: someservicename
username: user
password: pass

I've tried different variations of supplying the values in
database.yml to no avail. App works in plain ruby (no JRuby) and using
activerecord-jdbc-adapter. Any suggestions?

Raimonds Simanovskis

unread,
Nov 6, 2009, 4:06:28 PM11/6/09
to Oracle enhanced adapter for ActiveRecord
If you have such complex JDBC URL then you can specify it as url:
parameter in database.yml :

development:
adapter: oracle_enhanced
url: jdbc:oracle:thin:@(description=(address_list=(address=
(host=somehostname1)(protocol=tcp)(port=1521))(address=
(host=somehostname2)(protocol=tcp)(port=1521))(load_balance=yes)
(failover=yes))(connect_data=(service_name=someservicename)))
username: user
password: pass

Other option is that you can define this connection in tnsnames.ora
file (that OCI client uses), defne TNS_ADMIN environment variable to
point to directory where tnsnames.ora is located and then you can
define your database.yml as following:

development:
adapter: oracle_enhanced
database: someservicename
username: user
password: pass

where someservicename is TNS names alias that you used in tnsnames.ora
file.

Raimonds

David Holmes

unread,
Nov 6, 2009, 4:10:10 PM11/6/09
to Oracle enhanced adapter for ActiveRecord
Thanks Raimonds, I'll need the more complex URL for production. But
shouldn't this work?

development:
adapter: oracle_enhanced
host: myhost
database: oracleservicename
username: user
password: pass


On Nov 6, 3:06 pm, Raimonds Simanovskis

David Holmes

unread,
Nov 6, 2009, 4:23:10 PM11/6/09
to Oracle enhanced adapter for ActiveRecord
Raimonds, I get an exception when trying the to use url: instead of
host: and database:.

org.jruby.rack.RackInitializationException: syntax error on line 2,
col 281:

The jdbc url is the same I use for "adapter: jdbc", so I know it
works.

I appreciate any advice you have.

On Nov 6, 3:06 pm, Raimonds Simanovskis
<raimonds.simanovs...@gmail.com> wrote:

David Holmes

unread,
Nov 6, 2009, 4:30:44 PM11/6/09
to Oracle enhanced adapter for ActiveRecord
Cancel the last one. The url: works. Would still like to know about
using the host: and database:.
Reply all
Reply to author
Forward
0 new messages