Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# gems you need
#
# dbi
# dbd-jdbc
# jdbc-postgres
require 'java'
require 'rubygems'
require 'dbi'
require 'dbd/Jdbc'
require 'jdbc/postgres'
# connect to database 'foobar'
# with user 'foobar' and password 'quux'
DBI.connect('DBI:Jdbc:postgresql://localhost/foobar',
'foobar', 'quux',
'driver' => 'org.postgresql.Driver') do |dbh|
puts "Connected"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment