Connecting mySQL to Ruby on NETBEAN 8.0

  • Thread starter Thread starter infinite.curve
  • Start date Start date
  • Tags Tags
    Mysql Ruby
AI Thread Summary
The discussion centers on a user's attempt to connect MySQL to Ruby using NetBeans, encountering a LoadError indicating that the 'mysql' library cannot be loaded. The provided code snippet attempts to establish a connection to a MySQL server and retrieve server information but fails due to this error. It is suggested that the issue arises before the database connection is attempted, pointing to a potential problem with the MySQL server or the library installation rather than the connection code itself. A link to a Ruby MySQL tutorial is shared as a potential resource for troubleshooting.
infinite.curve
Messages
23
Reaction score
1
So... I hae this issue trying to connect mySQL to ruby on net bean... Has anyone connected it before?

The code:

#!/user/bin/ruby


require 'mysql'


begin
puts "hello World"
con = Mysql.new 'localhost', 'sqluser', ''
puts con.get_server_info
rs = con.query 'SELECT VERSION();'
puts rs.fetch_row

rescue Mysql::Error => e
puts e.errno
puts e.error

ensure
con.close if con
end

LoadError: no such file to load -- mysql
require at org/jruby/RubyKernel.java:1027
require at /Users/eugenelemon/Library/Application Support/NetBeans/8.0/jruby/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at /Users/eugenelemon/NetBeansProjects/RubyApplication1/lib/main.rb:9
 
Technology news on Phys.org
I'm not a Ruby developer but perhaps this will help.

http://rubylearning.com/satishtalim/ruby_mysql_tutorial.html
 
infinite.curve said:
LoadError: no such file to load -- mysql

Looks like the problem occurs long before you try to connect to the database.
 
Looks like it's a MySQL server issue as it's not able to access the database file that you're trying to pull.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top