Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) better error message if jdbc driver could not be loaded

thelif55d3d0d795a
diff --git a/source/dbtest.java b/source/dbtest.java
index add46a50e..084281325 100644
--- a/source/dbtest.java
+++ b/source/dbtest.java
@@ -333,23 +333,26 @@ final class dbTable implements kelondroIndex {
}
private void openDatabaseConnection(String dbType) throws Exception{
- try {
- if (dbType == null) throw new IllegalArgumentException();
-
- String dbDriverStr = null, dbConnStr = null;
- if (dbType.equalsIgnoreCase("mysql")) {
- dbDriverStr = db_driver_str_mysql;
- dbConnStr = db_conn_str_mysql;
- } else if (dbType.equalsIgnoreCase("pgsql")) {
- dbDriverStr = db_driver_str_pgsql;
- dbConnStr = db_conn_str_pgsql;
- }
-
+
+ if (dbType == null) throw new IllegalArgumentException();
+
+ String dbDriverStr = null, dbConnStr = null;
+ if (dbType.equalsIgnoreCase("mysql")) {
+ dbDriverStr = db_driver_str_mysql;
+ dbConnStr = db_conn_str_mysql;
+ } else if (dbType.equalsIgnoreCase("pgsql")) {
+ dbDriverStr = db_driver_str_pgsql;
+ dbConnStr = db_conn_str_pgsql;
+ }
+ try {
Class.forName(dbDriverStr).newInstance();
-
+ } catch (Exception e) {
+ throw new Exception ("Unable to load the jdbc driver: " + e.getMessage(),e);
+ }
+ try {
this.theDBConnection = DriverManager.getConnection (dbConnStr,this.db_usr_str,this.db_pwd_str);
} catch (Exception e) {
- throw new Exception ("Unable to establish a database connection.");
+ throw new Exception ("Unable to establish a database connection: " + e.getMessage(),e);
}
}