This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes rmid and activatable class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "rmid and activatable class" Watch "rmid and activatable class" New topic

rmid and activatable class

Matt Sall

Joined: Jul 01, 2007
Posts: 19

I have succefully registered an activatable class to rmid. This class, ServerImpl, needs to open a connection to a MySQL database located on another computer. The JDBC driver(mysql.jar) is located on a webserver. The code for this is in the the contructor, like this:

I get an exception when starting the client, which says, "Can't find a suitable driver for jdbc:mysql://hostname/db". Normally you would use Class.forName("com.mysql.jdbc.Driver), but that won't work here(?). How can I load the driver so that this activatable class can see it?

Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

What i understood from your question is:

You can not put the jar containing the driver classes in the application classpath. So, you are creating one classloader containing the location of the jar and instantiate the driver using this classloader.
However, you are not able to set the same classloader while doing:

Is my understanding correct?

If yes, then you do not need to use DriverManager.getConnection() for drivers loaded by custom classloaders.
Instead you can use:

This thread has more details on which properties to pass to the connect method.

apigee, a better way to API!
It is sorta covered in the JavaRanch Style Guide.
subject: rmid and activatable class