0

This is doing my head right in!

I am messing about with JRuby trying to make some Java calls. Here is the source Im messing with.

require 'java'

module JavaLang
  include_package "java.lang"
end

module JavaSql
  include_package 'java.sql'
end

begin
    JavaLang::Class.forName("com.mysql.jdbc.Driver").newInstance
    jdbcconnection = JavaSql::DriverManager.getConnection("jdbc:mysql://localhost:3306/accounts", 'root', '');

    puts 'Werked'
rescue Exception => ex
    connectmsg = "Could not connect to the database: " + ex.message;
    puts connectmsg
end

I am using Netbeans 6.8 as the IDE.

When I run the script it all works fine and I get Werked printing out in the output.

When I try to run this through on the debugger I get

Could not connect to the database: java.lang.ClassNotFoundException: com/mysql/jdbc/Driver

Im sure its just something basic to do with setting a debugger configuration, but I can't find anything anywhere to give me a clue.

Why would the debugger not pick up these java classes?

Edit

Just to follow up, this is a bug in Netbeans 6.8. Here is the bug report.

Relieved that Im not going mad!

3
  • Are you using the debug version of your JDBC driver? Commented Jan 10, 2010 at 15:48
  • I dont think so, am using mysql-connector-java-5.1.9-bin.jar. Will try getting a debug version. Commented Jan 10, 2010 at 16:01
  • Finally got a debug version built. It made no difference. Commented Jan 10, 2010 at 17:31

1 Answer 1

1

This seems like a general classpath issue. The fact that the reflection fails, supports this. Are you sure that your classpath is the same / similar to your runtime classpath?

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, spot on! The classpath Ive set in the IDE hasnt been applied to the debug classpath. Now I need to work out how to get it to apply this. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.