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...
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...