Strage classloading behaviour of JDBC driveres
Hi,
It seems to be some classloading weirdness while running plugin in sandbox. I have dependency on JDBC driver ( statet as plugin dependency ), and to be able to create connection I have to load driver manualy first:
try {
System.err.println(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver") );
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
// create db connection
Properties connectionProps = new Properties();
connectionProps.put("user", pmFacet.getConfiguration().getUsername());
connectionProps.put("password", pmFacet.getConfiguration().getPassword());
System.err.println("created properties");
try {
String databaseConnection = pmFacet.getConfiguration().getDatabaseConnection();
final Connection connection = DriverManager.getConnection(databaseConnection, connectionProps);
Without is, connection fails on driver not found. Usially it is expected to work out of the box, but I also tried:
-Djdbc.drivers=com.microsoft.sqlserver.jdbc.SQLServerDriver
and also adding jar file to IDEA sdk Classloasder - nothing seems to work, and delivers CNFE. What would be a proper way to do this?
Please sign in to leave a comment.