Connect to MySQL in Ruby using NetBeans
I've downloaded the dbd-mysql-0.4.4.zip
and linked it to my project. While I try to run a demo code from NetBeans the very first line (shown below) gives me an error. Is there a different way to do it?
require "dbi";
I also tried this command from the command prompt:
j开发者_如何学编程ruby setup.rb config --with=dbi,dbd_mysql
It gave me the following error:
config: unknown option --with=dbi,dbd_mysql
Try ruby setup.rb --help for detailed usage.
Any suggestions please?
If you're working with jruby, you need to use dbd-jdbc
, because dbd-mysql
depends on mysql
a native extension (written in C) for Matz' Ruby interpreter.
Install it using rubygems: jruby -S gem install dbi
, and add require 'rubygems'
as the first line of your code.
精彩评论