I have the following method to connect to our DB2 database. If the username and password passed in are valid then it works fine, but if they are not it gets stuck on the second getConnection. What am I missing?
Code:
private Connection setupDB2Connection(String username, String password) throws SQLException {
if (connDB2!=null) {
if(!connDB2.isClosed()) {
connDB2.close();
connDB2 = null;
}
}
DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
if (username == null || password == null) {
connDB2 = DriverManager.getConnection("jdbc:as400://EJDEV;prompt=true");
}
else {
connDB2 = DriverManager.getConnection("jdbc:as400://EJDEV;", username, password);
}
return connDB2;
}