6 Replies Latest reply: Nov 23, 2010 1:21 AM by 788763 RSS

    Connecting to Oracle with JRuby?

    596410
      I believe the OCI adaptor is out of the question due to it using C and that JRuby cannot handle it yet.

      What are my alternatives to connecting to an Oracle database within a Rails app? I need to do some quick and dirty tasks but need to get my connection squared away first. Would I be able to connect via ODBC or JDBC? Can anyone point me towards some good resources?

      Thanks!
        • 1. Re: Connecting to Oracle with JRuby?
          596410
          I think I'm close with my settings... however when working with a scaffold I'm getting the following error:

          "The driver encountered an error: cannot load Java class oracle.jdbc.driver.OracleDriver"

          Do I need to set a path somewhere? I have the following in my environment.rb:
          if RUBY_PLATFORM =~ /java/
          require 'rubygems'
          RAILS_CONNECTION_ADAPTERS = %w(jdbc)
          end

          and my connection string looks like this:
          development:
          adapter: jdbc
          driver: oracle.jdbc.driver.OracleDriver
          url: jdbc:oracle:thin:@iserver:1521:db
          username: user
          password: pass

          I've got ActiveRecord-JDBC installed and the Oracle driver is there, I"m guessing I"m not setting a path correctly?
          • 2. Re: Connecting to Oracle with JRuby?
            589551
            Hi,

            What's the location of your Oracle JDBC driver package?

            The simplest way is to add the driver to your $JRUBY_HOME/lib directory or you can add the path to the driver into environment variable $CLASSPATH by the following command:

            export CLASSPATH=$CLASSPATH:<Path_To_Your_Oracle_JDBC_Driver>

            Regards,
            Liming
            • 3. Re: Connecting to Oracle with JRuby?
              dvohra21
              Oracle Mix is created with JRuby.
              http://www.linux-magazine.com/online/news/oracle_launches_jruby_website
              • 4. Re: Connecting to Oracle with JRuby?
                579214
                Did you get it to work?

                I'm developing a web application with jruby 1.1.2 using activerecord-jdbc-adapter 0.8.2 to access oracle with jndi.

                I'm receving the following error "ActiveRecord::ActiveRecordError (Table PER_APPRAISALS does not exist)" and alredy post this on http://jira.codehaus.org/browse/JRUBY-2618 hoping that will be fixed soon.

                How was the mix.oracle.com developed without activerecord-jdbc-adapter? Is there an alternative for that?

                Thanks,
                Marcelo Murad
                • 5. Re: Connecting to Oracle with JRuby?
                  586655
                  Hi. Here is a tutorial help users get started with JRuby on Rails and Oracle. Hope it's helpful. Thanks

                  Link: http://wiki.oracle.com/page/JRuby+on+Rails%3A+Deploying+to+Oracle+Containers+for+Java+EE+(OC4J)
                  • 6. Re: Connecting to Oracle with JRuby?
                    788763
                    Murad wrote:

                    Did you get it to work?




                    I'm developing a web <font face="tahoma,verdana,sans-serif" size="1" color="#000">application</font> with jruby 1.1.2 using activerecord-jdbc-adapter 0.8.2 to access oracle with jndi.




                    I'm receving the following error "ActiveRecord::ActiveRecordError (Table PER_APPRAISALS does not exist)" and alredy post this on <a class="jive-link-external" href="http://jira.codehaus.org/browse/JRUBY-2618">http://jira.codehaus.org/browse/JRUBY-2618</a> hoping that will be fixed soon.




                    How was the mix.oracle.com developed without activerecord-jdbc-adapter? Is there an alternative for that?




                    Thanks,



                    Marcelo Murad
                    It's quite useful, Many thanks to your description! It helps me out of the problem.