Accessing PostgreSQL database using JDBC driver

Hi,
I am trying to access PostgreSQL database using jdbc-postgres driver. I
am using this code:

require ‘java’
require ‘jdbc/postgres’
Jdbc::Postgres.load_driver

String url = “jdbc:postgresql://localhost/postgres”
conn= DriverManager.getConnection(url,‘postgres’,‘postgres’);
res=conn.query(‘select * from hoom.test’)

The error I am getting is:
NameError: uninitialized constant DriverManager
const_missing at org/jruby/RubyModule.java:2690
(root) at db.rb:6

Thanks in advance for help

use Java::JavaSql::DriverManager or java.sql.DriverManager

Hi,
Thanks for help. I am able to get connection but unable to read the
records. I am using following code:

require ‘rubygems’
require ‘java’
require ‘jdbc/postgres’
Jdbc::Postgres.load_driver

url = “jdbc:postgresql://localhost/postgres”
conn= *java::sql::DriverManager.getConnection(url,‘postgres’,‘postgres’)
st=conn.create_statement
query=“select * from test”
rs = st.execute_query(query)
rs.each {|row| puts row }

The error I am getting is:
NoMethodError: undefined method `create_statement’ for
[#<Java::OrgPostgresqlJdb
c4::Jdbc4Connection:0x11e04129>]:Array
(root) at db.rb:8
The code example is from this link:

the error message simply says it all conn is an Array due the * you
probably wanted :

conn= java::sql::DriverManager.getConnection(url,‘postgres’,‘postgres’)

I recommend you learn some ‘more’ Ruby first cause otherwise it’s going
to
take some.