This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 155708 - JDBC drivers not working with JRuby within NetBeans
Summary: JDBC drivers not working with JRuby within NetBeans
Status: NEW
Alias: None
Product: ruby
Classification: Unclassified
Component: Platform (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@ruby
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-17 21:03 UTC by auxbuss
Modified: 2011-01-28 20:12 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description auxbuss 2008-12-17 21:03:21 UTC
In irb, I get:

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'sequel'
=> true
irb(main):003:0> DB = Sequel.connect("jdbc:mysql://localhost/blah?user=blah&password=blah")
=> #<Sequel::JDBC::Database: "jdbc:mysql://localhost/blah?user=blah&password=blah"
>
irb(main):004:0> DB[:quality].all
=> [{:quaID=>1, :quaDesc=>"Unknown", :quaOrder=>1}, {:quaID=>2, 
:quaDesc=>"Suspect", :quaOrder=>2},
{:quaID=>3, :quaDesc=>"Poor", :quaOrder=>3}, {:quaID=>4, :quaDesc=>"Less 
than average", :quaOrder=>4
}, {:quaID=>5, :quaDesc=>"Average", :quaOrder=>5}, {:quaID=>6, 
:quaDesc=>"More than average", :quaOr
der=>6}, {:quaID=>7, :quaDesc=>"Good", :quaOrder=>7}, {:quaID=>8, 
:quaDesc=>"Excellent", :quaOrder=>
8}, {:quaID=>9, :quaDesc=>"Gold", :quaOrder=>9}]
irb(main):005:0>

But the identical code in netbeans bombs with:

java/sql/DriverManager.java:602:in `getConnection': 
java.sql.SQLException: No suitable driver found for 
jdbc:mysql://localhost/blah?user=blah&password=blah (NativeException)
        from java/sql/DriverManager.java:207:in `getConnection'
        from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
        from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke'
        from sun/reflect/DelegatingMethodAccessorImpl.java:25:in 
`invoke'
        from java/lang/reflect/Method.java:597:in `invoke'

etc.

Works fine with regular Ruby in netbeans.
Comment 1 Erno Mononen 2008-12-18 08:31:26 UTC
Thanks for filing this, I'll try to address this for 7.0.
Comment 2 cosmocracy 2009-05-26 19:32:51 UTC
I am also having an issue that appears only in NetBean 6.5.  In my case I'm attempting to perform JDBC via a JRuby rake
task.  The rake task attempts to perform some JDBC using the Oracle driver.  In NetBeans it acts as if it can't find the
.JAR file for the JDBC Driver (wrong classloader?) yielding the error "java.sql.SQLException: No suitable driver found
for jdbc:oracle:thin:@10.1.2.3:1521:XE".  I went to great pains to ensure the .JAR file is indeed in the classpath. 
From JRuby I can even instantiate the driver class.

Sample code to reproduce:

# Try putting it on the classpath two ways (and tried variations to no avail)
require "#{RAILS_ROOT}/vendor/jars/ojdbc14.jar"
$CLASSPATH << "#{RAILS_ROOT}/vendor/jars/ojdbc14.jar"

# For completeness, make sure the driver class is available
puts Java::JavaClass.for_name('oracle.jdbc.OracleDriver').inspect
# Register the JDBC driver (overkill but just trying anything...)
java.sql.DriverManager.registerDriver(Java::oracle.jdbc.driver.OracleDriver.new)
url = "jdbc:oracle:thin:@10.1.2.3:1521:XE"
properties = java.util.Properties.new
properties.put("user", "abcd")
properties.put("password", "abcd")
# The following errors with a "No suitable driver" error but ONLY WITHIN NETBEANS 6.5
jdbc_conn = java.sql.DriverManager.getConnection(url, properties)

This does work, however, when run outside NetBeans 6.5.  Thank you!