:: Class Loader and JDBC DriverManager issue ::
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bhaktavatsalamreddy_Gani
Posted On:   Thursday, August 25, 2005 03:00 AM

My application is demanding to load the JDBC driver jars explicitely using custom class loaders. So, we dont keep the driver jars in the class path I am encountered with an exception and the message says"No suitable driver" Code Snippet is as follows: CustomClassLoader loader = new CustomClassLoader( Thread.currentThread().getContextClassLoader()) loader.addJar("driverjar.jar"); class clazz = loader.loadClass"com.microsoft.jdbc.sqlserver.SQLServerDriver"); DriverManager.registerDriver(clazz.newInstance()); DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind","sa", "sa")   More>>

My application is demanding to load the JDBC driver jars explicitely using custom class loaders. So, we dont keep the driver jars in the class path


I am encountered with an exception and the message says"No suitable driver"


Code Snippet is as follows:


CustomClassLoader loader = new CustomClassLoader( Thread.currentThread().getContextClassLoader())


loader.addJar("driverjar.jar");


class clazz = loader.loadClass"com.microsoft.jdbc.sqlserver.SQLServerDriver");


DriverManager.registerDriver(clazz.newInstance());
DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind","sa", "sa");


when getConnection statement is executed it is raising that exception with an error message: No suitable driver


My question is driver is getting registered. Why it is not detecting that registered driver.


My Understading is DriverManager is loaded by System class loader and it is trying to check whether driver is also loaded by the same class loader.

In this case driver is loaded by custom class loader. That's why it is not succeding. If this is the case how the web application are working. because webservers and app servers have their own class loaders and they will load the web app.


Can any body help me in this regards.

Thanks in advance,
BhaktavatsalamReddy. gani

   <<Less

Re: :: Class Loader and JDBC DriverManager issue ::

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, August 26, 2005 10:29 PM

Web app servers are not using your "CustomClassLoader", that might be the problem?
About | Sitemap | Contact