Connecting mySQL to Ruby on NETBEAN 8.0

  • Thread starter Thread starter infinite.curve
  • Start date Start date
  • Tags Tags
    Mysql Ruby
Click For 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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...