JRuby and Class.forName()

Y

Yvon Thoraval

i want get a connection to a PostgreSQL database then i wrote a JRuby
script :

1 require 'java'
2 module JavaLang
3 include_package "java.lang"
4 end
5 module JavaSQL
6 include_package "java.sql"
7 end
8
9 JavaLang::Class.forName("org.postgresql.Driver")
10 [...]

this raises an error :

connect2macave.rb:9: Undefined method 'forName' for Class:Class
(NameError)
from connect2macave.rb:9
from :0

i don't understand this error because this script is similar to java
version :

import java.sql.*;
import javax.swing.JOptionPane;

public class connect2macave {
public static void main(java.lang.String[] args) {
ResultSet bouteilles = null;
Statement query = null;
Connection pSQL = null;
try {
// Here we load the JDBC driver.
Class.forName("org.postgresql.Driver");


which works well...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top