Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.
« TOTD #34: Using... | Main | New "Community:... »

http://blogs.sun.com/arungupta/date/20080623 Monday June 23, 2008

TOTD #35: Rails Database Connection on Solaris

Are you deploying your JRuby-on-Rails applications on Solaris (or any variety of Unix) and not able to connect to the database ?

I experienced it last week so thought of sharing the tip here. Luckily it's really simple.

Here is the default generated "config/database.yml"

development:
  adapter: mysql
  encoding: utf8
  database: runner_development
  username: root
  password:
  socket: /tmp/mysql.sock

The only required change is to add "host: 127.0.01" for the required database configuration. The updated fragment is shown below (with change highlighted):

development:
  adapter: mysql
  encoding: utf8
  database: runner_development
  username: root
  password:
  socket: /tmp/mysql.sock
  host: 127.0.01

Even though "host" is required for TCP connections but the database connection does not seem to work without this entry. The exact same application works without "host" entry on Windows and Mac OS.

Alternatively, you can always install the JDBC adapter as explained here.

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive is available here.

Technorati: totd rubyonrails jruby ruby opensolaris mysql

del.icio.us | furl | simpy | slashdot | technorati | digg |
|
Comments:

Basically you don't need

'socket: /tmp/mysql.sock'

socket or host are mmutually exclusive, looks like if host entry is there it takes over socket.

Looks like there is some bug with handling unix domain socket, use -J-Djruby.native.enabled=false on the jruby CLI and you wont see any issue. See a thread on this atusers@jruby[1].

[1]http://markmail.org/search/list:org.codehaus.jruby?q=vivek+pandey#query:vivek%20pandey+page:1+mid:6d6rn6v2mlfrhzcs+state:results

Posted by vivek on June 23, 2008 at 09:54 AM PDT #

[Trackback] My primary development machine is Mac OS Leopard on Intel Core 2 Duo (read osxtips). But the beauty of virtualization is that I can run multiple Operating Systems on a single powerful machine. And what better virtualization product than...

Posted by Arun Gupta's Blog on June 24, 2008 at 06:22 AM PDT #

One other step I needed was to add my port info. For instance:

development:
adapter: mysql
encoding: utf8
database: my_db_name_here
username: root
password: root
host: 127.0.0.1
port: 8889

Am running MySQL as part of the MAMP bundle; am guessing my port isn't the default.

Cheers,
Bobby

Posted by Bobby Bissett on August 21, 2008 at 11:41 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
« TOTD #34: Using... | Main | New "Community:... »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.