Skip to content

Instantly share code, notes, and snippets.

@oinume
Created April 1, 2013 10:29
Show Gist options
  • Save oinume/5284189 to your computer and use it in GitHub Desktop.
Save oinume/5284189 to your computer and use it in GitHub Desktop.
Connecting to MySQL with JRuby and JDBC.
require 'java'
require 'rubygems'
require 'dbi'
require 'dbd/Jdbc'
require 'jdbc/mysql'
Jdbc::MySQL.load_driver
DBI.connect(
'DBI:Jdbc:mysql://localhost/test',
'root', 'root',
'driver' => 'com.mysql.jdbc.Driver'
) do |dbh|
puts "Connected"
end
@ikhoon
Copy link

ikhoon commented Jul 3, 2015

This code works good! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment