In `require': no such file found --mysql(Load Error)

Hi friends …

         I am using netbeans IDE for JRuby. While trying for MySQL

connection am getting the load error. How to rectify this?

If you are trying to use the MySQL native gem for MRI on JRuby, that
will never work. The “mysql” library plugs directly into MRI using C
APIs.

You may be interested in using JDBC instead, which can provide access
to MySQL (and other databases) without any native libraries (and works
fine from JRuby as well:

(FYI) just import the java.sql classes used in that example directly;
the include_package stuff he uses is not the recommended way.

On Wed, Mar 3, 2010 at 2:21 AM, Anbu S. [email protected]
wrote:

  http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Mar 3, 2010 at 5:34 PM, Eric C.
[email protected] wrote:

Is there anything for JRuby that allows you to read embedded MySQL
databases (i.e. without a server)? I know for Java there’s mysql-je,
so I could probably use that, if nothing else.

I had never even heard of mysql-je. If it has to be an embedded
mysql database, that’s probably your best bet.

If it just needs to be an embedded database, there’s lots of other
options, like Derby (JavaDB), HSQLDB, and even sqlite3.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Mar 3, 2010 at 7:38 AM, Charles Oliver N.
[email protected] wrote:

the include_package stuff he uses is not the recommended way.
Is there anything for JRuby that allows you to read embedded MySQL
databases (i.e. without a server)? I know for Java there’s mysql-je,
so I could probably use that, if nothing else.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Mar 3, 2010 at 7:07 PM, Eric C.
[email protected] wrote:

Playing around with the JDBC example there, I can’t seem to make it
work unless I actually put the jar file in my CLASSPATH. I see some
messages saying old versions of JRuby didn’t support setting the class
path via command line arguments; is that still true in 1.4.0?

JRuby 1.4 and higher should work fine using either the CLASSPATH env
var or the -cp JVM argument (as -J-cp when passed to JRuby, of
course).

So the example there didn’t work if you required the jar directly in the
script?

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

OK, thanks.

Playing around with the JDBC example there, I can’t seem to make it
work unless I actually put the jar file in my CLASSPATH. I see some
messages saying old versions of JRuby didn’t support setting the class
path via command line arguments; is that still true in 1.4.0?

On Wed, Mar 3, 2010 at 6:17 PM, Charles Oliver N.
[email protected] wrote:

options, like Derby (JavaDB), HSQLDB, and even sqlite3.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Mar 3, 2010 at 7:38 PM, Eric C.
[email protected] wrote:

var or the -cp JVM argument (as -J-cp when passed to JRuby, of
Documents\Development\Java\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin.jar"

Sorry; I spoke too soon about it working. I forgot I still had the
hard-coded jar path in the script itself. I still get a NameError even
if the jar path doesn’t have spaces.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Mar 3, 2010 at 7:18 PM, Charles Oliver N.
[email protected] wrote:

So the example there didn’t work if you required the jar directly in the script?

Ah… if I require the whole pathname of the jar, and then try
importing classes, that works. However, if I don’t require the jar,
the -J-cp argument doesn’t help:

H:\Projects\Scripts>jruby -J-cp “C:\Documents and
Settings\echristopherson\My
Documents\Development\Java\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin.jar”
jdbc.rb
:1: C:\Documents and Settings\echristopherson\My
Documents\Development\Java\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin.jar:1:
\3Invalid char `\3’ (‘♥’) in expression (SyntaxError)

– I understand it’s trying to treat the jar as a Ruby script because
I put a space after -J-cp, but I don’t think there should be a ‘\3’
before ‘Invalid char `\3’'.

I took out the space after -J-cp:

H:\Projects\Scripts>jruby -J-cp"C:\Documents and
Settings\echristopherson\My
Documents\Development\Java\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin.jar"
jdbc.rb
(eval):1:in `include_class’: cannot load Java class
com.mysql.jdbc.Driver (NameError)

It does work if I set CLASSPATH right. It also works if I use a
pathname without spaces. Would there be any way to make it accommodate
spaces?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Is there anything for JRuby that allows you to read embedded MySQL
databases (i.e. without a server)? I know for Java there’s mysql-je,
so I could probably use that, if nothing else.

I had never even heard of mysql-je. If it has to be an embedded
mysql database, that’s probably your best bet.

If it just needs to be an embedded database, there’s lots of other
options, like Derby (JavaDB), HSQLDB, and even sqlite3.

H2 Database Engine is also nice.

Jon


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Mar 3, 2010 at 7:38 PM, Eric C.
[email protected] wrote:

It does work if I set CLASSPATH right. It also works if I use a
pathname without spaces. Would there be any way to make it accommodate
spaces?

This looks like a bug in how we process -J-cp argument to JRuby. It
should take the quoted string en masse as the element to add to
classpath. Can you file a bug for that?

On UNIX, it appears to work ok:

~/projects/jruby âž” mkdir “path with spaces”

~/projects/jruby âž” cp ~/Downloads/junit-4.6.jar “path with spaces”/

~/projects/jruby âž” jruby -J-cp “path with spaces/junit-4.6.jar” -rjava
-e “p org.junit.Test”
Java::OrgJunit::Test

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Fri, Mar 5, 2010 at 8:56 AM, Charles Oliver N.
[email protected] wrote:

On Wed, Mar 3, 2010 at 7:38 PM, Eric C.
[email protected] wrote:

It does work if I set CLASSPATH right. It also works if I use a
pathname without spaces. Would there be any way to make it accommodate
spaces?

This looks like a bug in how we process -J-cp argument to JRuby. It
should take the quoted string en masse as the element to add to
classpath. Can you file a bug for that?

I will do so. Have you confirmed that it fails in 1.5 too?

It does turn out, though, that spaces aren’t necessarily the problem
– I was actually unable to successfully use -J-cp at all under
Windows. I had a “false positive” when it seemed to work but I had
CLASSPATH set.

On UNIX, it appears to work ok:

~/projects/jruby âž” mkdir “path with spaces”

~/projects/jruby âž” cp ~/Downloads/junit-4.6.jar “path with spaces”/

~/projects/jruby âž” jruby -J-cp “path with spaces/junit-4.6.jar” -rjava
-e “p org.junit.Test”
Java::OrgJunit::Test

Yes, this works on OS X.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Eric,

On Sat, Mar 6, 2010 at 4:57 AM, Eric C.
[email protected] wrote:

On Fri, Mar 5, 2010 at 5:23 PM, Eric C.
[email protected] wrote:

On Fri, Mar 5, 2010 at 8:56 AM, Charles Oliver N.

This looks like a bug in how we process -J-cp argument to JRuby. It
should take the quoted string en masse as the element to add to
classpath. Can you file a bug for that?

I will do so. Have you confirmed that it fails in 1.5 too?

Sorry, never mind. Jruby 1.5 does handle it correctly.

Yes, there was a bug in the native launcher which we fixed in 1.5.dev.
There we so much work on the native launchers since 1.4, so it is
definitely worth at least trying 1.5.0.dev.

Thanks,
–Vladimir


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Fri, Mar 5, 2010 at 5:23 PM, Eric C.
[email protected] wrote:

On Fri, Mar 5, 2010 at 8:56 AM, Charles Oliver N.

This looks like a bug in how we process -J-cp argument to JRuby. It
should take the quoted string en masse as the element to add to
classpath. Can you file a bug for that?

I will do so. Have you confirmed that it fails in 1.5 too?

Sorry, never mind. Jruby 1.5 does handle it correctly.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Sat, Mar 6, 2010 at 1:56 AM, Vladimir S. [email protected]
wrote:

On Sat, Mar 6, 2010 at 4:57 AM, Eric C.
[email protected] wrote:

Sorry, never mind. Jruby 1.5 does handle it correctly.

Yes, there was a bug in the native launcher which we fixed in 1.5.dev.
There we so much work on the native launchers since 1.4, so it is
definitely worth at least trying 1.5.0.dev.

Ok, my bad, I should have suggested trying 1.5 first :slight_smile:

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email