developer.com
Search EarthWeb
CodeGuru | Gamelan | Jars | Wireless | Discussions
Navigate developer.com
Architecture & Design  
Database  
Java
Languages & Tools
Microsoft & .NET
Open Source  
Project Management  
Security  
Techniques  
Voice  
Web Services  
Wireless/Mobile
XML  
New
 
Technology Jobs  

   Developer.com Webcasts:
  The Impact of Coding Standards and Code Reviews

  Project Management for the Developer

  Defining Your Own Software Development Methodology

  more Webcasts...




Return in early January to see which technologies and products won.




Developer Jobs

Be a Commerce Partner














 


Developer News -
Big Enterprise Linux Moves, Green Networks in 2009    December 26, 2008
Gifts for All in Linux 2.6.28    December 24, 2008
Merb Merges With Rails    December 24, 2008
Sun's Unwired Motherboard Plans    December 24, 2008
Free Tech Newsletter -

JRuby on Rails with Nine Lives: Running a JRuby on Rails Application on Tomcat
By Dominic Da Silva

Go to page: Prev  1  2  3  4  5  6  7  8  Next  

Configuring the Database

Next, you need to tell your JRuby on Rails app to use ActiveRecord-JDBC and what database you will be using. Within the railswartest directory, edit the config/environment.rb file and add the following just before the line containing Rails::Initializer.run do |config|:

if RUBY_PLATFORM =~ /java/
   require 'rubygems'
   gem 'ActiveRecord-JDBC'
   require 'jdbc_adapter'
end



Click here for a larger image.

Figure 7: Configuring JRuby on Rails app to use ActiveRecord-JDBC

This tells Rails that, if it detects that it is running on Java (in other words, JRuby) to load the ActiveRecord-JDBC gem.

Now, configure your JDBC driver. Within the railswartest directory, edit the config/database.yml file and edit the development: and production: configurations to contain the following:

development:
   adapter: jdbc
   driver: com.mysql.jdbc.Driver
   url: jdbc:mysql://localhost:3306/railswartest
   username: <username>
   password: <password>

production:
   adapter: jdbc
   driver: com.mysql.jdbc.Driver
   url: jdbc:mysql://localhost:3306/railswartest
   username: <username>
   password: <password>



Click here for a larger image.

Figure 8: Configuring the JRuby on Rails app development and production database connections

I am using a database named railswartest, which I created using the MySQL Query Browser:



Click here for a larger image.

Figure 9: Creating MySQL database 'railswartest' using MySQL Query Browser

Go to page: Prev  1  2  3  4  5  6  7  8  Next  


Tools:
Add www.developer.com to your favorites
Add www.developer.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed


Database Archives






internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers