try to connect without loading the driver

This commit is contained in:
Wisser
2018-05-28 08:01:20 +02:00
parent ba002a00ec
commit 106e7fa20b
2 changed files with 8 additions and 2 deletions
@@ -17,6 +17,7 @@ package net.sf.jailer.database;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import java.sql.SQLException;
import java.util.UUID;
@@ -47,7 +48,12 @@ public class LocalDatabase {
public LocalDatabase(String driverClassName, String urlPattern, String user, String password, String jarfile) throws ClassNotFoundException, FileNotFoundException, SQLException {
this.databaseFolder = new File(Configuration.getInstance().getTempFileFolder() + File.separator + UUID.randomUUID().toString()).getAbsolutePath();
new File(databaseFolder).mkdirs();
BasicDataSource dataSource = new BasicDataSource(driverClassName, urlPattern.replace("%s", databaseFolder + File.separator + "local"), user, password, 0, ClasspathUtil.toURLArray(jarfile, null, null, null));
BasicDataSource dataSource;
try {
dataSource = new BasicDataSource(driverClassName, urlPattern.replace("%s", databaseFolder + File.separator + "local"), user, password, 0, new URL[0]);
} catch (Exception e) {
dataSource = new BasicDataSource(driverClassName, urlPattern.replace("%s", databaseFolder + File.separator + "local"), user, password, 0, ClasspathUtil.toURLArray(jarfile, null, null, null));
}
session = new Session(dataSource, dataSource.dbms, null, false, true);
}
@@ -967,7 +967,7 @@ public class DbConnectionDialog extends javax.swing.JDialog {
if (e.getCause() instanceof ClassNotFoundException) {
UIUtil.showException(parent, "Could not connect to DB", new ClassNotFoundException("JDBC driver class not found: '" + e.getMessage() + "'", e.getCause()), UIUtil.EXCEPTION_CONTEXT_USER_ERROR);
} else {
UIUtil.showException(parent, "Could not connect to DB", e, UIUtil.EXCEPTION_CONTEXT_USER_ERROR);
UIUtil.showException(parent, "Could not connect to DB (" + (e.getClass().getSimpleName()) + ")", e, UIUtil.EXCEPTION_CONTEXT_USER_ERROR);
}
return false;
}