I'm trying to connect to a remote database using the following java code, but I get an error saying no suitable driver found
I have included the required db2 libraries in my project:
I have declared the jdbc settings in the main class
Settings.loadSettings();
Class.forName("Settings.DB2_JDBC_DRIVER");
Controller con = new Controller();
con.business_logic();
}
Then trying to connect the database in another class
public Connection getDBConnection()
{
Connection DBConnection = null;
try {
System.out.println("Connecting to database " + Settings.DBName + ".");
String DBURL = "jdbc:db2://" + Settings.DBServer + ":" + Settings.DBPort +
"/" + Settings.DBName + ";";
String decryptedPass = decryptPassString(Settings.DBPass);
DBConnection = DriverManager.getConnection(DBURL, Settings.DBUser,
decryptedPass);
System.out.println("Database connection successfully established to
database " + Settings.DBName + " using user " + Settings.DBUser + ".");
return DBConnection;
}
catch (Exception e) {
System.out.println("An unexpected error occurred when attempting to
establish connection to database " + Settings.DBName + ". The error was: "
+ e.getMessage() + "\r\n" + e.getMessage()); }
return DBConnection;
}
can anyone please explain what i am missing here ?
The error message i am receiving is
An unexpected error occurred when attempting to establish connection to database DWHER00. The error was: No suitable driver found for jdbc:db2:/