public class JdbcDriverHolder extends Object
Constructor and Description |
---|
JdbcDriverHolder(ArtifactDownloader extensionDownloader) |
Modifier and Type | Method and Description |
---|---|
URLClassLoader |
getClassLoader() |
void |
stop()
This method automatically invoked by PicoContainer and deregisters JDBC drivers, which were forgotten.
|
public JdbcDriverHolder(ArtifactDownloader extensionDownloader)
public URLClassLoader getClassLoader()
public void stop()
Dynamically loaded JDBC drivers can not be simply used and this is a well known problem of DriverManager
,
so workaround is to use proxy.
However DriverManager also contains memory leak, thus not only proxy, but also original driver must be deregistered,
otherwise our class loader would be kept in memory.
This operation contains unnecessary complexity because:
JdbcLeakPrevention
. But we can't just create an instance,
since it will be loaded by parent class loader and again will not pass DriverManager's check.
So, we load the bytes via our parent class loader, but define the class with this class loader
thus JdbcLeakPrevention looks like our class to the DriverManager.Copyright © 2009-2012 SonarSource. All Rights Reserved.