Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connection connection;
- try {
- // this is hard fix for example, ~/hsqldb-2.3.3.jar should be gotten from a setting file
- File jdbcJarFile = new File("~/hsqldb-2.3.3.jar");
- URL urls[] = { jdbcJarFile.toURI().toURL() };
- URLClassLoader loader = new URLClassLoader(urls, DatabaseUtil.class.getClassLoader());
- Thread.currentThread().setContextClassLoader(loader);
- loader.loadClass("org.hsqldb.jdbcDriver");
- // no error but nothing happens
- Class.forName("org.hsqldb.jdbcDriver", true, loader);
- // throw exception because cannot find the driver for HSQL DB
- // with this url: jdbc:hsqldb:file://home/abc/hsqldb/test
- connection = DriverManager.getConnection(datasourceURL, datasourceUserName, datasourcePassword);
- } catch(Exception ex) {
- // (java.sql.SQLException) java.sql.SQLException: No suitable driver found for jdbc:hsqldb:file://home/abc/hsqldb/test
- throw new SQLException(ex);
- }
Add Comment
Please, Sign In to add comment