• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

rmid and activatable class

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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?

Regards,
Mattias
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic