Rails connection to Oracle Database

Source: Internet
Author: User
An error may occur during installation, and a message may be prompted that the following steps may be performed 2.1) sudoln-slibclntsh.dylib.10.1libclntsh.dylib2.2) to set up the environment

An error may occur during the installation process. Generally, a prompt is displayed, and the following step 2.1 may be executed.) sudo ln-s libclntsh. dylib.10.1 libclntsh. dylib 2.2) sets the environment.

Preparations:
1) install ActiveRecord Oracle adapter
Sudo gem install activerecord-oracle-adapter -- source

2) install the Oracle Client

An error may occur during the installation process. Generally, a prompt is displayed, and the following steps may be performed:
2.1) sudo ln-s libclntsh. dylib.10.1 libclntsh. dylib
2.2) set the environment variable. You can add it in. profile for Mac.
Export DYLD_LIBRARY_PATH = "/usr/local/oracle/instantclient_10_2"

3) install the ruby oracle driver and modify the driver according to your system environment.
Sudo env DYLD_LIBRARY_PATH = $ DYLD_LIBRARY_PATH ARCHFLAGS = "-arch x86_64" gem install ruby-oci8

For installation instructions, refer to the following article:

The project requires the Rails application to connect to mysql and Oracle DB at the same time, so you only need to modify the configuration in the config/database. yml file:
The following configuration generally uses the 'development' configuration by default and connects to the sqlite3 database.

Development:
Adapter: sqlite3
Database: db/development. sqlite3
Pool: 5
Timeout: 5000

Iisp:
Adapter: oracle
Encoding: utf8
Database: 192.168.68.22/iisp. xjgz
Username: iisp916
Password: iisp916

In iisp/database, the IP address is followed by the database Sid, not the database Name

Add the following code to the model to connect to oracle:

Establish_connection 'iisp'
Self. table_name = 't_ capacity'
Self. sequence_name ='s _ capacity '# primary key generation

Set the code for Rails to connect to Oracle:
Add the following code to config/environment. rb:
ENV ['nls _ lang'] = 'American _ AMERICA. utf8'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.